mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 20:54:10 +08:00
perf: Optimize get_recursion_context()
"Look ma, no branches!" Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Link: https://lkml.kernel.org/r/20201030151955.187580298@infradead.org
This commit is contained in:
parent
ce0f17fc93
commit
09da9c8125
@ -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 += !!(pc & (NMI_MASK));
|
||||||
rctx = 3;
|
rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK));
|
||||||
else if (in_irq())
|
rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET));
|
||||||
rctx = 2;
|
|
||||||
else if (in_serving_softirq())
|
|
||||||
rctx = 1;
|
|
||||||
else
|
|
||||||
rctx = 0;
|
|
||||||
|
|
||||||
if (recursion[rctx])
|
if (recursion[rctx])
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user