Commit 09da9c81 authored by Peter Zijlstra's avatar Peter Zijlstra

perf: Optimize get_recursion_context()

  "Look ma, no branches!"
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Link: https://lkml.kernel.org/r/20201030151955.187580298@infradead.org
parent ce0f17fc
...@@ -205,16 +205,12 @@ DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user) ...@@ -205,16 +205,12 @@ DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
static inline int get_recursion_context(int *recursion) static inline int get_recursion_context(int *recursion)
{ {
int rctx; unsigned int pc = preempt_count();
unsigned char rctx = 0;
if (unlikely(in_nmi()))
rctx = 3; rctx += !!(pc & (NMI_MASK));
else if (in_irq()) rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK));
rctx = 2; rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET));
else if (in_serving_softirq())
rctx = 1;
else
rctx = 0;
if (recursion[rctx]) if (recursion[rctx])
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment