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. Besides, given that RCU has been in the Linux kernel for almost two decades, one would expect it to be losing the “advanced” adjective any day now.

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 don't rise so far 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 a bit further 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, and within one order of magnitude in 2018. RCU usage now exceeds 10% that of locking, 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: 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.