1RCU Concepts
   4The basic idea behind RCU (read-copy update) is to split destructive
   5operations into two parts, one that prevents anyone from seeing the data
   6item being destroyed, and one that actually carries out the destruction.
   7A "grace period" must elapse between the two parts, and this grace period
   8must be long enough that any readers accessing the item being deleted have
   9since dropped their references.  For example, an RCU-protected deletion
  10from a linked list would first remove the item from the list, wait for
  11a grace period to elapse, then free the element.  See the listRCU.txt
  12file for more information on using RCU with linked lists.
  15Frequently Asked Questions
  17o       Why would anyone want to use RCU?
  19        The advantage of RCU's two-part approach is that RCU readers need
  20        not acquire any locks, perform any atomic instructions, write to
  21        shared memory, or (on CPUs other than Alpha) execute any memory
  22        barriers.  The fact that these operations are quite expensive
  23        on modern CPUs is what gives RCU its performance advantages
  24        in read-mostly situations.  The fact that RCU readers need not
  25        acquire locks can also greatly simplify deadlock-avoidance code.
  27o       How can the updater tell when a grace period has completed
  28        if the RCU readers give no indication when they are done?
  30        Just as with spinlocks, RCU readers are not permitted to
  31        block, switch to user-mode execution, or enter the idle loop.
  32        Therefore, as soon as a CPU is seen passing through any of these
  33        three states, we know that that CPU has exited any previous RCU
  34        read-side critical sections.  So, if we remove an item from a
  35        linked list, and then wait until all CPUs have switched context,
  36        executed in user mode, or executed in the idle loop, we can
  37        safely free up that item.
  39        Preemptible variants of RCU (CONFIG_TREE_PREEMPT_RCU) get the
  40        same effect, but require that the readers manipulate CPU-local
  41        counters.  These counters allow limited types of blocking within
  42        RCU read-side critical sections.  SRCU also uses CPU-local
  43        counters, and permits general blocking within RCU read-side
  44        critical sections.  These variants of RCU detect grace periods
  45        by sampling these counters.
  47o       If I am running on a uniprocessor kernel, which can only do one
  48        thing at a time, why should I wait for a grace period?
  50        See the UP.txt file in this directory.
  52o       How can I see where RCU is currently used in the Linux kernel?
  54        Search for "rcu_read_lock", "rcu_read_unlock", "call_rcu",
  55        "rcu_read_lock_bh", "rcu_read_unlock_bh", "call_rcu_bh",
  56        "srcu_read_lock", "srcu_read_unlock", "synchronize_rcu",
  57        "synchronize_net", "synchronize_srcu", and the other RCU
  58        primitives.  Or grab one of the cscope databases from:
  62o       What guidelines should I follow when writing code that uses RCU?
  64        See the checklist.txt file in this directory.
  66o       Why the name "RCU"?
  68        "RCU" stands for "read-copy update".  The file listRCU.txt has
  69        more information on where this name came from, search for
  70        "read-copy update" to find it.
  72o       I hear that RCU is patented?  What is with that?
  74        Yes, it is.  There are several known patents related to RCU,
  75        search for the string "Patent" in RTFP.txt to find them.
  76        Of these, one was allowed to lapse by the assignee, and the
  77        others have been contributed to the Linux kernel under GPL.
  78        There are now also LGPL implementations of user-level RCU
  79        available (
  81o       I hear that RCU needs work in order to support realtime kernels?
  83        This work is largely completed.  Realtime-friendly RCU can be
  84        enabled via the CONFIG_TREE_PREEMPT_RCU kernel configuration
  85        parameter.  However, work is in progress for enabling priority
  86        boosting of preempted RCU read-side critical sections.  This is
  87        needed if you have CPU-bound realtime threads.
  89o       Where can I find more information on RCU?
  91        See the RTFP.txt file in this directory.
  92        Or point your browser at
  94o       What are all these files in this directory?
  96        See 00-INDEX for the list.
  97 kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.