tracing, perf: Adjust code layout in get_recursion_context()
authorJesper Dangaard Brouer <brouer@redhat.com>
Tue, 22 Aug 2017 17:22:43 +0000 (19:22 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 25 Aug 2017 09:04:18 +0000 (11:04 +0200)
commitd0618410eced4eb092295fad10312a4545fcdfaf
tree927f02a812f22f476c608dabcd4e6b25917963ff
parent1d953111b648e48923171c3c9cf17be2250544fa
tracing, perf: Adjust code layout in get_recursion_context()

In an XDP redirect applications using tracepoint xdp:xdp_redirect to
diagnose TX overrun, I noticed perf_swevent_get_recursion_context()
was consuming 2% CPU. This was reduced to 1.85% with this simple
change.

Looking at the annotated asm code, it was clear that the unlikely case
in_nmi() test was chosen (by the compiler) as the most likely
event/branch.  This small adjustment makes the compiler (GCC version
7.1.1 20170622 (Red Hat 7.1.1-3)) put in_nmi() as an unlikely branch.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/150342256382.16595.986861478681783732.stgit@firesoul
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/internal.h