public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jesper Dangaard Brouer <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: peterz@infradead.org, jolsa@kernel.org, brouer@redhat.com,
	tglx@linutronix.de, linux-kernel@vger.kernel.org,
	mingo@kernel.org, acme@kernel.org, torvalds@linux-foundation.org,
	hpa@zytor.com
Subject: [tip:perf/core] tracing, perf: Adjust code layout in get_recursion_context()
Date: Fri, 25 Aug 2017 04:54:18 -0700	[thread overview]
Message-ID: <tip-d0618410eced4eb092295fad10312a4545fcdfaf@git.kernel.org> (raw)
In-Reply-To: <150342256382.16595.986861478681783732.stgit@firesoul>

Commit-ID:  d0618410eced4eb092295fad10312a4545fcdfaf
Gitweb:     http://git.kernel.org/tip/d0618410eced4eb092295fad10312a4545fcdfaf
Author:     Jesper Dangaard Brouer <brouer@redhat.com>
AuthorDate: Tue, 22 Aug 2017 19:22:43 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 25 Aug 2017 11:04:18 +0200

tracing, perf: Adjust code layout in get_recursion_context()

In an XDP redirect applications using tracepoint xdp:xdp_redirect to
diagnose TX overrun, I noticed perf_swevent_get_recursion_context()
was consuming 2% CPU. This was reduced to 1.85% with this simple
change.

Looking at the annotated asm code, it was clear that the unlikely case
in_nmi() test was chosen (by the compiler) as the most likely
event/branch.  This small adjustment makes the compiler (GCC version
7.1.1 20170622 (Red Hat 7.1.1-3)) put in_nmi() as an unlikely branch.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/150342256382.16595.986861478681783732.stgit@firesoul
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/events/internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index 5377c59..843e970 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -208,7 +208,7 @@ static inline int get_recursion_context(int *recursion)
 {
 	int rctx;
 
-	if (in_nmi())
+	if (unlikely(in_nmi()))
 		rctx = 3;
 	else if (in_irq())
 		rctx = 2;

  reply	other threads:[~2017-08-25 11:57 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-bot for Jesper Dangaard Brouer [this message]
2017-08-22 17:55       ` [PATCH] " Peter Zijlstra
2017-08-23  8:12         ` Ingo Molnar

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=tip-d0618410eced4eb092295fad10312a4545fcdfaf@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@kernel.org \
    --cc=brouer@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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