linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH] trace: adjust code layout in get_recursion_context
Date: Wed, 23 Aug 2017 10:12:19 +0200	[thread overview]
Message-ID: <20170823081219.27tdvloc3h35l5w7@gmail.com> (raw)
In-Reply-To: <20170822175512.GJ32112@worktop.programming.kicks-ass.net>


* 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

      reply	other threads:[~2017-08-23  8:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 14:40 [PATCH] trace: adjust code layout in get_recursion_context Jesper Dangaard Brouer
2017-08-22 15:14 ` Peter Zijlstra
2017-08-22 15:20   ` Peter Zijlstra
2017-08-22 17:00     ` Jesper Dangaard Brouer
2017-08-22 17:10       ` Jesper Dangaard Brouer
2017-08-22 17:22         ` [PATCH V2] " Jesper Dangaard Brouer
2017-08-25 11:54           ` [tip:perf/core] tracing, perf: Adjust code layout in get_recursion_context() tip-bot for Jesper Dangaard Brouer
2017-08-22 17:55       ` [PATCH] trace: adjust code layout in get_recursion_context Peter Zijlstra
2017-08-23  8:12         ` Ingo Molnar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170823081219.27tdvloc3h35l5w7@gmail.com \
    --to=mingo@kernel.org \
    --cc=acme@kernel.org \
    --cc=brouer@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).