SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Userspace RCU Library:

 What Linear Multiprocessor
 Scalability Means for Your
        Application

   Linux Plumbers Conference 2009

          Mathieu Desnoyers
   École Polytechnique de Montréal
> Mathieu Desnoyers
●   Author/maintainer of :
    –   LTTV (Linux Trace Toolkit Viewer)
         ●   2003-...
    –   LTTng (Linux Trace Toolkit Next Generation)
         ●   2005-...
    –   Immediate Values
         ●   2007...
    –   Tracepoints
         ●   2008-...
    –   Userspace RCU Library
2
         ●   2009-...
> Contributions by
●   Paul E. McKenney
    –   IBM Linux Technology Center
●   Alan Stern
    –   Rowland Institute, Harvard University
●   Jonathan Walpole
    –   Computer Science Department, Portland
        State University
●   Michel Dagenais
    –   Computer and Software Engineering Dpt.,
3       École Polytechnique de Montréal
> Summary
●   RCU Overview
●   Kernel vs Userspace RCU
●   Userspace RCU Library
●   Benchmarks
●   RCU-Friendly Applications




4
> Linux Kernel RCU Usage




5
> RCU Overview
●   Relativistic programming
    –   Updates seen in different orders by CPUs
    –   Tolerates conflicts
●   Linear scalability
●   Wait-free read-side
●   Efficient updates
    –   Only a single pointer exchange needs
        exclusive access

6
> Schematic of RCU Update
          and Read-Side C.S.




7
> RCU Linked-List Deletion




8
> Kernel vs Userspace RCU
●   Quiescent state
    –   Kernel threads
         ●   Wait for kernel pre-existing RCU read-side C.S. to
             complete
    –   User threads
         ●   Wait for process pre-existing RCU read-side C.S. to
             complete




9
> Userspace RCU Library
●    QSBR
     –   liburcu-qsbr.so
●    Generic RCU
     –   liburcu-mb.so
●    Signal-based RCU
     –   liburcu.so
●    call_rcu()
     –   liburcu-defer.so

10
> QSBR
●    Detection of quiescent state:
     –   Each reader thread calls
         rcu_quiescent_state() periodically.
●    Require application modification
●    Read-side with very low overhead




11
> Generic RCU
●    Detection of quiescent state:
     –   rcu_read_lock()/rcu_read_unlock() mark the
         beginning/end of the critical sections
     –   Counts nesting level
●    Suitable for library use
●    Higher read-side overhead than QSBR
     due to added memory barriers



12
> Signal-based RCU
●    Same quiescent state detection as
     Generic RCU
●    Suitable for library use, but reserves a
     signal
●    Read-side close to QSBR performance
     –   Remove memory barriers from
         rcu_read_lock()/rcu_read_unlock().
     –   Replaced by memory barriers in signal
         handler, executed at each update-side
         memory barrier.
13
> call_rcu()
●    Eliminates the need to call
     synchronize_rcu() after each removal
●    Queues RCU callbacks for deferred
     batched execution
●    Wait-free unless per-thread queue is full
●    “Worker thread” executes callbacks
     periodically
●    Energy-efficient, uses sys_futex()

14
> Example: RCU Read-Side

     struct mystruct *rcudata = &somedata;

     /* register thread with rcu_register_thread()/rcu_unregister_thread() */
     void fct(void)
     {
          struct mystruct *ptr;

         rcu_read_lock();
         ptr = rcu_dereference(rcudata);
         /* use ptr */
         rcu_read_unlock();
     }




15
> Example: exchange pointer

     struct mystruct *rcudata = &somedata;

     void replace_data(struct mystruct data)
     {
         struct mystruct *new, *old;

         new = malloc(sizeof(*new));
         memcpy(new, &data, sizeof(*new));
         old = rcu_xchg_pointer(&rcudata, new);
         call_rcu(free, old);
     }




16
> Example:
compare-and-exchange pointer
     struct mystruct *rcudata = &somedata;

     /* register thread with rcu_register_thread()/rcu_unregister_thread() */
     void modify_data(int increment_a, int increment_b)
     {
          struct mystruct *new, *old;

         new = malloc(sizeof(*new));
         rcu_read_lock();     /* Ensure pointer is not re-used */
         do {
              old = rcu_dereference(rcudata);
              memcpy(new, old, sizeof(*new));
              new->field_a += increment_a;
              new->field_b += increment_b;
         } while (rcu_cmpxchg_pointer(&rcudata, old, new) != old);
         rcu_read_unlock();
         call_rcu(free, old);
     }
17
> Benchmarks
●    Read-side Scalability
●    Read-side C.S. length impact
●    Update Overhead




18
> Read-Side Scalability




64-cores POWER5+

19
> Read-Side C.S. Length Impact




64-cores POWER5+, logarithmic scale (x, y)

20
> Update Overhead




64-cores POWER5+, logarithmic scale (x, y)

21
> RCU-Friendly Applications
●    Multithreaded applications with read-
     often shared data
     –   Cache
          ●   Name servers
          ●   Proxy
          ●   Web servers with static pages
     –   Configuration
          ●   Low synchronization overhead
          ●   Dynamically modified without restart


22
> RCU-Friendly Applications
●    Libraries supporting multithreaded
     applications
     –   Tracing library, e.g. lib UST (LTTng port for
         userspace tracing)
          ●   http://git.dorsal.polymtl.ca/?p=ust.git




23
> RCU-Friendly Applications
●    Libraries supporting multithreaded
     applications (cont.)
     –   Typing/data structure support
          ●   Typing system
               –   Creation of a class is a rare event
               –   Reading class structure happens at object
                   creation/destruction (_very_ often)
               –   Applies to gobject
                     ● Used by: gtk/gdk/glib/gstreamer...


          ●   Efficient hash tables
          ●   Glib “quarks”

24
> RCU-Friendly Applications
●    Routing tables in userspace
●    Userspace network stacks
●    Userspace signal-handling
     –   Signal-safe read-side
     –   Could implement an inter-thread signal
         multiplexer
●    Your own ?


25
> Info / Download / Contact
●    Mathieu Desnoyers
     –   Computer and Software Engineering Dpt.,
         École Polytechnique de Montréal
●    Web site:
     –   http://www.lttng.org/urcu
●    Git tree
     –   git://lttng.org/userspace-rcu.git
●    Email
     –   mathieu.desnoyers@polymtl.ca
26

Más contenido relacionado

La actualidad más candente

Hungarian ClusterGrid and its applications
Hungarian ClusterGrid and its applicationsHungarian ClusterGrid and its applications
Hungarian ClusterGrid and its applications
Ferenc Szalai
 

La actualidad más candente (19)

Autentia OS - 20180210 - Docker y las películas de chinos
Autentia OS - 20180210 - Docker y las películas de chinosAutentia OS - 20180210 - Docker y las películas de chinos
Autentia OS - 20180210 - Docker y las películas de chinos
 
OSDC 2013 | Distributed Storage with GlusterFS by Dr. Udo Seidel
OSDC 2013 | Distributed Storage with GlusterFS by Dr. Udo SeidelOSDC 2013 | Distributed Storage with GlusterFS by Dr. Udo Seidel
OSDC 2013 | Distributed Storage with GlusterFS by Dr. Udo Seidel
 
Caffe + H2O - By Cyprien noel
Caffe + H2O - By Cyprien noelCaffe + H2O - By Cyprien noel
Caffe + H2O - By Cyprien noel
 
Integrating GlusterFS with iSCSI Target
Integrating GlusterFS with iSCSI TargetIntegrating GlusterFS with iSCSI Target
Integrating GlusterFS with iSCSI Target
 
Linux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and OpportunitiesLinux NUMA & Databases: Perils and Opportunities
Linux NUMA & Databases: Perils and Opportunities
 
