RCU Linux Usage

There probably are not many people left who would argue that the Linux community is inherently incapable of using advanced synchronization as exemplified by RCU, but creating these graphs has become a heavily scripted habit.

The best summary of Linux RCU usage is graphical:

However, the above plot might give a too-prominent impression of RCU's usage in the Linux kernel. It is more even-handed to compare RCU usage to the combination of that of spinlocks and semaphores, both exclusive and reader-writer variants, as shown below:

Here, the traces for RCU barely rise off of the x-axis. Furthermore, the rate of usage of RCU (in absolute terms) is growing more slowly than that of locking. Lastly, the trace for locking is conservative, since it counts only the main locking primitives themselves, and not the “wrapper” macros that are commonly used throughout the kernel. (That said, RCU is now gaining a considerable number of wrappers as well, and these are not counted, either.)

Finally, in order to pull RCU off of the x-axis, the next figure shows this same data on a semi-log plot:

Here we can see that the percent rate of growth of RCU has exceeded that of the other locking primitives, so that as of late 2004, the use of RCU rose to within two orders of magnitude of that of normal locking. The ratio of RCU usage to locking usage has continued to grow, as can be seen in the following figure:

However, please note that I do not expect RCU's usage to ever come close to that of the combined locking primitives. For one thing, the rate of RCU's growth has in fact been decreasing, approaching that of the other primitives. Furthermore, the absolute level of RCU usage does decrease sometimes, for example, during netfilter consolidation in 2.6.22 in mid-2007. This is to be expected: RCU has for the most part found its place at somewhere between 6% and 7% of the uses of the locking primitives. After all, RCU is a very specialized primitive, and it is exceedingly important to use the right tool for the job. For a great many jobs, normal locking remains the best tool. Finally, almost all RCU uses in the Linux kernel use locking to protect updates, which does place a hard upper limit on RCU's fraction of synchronization primitives.

The raw data for these plots are available here and on kernel.org. The scripts that produced this data from kernel.org are available (under GPL) here.