[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170823081219.27tdvloc3h35l5w7@gmail.com>
Date: Wed, 23 Aug 2017 10:12:19 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Jesper Dangaard Brouer <brouer@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...nel.org>
Subject: Re: [PATCH] trace: adjust code layout in get_recursion_context
* Peter Zijlstra <peterz@...radead.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
Powered by blists - more mailing lists