SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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
 

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