Userspace RCU Library: What Linear Multiprocessor Scalability Means - - PowerPoint PPT Presentation

userspace rcu library
SMART_READER_LITE
LIVE PREVIEW

Userspace RCU Library: What Linear Multiprocessor Scalability Means - - PowerPoint PPT Presentation

Userspace RCU Library: What Linear Multiprocessor Scalability Means for Your Application Linux Plumbers Conference 2009 Mathieu Desnoyers cole Polytechnique de Montral > Mathieu Desnoyers Author/maintainer of : LTTV (Linux


slide-1
SLIDE 1

What Linear Multiprocessor Scalability Means for Your Application

Linux Plumbers Conference 2009 Mathieu Desnoyers École Polytechnique de Montréal

Userspace RCU Library:

slide-2
SLIDE 2

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

  • 2009-...
slide-3
SLIDE 3

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.,

École Polytechnique de Montréal

slide-4
SLIDE 4

4

> Summary

  • RCU Overview
  • Kernel vs Userspace RCU
  • Userspace RCU Library
  • Benchmarks
  • RCU-Friendly Applications
slide-5
SLIDE 5

5

> Linux Kernel RCU Usage

slide-6
SLIDE 6

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

slide-7
SLIDE 7

7

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

slide-8
SLIDE 8

8

> RCU Linked-List Deletion

slide-9
SLIDE 9

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

slide-10
SLIDE 10

10

> Userspace RCU Library

  • QSBR

– liburcu-qsbr.so

  • Generic RCU

– liburcu-mb.so

  • Signal-based RCU

– liburcu.so

  • call_rcu()

– liburcu-defer.so

slide-11
SLIDE 11

11

> QSBR

  • Detection of quiescent state:

– Each reader thread calls

rcu_quiescent_state() periodically.

  • Require application modification
  • Read-side with very low overhead
slide-12
SLIDE 12

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

slide-13
SLIDE 13

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.

slide-14
SLIDE 14

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()
slide-15
SLIDE 15

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(); }

slide-16
SLIDE 16

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));

  • ld = rcu_xchg_pointer(&rcudata, new);

call_rcu(free, old); }

slide-17
SLIDE 17

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 {

  • ld = 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); }

slide-18
SLIDE 18

18

> Benchmarks

  • Read-side Scalability
  • Read-side C.S. length impact
  • Update Overhead
slide-19
SLIDE 19

19

> Read-Side Scalability

64-cores POWER5+

slide-20
SLIDE 20

20

> Read-Side C.S. Length Impact

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

slide-21
SLIDE 21

21

> Update Overhead

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

slide-22
SLIDE 22

22

> RCU-Friendly Applications

  • Multithreaded applications with read-
  • ften shared data

– Cache

  • Name servers
  • Proxy
  • Web servers with static pages

– Configuration

  • Low synchronization overhead
  • Dynamically modified without restart
slide-23
SLIDE 23

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
slide-24
SLIDE 24

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”
slide-25
SLIDE 25

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 ?
slide-26
SLIDE 26

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