The Linux Kernel Scheduler (For Beginners) - SFO17-421
The Linux Kernel Scheduler (For Beginners) - SFO17-421The Linux Kernel Scheduler (For Beginners) - SFO17-421
The Linux Kernel Scheduler (For Beginners) - SFO17-421
 
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie MorganEmbedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
Embedded Recipes 2018 - Shared memory / telemetry - Yves-Marie Morgan
 
OpenNebulaConf2018 - OpenNebula and LXD Containers - Rubén S. Montero - OpenN...
OpenNebulaConf2018 - OpenNebula and LXD Containers - Rubén S. Montero - OpenN...OpenNebulaConf2018 - OpenNebula and LXD Containers - Rubén S. Montero - OpenN...
OpenNebulaConf2018 - OpenNebula and LXD Containers - Rubén S. Montero - OpenN...
 
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMsJava one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
 
Linux Locking Mechanisms
Linux Locking MechanismsLinux Locking Mechanisms
Linux Locking Mechanisms
 
OpenNebula LXD Container Support overview
OpenNebula LXD Container Support overviewOpenNebula LXD Container Support overview
OpenNebula LXD Container Support overview
 
FOSDEM2015: Live migration for containers is around the corner
FOSDEM2015: Live migration for containers is around the cornerFOSDEM2015: Live migration for containers is around the corner
FOSDEM2015: Live migration for containers is around the corner
 
