Messages in this thread | | | Date | Wed, 23 Aug 2017 10:12:19 +0200 | From | Ingo Molnar <> | Subject | Re: [PATCH] trace: adjust code layout in get_recursion_context |
| |
* Peter Zijlstra <peterz@infradead.org> wrote:
> diff --git a/kernel/events/internal.h b/kernel/events/internal.h > index 486fd78eb8d5..981e4163e16c 100644 > --- a/kernel/events/internal.h > +++ b/kernel/events/internal.h > @@ -206,16 +206,15 @@ static inline unsigned long perf_aux_size(struct ring_buffer *rb) > > static inline int get_recursion_context(int *recursion) > { > - int rctx; > - > - if (in_nmi()) > - rctx = 3; > - else if (in_irq()) > - rctx = 2; > - else if (in_softirq()) > - rctx = 1; > - else > - rctx = 0; > + unsigned int pc = preempt_count(); > + int rctx = 0; > + > + if (pc & SOFTIRQ_OFFSET) > + rctx++; > + if (pc & HARDIRQ_MASK) > + rctx++; > + if (pc & NMI_MASK) > + rctx++;
Just a nit: if this ever gets beyond the proof of concent stage please rename 'pc' to something like 'count', because 'pc' stands for so many other things (program counter, etc.) which makes it all look a bit weird ...
Thanks,
Ingo
| |