* Peter Zijlstra <pet...@infradead.org> wrote: > On Wed, Feb 14, 2018 at 09:52:59AM +0000, Yatsina, Marina wrote: > > Hi Peter, > > > > When I started the original thread last year I was in favor of adding > > "asm goto" and didn't understand why it wasn't done by that time. The > > feedback I got is that this feature (optimizing tracepoints) is very > > useful and that we do want it in llvm, but perhaps there's a cleaner > > way of implementing than "asm goto". An alternative suggestion arose > > as well. > > So it's far more than just tracepoints. We use it all over the kernel to > do runtime branch patching. > > One example is avoiding the scheduler preemption callbacks if we know > there are no users. This shaves a few % off a context switch > micro-bench. > > But it is really _all_ over the place.
To quantify it: I just performed a test build of a Linux distro kernel config (Fedora x86-64), and counted the number of callsites that use 'asm goto' functionality with the v4.15 kernel (including drivers). The results: Linux distro | !CONFIG_TRACING ----------------------------------------------------------------------------- total # of functions : 191,567 | 184,443 total # of instructions : 14,251,355 | 13,526,112 ----------------------------------------------------------------------------- total # of spin_lock*() calls : 25,246 | 25,177 total # of mutex_lock*() calls : 13,062 | 12,861 total # of kmalloc*() calls : 5,148 | 5,118 ----------------------------------------------------------------------------- total # of 'asm goto' usage sites : 34,851 | 31,059 total # of 'asm goto' using functions : 18,209 | 16,089 ----------------------------------------------------------------------------- percent of kernel functions using 'asm goto' : 9.5% | 8.7% ----------------------------------------------------------------------------- ( Note: I added the 'tracing disabled' column only to demonstrate how widely 'asm goto' is used beyond tracing - but since *all* major Linux distributions have tracing enabled it's the first column that matters in practice. ) So 'asm goto' is a major, major compiler feature the Linux kernel relies on: in fact in the Linux kernel there's more 'asm goto' usage sites than there are spin-lock critical sections! Thanks, Ingo