September 7, 2019 Cloud Native and Containerisation (Joint Meetup with Docke...
September 7, 2019  Cloud Native and Containerisation (Joint Meetup with Docke...September 7, 2019  Cloud Native and Containerisation (Joint Meetup with Docke...
September 7, 2019 Cloud Native and Containerisation (Joint Meetup with Docke...
 
Mahti quick-start guide
Mahti quick-start guide Mahti quick-start guide
Mahti quick-start guide
 
Gjergj Sheldija: Albania
Gjergj Sheldija: AlbaniaGjergj Sheldija: Albania
Gjergj Sheldija: Albania
 
PASTE: Network Stacks Must Integrate with NVMM Abstractions
PASTE: Network Stacks Must Integrate with NVMM AbstractionsPASTE: Network Stacks Must Integrate with NVMM Abstractions
PASTE: Network Stacks Must Integrate with NVMM Abstractions
 
Hungarian ClusterGrid and its applications
Hungarian ClusterGrid and its applicationsHungarian ClusterGrid and its applications
Hungarian ClusterGrid and its applications
 
Enduro/X Middleware
Enduro/X MiddlewareEnduro/X Middleware
Enduro/X Middleware
 
Gluster fs hadoop_fifth-elephant
Gluster fs hadoop_fifth-elephantGluster fs hadoop_fifth-elephant
Gluster fs hadoop_fifth-elephant
 

Similar a Userspace RCU library : what linear multiprocessor scalability means for your application

Building a QT based solution on a i.MX7 processor running Linux and FreeRTOS
Building a QT based solution on a i.MX7 processor running Linux and FreeRTOSBuilding a QT based solution on a i.MX7 processor running Linux and FreeRTOS
Building a QT based solution on a i.MX7 processor running Linux and FreeRTOS
Fernando Luiz Cola
 
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Andrey Vagin
 
Checkpoint and Restore In Userspace
Checkpoint and Restore In UserspaceCheckpoint and Restore In Userspace
Checkpoint and Restore In Userspace
OpenVZ
 

Similar a Userspace RCU library : what linear multiprocessor scalability means for your application (20)

Gluster d thread_synchronization_using_urcu_lca2016
Gluster d thread_synchronization_using_urcu_lca2016Gluster d thread_synchronization_using_urcu_lca2016
Gluster d thread_synchronization_using_urcu_lca2016
 
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
Kubernetes @ Squarespace (SRE Portland Meetup October 2017)
 
Mastering Real-time Linux
Mastering Real-time LinuxMastering Real-time Linux
Mastering Real-time Linux
 
Glusterd_thread_synchronization_using_urcu_lca2016
Glusterd_thread_synchronization_using_urcu_lca2016Glusterd_thread_synchronization_using_urcu_lca2016
Glusterd_thread_synchronization_using_urcu_lca2016
 
Rlite software-architecture (1)
Rlite software-architecture (1)Rlite software-architecture (1)
Rlite software-architecture (1)
 
Building a QT based solution on a i.MX7 processor running Linux and FreeRTOS
Building a QT based solution on a i.MX7 processor running Linux and FreeRTOSBuilding a QT based solution on a i.MX7 processor running Linux and FreeRTOS
Building a QT based solution on a i.MX7 processor running Linux and FreeRTOS
 
Kubernetes @ Squarespace: Kubernetes in the Datacenter
Kubernetes @ Squarespace: Kubernetes in the DatacenterKubernetes @ Squarespace: Kubernetes in the Datacenter
Kubernetes @ Squarespace: Kubernetes in the Datacenter
 
Onnc intro
Onnc introOnnc intro
Onnc intro
 
Linux Synchronization Mechanism: RCU (Read Copy Update)
Linux Synchronization Mechanism: RCU (Read Copy Update)Linux Synchronization Mechanism: RCU (Read Copy Update)
Linux Synchronization Mechanism: RCU (Read Copy Update)
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
 
Андрей Вагин. Все что вы хотели знать о Criu, но стеснялись спросить...
Андрей Вагин. Все что вы хотели знать о Criu, но стеснялись спросить...Андрей Вагин. Все что вы хотели знать о Criu, но стеснялись спросить...
Андрей Вагин. Все что вы хотели знать о Criu, но стеснялись спросить...
 
Checkpoint and Restore In Userspace
Checkpoint and Restore In UserspaceCheckpoint and Restore In Userspace
Checkpoint and Restore In Userspace
 
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
Open WG Talk #2 Everything you wanted to know about CRIU (but were afraid to ...
 
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
 
State of ARM-based HPC
State of ARM-based HPCState of ARM-based HPC
State of ARM-based HPC
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQ
 
LTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space TracingLTTng-UST: Efficient System-Wide User-Space Tracing
LTTng-UST: Efficient System-Wide User-Space Tracing
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stack
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Userspace RCU library : what linear multiprocessor scalability means for your application

  • 1. Userspace RCU Library: What Linear Multiprocessor Scalability Means for Your Application Linux Plumbers Conference 2009 Mathieu Desnoyers École Polytechnique de Montréal
  • 2. > Mathieu Desnoyers ● Author/maintainer of : – LTTV (Linux Trace Toolkit Viewer) ● 2003-... – LTTng (Linux Trace Toolkit Next Generation) ● 2005-... – Immediate Values ● 2007... – Tracepoints ● 2008-... – Userspace RCU Library 2 ● 2009-...
  • 3. > Contributions by ● Paul E. McKenney – IBM Linux Technology Center ● Alan Stern – Rowland Institute, Harvard University ● Jonathan Walpole – Computer Science Department, Portland State University ● Michel Dagenais – Computer and Software Engineering Dpt., 3 École Polytechnique de Montréal
  • 4. > Summary ● RCU Overview ● Kernel vs Userspace RCU ● Userspace RCU Library ● Benchmarks ● RCU-Friendly Applications 4
  • 5. > Linux Kernel RCU Usage 5
  • 6. > RCU Overview ● Relativistic programming – Updates seen in different orders by CPUs – Tolerates conflicts ● Linear scalability ● Wait-free read-side ● Efficient updates – Only a single pointer exchange needs exclusive access 6
  • 7. > Schematic of RCU Update and Read-Side C.S. 7
  • 8. > RCU Linked-List Deletion 8
  • 9. > Kernel vs Userspace RCU ● Quiescent state – Kernel threads ● Wait for kernel pre-existing RCU read-side C.S. to complete – User threads ● Wait for process pre-existing RCU read-side C.S. to complete 9
  • 10. > Userspace RCU Library ● QSBR – liburcu-qsbr.so ● Generic RCU – liburcu-mb.so ● Signal-based RCU – liburcu.so ● call_rcu() – liburcu-defer.so 10
  • 11. > QSBR ● Detection of quiescent state: – Each reader thread calls rcu_quiescent_state() periodically. ● Require application modification ● Read-side with very low overhead 11
  • 12. > Generic RCU ● Detection of quiescent state: – rcu_read_lock()/rcu_read_unlock() mark the beginning/end of the critical sections – Counts nesting level ● Suitable for library use ● Higher read-side overhead than QSBR due to added memory barriers 12
  • 13. > Signal-based RCU ● Same quiescent state detection as Generic RCU ● Suitable for library use, but reserves a signal ● Read-side close to QSBR performance – Remove memory barriers from rcu_read_lock()/rcu_read_unlock(). – Replaced by memory barriers in signal handler, executed at each update-side memory barrier. 13
  • 14. > call_rcu() ● Eliminates the need to call synchronize_rcu() after each removal ● Queues RCU callbacks for deferred batched execution ● Wait-free unless per-thread queue is full ● “Worker thread” executes callbacks periodically ● Energy-efficient, uses sys_futex() 14
  • 15. > Example: RCU Read-Side struct mystruct *rcudata = &somedata; /* register thread with rcu_register_thread()/rcu_unregister_thread() */ void fct(void) { struct mystruct *ptr; rcu_read_lock(); ptr = rcu_dereference(rcudata); /* use ptr */ rcu_read_unlock(); } 15
  • 16. > Example: exchange pointer struct mystruct *rcudata = &somedata; void replace_data(struct mystruct data) { struct mystruct *new, *old; new = malloc(sizeof(*new)); memcpy(new, &data, sizeof(*new)); old = rcu_xchg_pointer(&rcudata, new); call_rcu(free, old); } 16
  • 17. > Example: compare-and-exchange pointer struct mystruct *rcudata = &somedata; /* register thread with rcu_register_thread()/rcu_unregister_thread() */ void modify_data(int increment_a, int increment_b) { struct mystruct *new, *old; new = malloc(sizeof(*new)); rcu_read_lock(); /* Ensure pointer is not re-used */ do { old = rcu_dereference(rcudata); memcpy(new, old, sizeof(*new)); new->field_a += increment_a; new->field_b += increment_b; } while (rcu_cmpxchg_pointer(&rcudata, old, new) != old); rcu_read_unlock(); call_rcu(free, old); } 17
  • 18. > Benchmarks ● Read-side Scalability ● Read-side C.S. length impact ● Update Overhead 18
  • 20. > Read-Side C.S. Length Impact 64-cores POWER5+, logarithmic scale (x, y) 20
  • 21. > Update Overhead 64-cores POWER5+, logarithmic scale (x, y) 21
  • 22. > RCU-Friendly Applications ● Multithreaded applications with read- often shared data – Cache ● Name servers ● Proxy ● Web servers with static pages – Configuration ● Low synchronization overhead ● Dynamically modified without restart 22
  • 23. > RCU-Friendly Applications ● Libraries supporting multithreaded applications – Tracing library, e.g. lib UST (LTTng port for userspace tracing) ● http://git.dorsal.polymtl.ca/?p=ust.git 23
  • 24. > RCU-Friendly Applications ● Libraries supporting multithreaded applications (cont.) – Typing/data structure support ● Typing system – Creation of a class is a rare event – Reading class structure happens at object creation/destruction (_very_ often) – Applies to gobject ● Used by: gtk/gdk/glib/gstreamer... ● Efficient hash tables ● Glib “quarks” 24
  • 25. > RCU-Friendly Applications ● Routing tables in userspace ● Userspace network stacks ● Userspace signal-handling – Signal-safe read-side – Could implement an inter-thread signal multiplexer ● Your own ? 25
  • 26. > Info / Download / Contact ● Mathieu Desnoyers – Computer and Software Engineering Dpt., École Polytechnique de Montréal ● Web site: – http://www.lttng.org/urcu ● Git tree – git://lttng.org/userspace-rcu.git ● Email – mathieu.desnoyers@polymtl.ca 26