From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756493AbdHYL5z (ORCPT ); Fri, 25 Aug 2017 07:57:55 -0400 Received: from terminus.zytor.com ([65.50.211.136]:49237 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756476AbdHYL5w (ORCPT ); Fri, 25 Aug 2017 07:57:52 -0400 Date: Fri, 25 Aug 2017 04:54:18 -0700 From: tip-bot for Jesper Dangaard Brouer Message-ID: 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 Reply-To: linux-kernel@vger.kernel.org, peterz@infradead.org, jolsa@kernel.org, brouer@redhat.com, tglx@linutronix.de, acme@kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org In-Reply-To: <150342256382.16595.986861478681783732.stgit@firesoul> References: <150342256382.16595.986861478681783732.stgit@firesoul> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tracing, perf: Adjust code layout in get_recursion_context() Git-Commit-ID: d0618410eced4eb092295fad10312a4545fcdfaf X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d0618410eced4eb092295fad10312a4545fcdfaf Gitweb: http://git.kernel.org/tip/d0618410eced4eb092295fad10312a4545fcdfaf Author: Jesper Dangaard Brouer AuthorDate: Tue, 22 Aug 2017 19:22:43 +0200 Committer: Ingo Molnar 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/150342256382.16595.986861478681783732.stgit@firesoul Signed-off-by: Ingo Molnar --- 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;