All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] jump_label: Do not profile branch annotations
@ 2020-12-11 21:37 Steven Rostedt
  2020-12-14  8:52 ` Peter Zijlstra
  2021-01-22 14:05 ` [tip: locking/core] " tip-bot2 for Steven Rostedt (VMware)
  0 siblings, 2 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-12-11 21:37 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Ingo Molnar, Jason Baron

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

While running my branch profiler that checks for incorrect "likely" and
"unlikely"s around the kernel, there's a large number of them that are
incorrect due to being "static_branches".

As static_branches are rather special, as they are likely or unlikely for
other reasons than normal annotations are used for, there's no reason to
have them be profiled.

Expose the "unlikely_notrace" and "likely_notrace" so that the
static_branch can use them, and have them be ignored by the branch
profilers.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index e512f5505dad..bbd141cf4b46 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -76,6 +76,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 #else
 # define likely(x)	__builtin_expect(!!(x), 1)
 # define unlikely(x)	__builtin_expect(!!(x), 0)
+# define likely_notrace(x)	likely(x)
+# define unlikely_notrace(x)	unlikely(x)
 #endif
 
 /* Optimization barrier */
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 32809624d422..d92691262f51 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -261,14 +261,14 @@ static __always_inline void jump_label_init(void)
 
 static __always_inline bool static_key_false(struct static_key *key)
 {
-	if (unlikely(static_key_count(key) > 0))
+	if (unlikely_notrace(static_key_count(key) > 0))
 		return true;
 	return false;
 }
 
 static __always_inline bool static_key_true(struct static_key *key)
 {
-	if (likely(static_key_count(key) > 0))
+	if (likely_notrace(static_key_count(key) > 0))
 		return true;
 	return false;
 }
@@ -460,7 +460,7 @@ extern bool ____wrong_branch_error(void);
 		branch = !arch_static_branch_jump(&(x)->key, true);		\
 	else									\
 		branch = ____wrong_branch_error();				\
-	likely(branch);								\
+	likely_notrace(branch);								\
 })
 
 #define static_branch_unlikely(x)						\
@@ -472,13 +472,13 @@ extern bool ____wrong_branch_error(void);
 		branch = arch_static_branch(&(x)->key, false);			\
 	else									\
 		branch = ____wrong_branch_error();				\
-	unlikely(branch);							\
+	unlikely_notrace(branch);							\
 })
 
 #else /* !CONFIG_JUMP_LABEL */
 
-#define static_branch_likely(x)		likely(static_key_enabled(&(x)->key))
-#define static_branch_unlikely(x)	unlikely(static_key_enabled(&(x)->key))
+#define static_branch_likely(x)		likely_notrace(static_key_enabled(&(x)->key))
+#define static_branch_unlikely(x)	unlikely_notrace(static_key_enabled(&(x)->key))
 
 #endif /* CONFIG_JUMP_LABEL */
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] jump_label: Do not profile branch annotations
  2020-12-11 21:37 [PATCH] jump_label: Do not profile branch annotations Steven Rostedt
@ 2020-12-14  8:52 ` Peter Zijlstra
  2020-12-14 15:33   ` Steven Rostedt
  2021-01-22 14:05 ` [tip: locking/core] " tip-bot2 for Steven Rostedt (VMware)
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2020-12-14  8:52 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Ingo Molnar, Jason Baron

On Fri, Dec 11, 2020 at 04:37:54PM -0500, Steven Rostedt wrote:
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> While running my branch profiler that checks for incorrect "likely" and
> "unlikely"s around the kernel, there's a large number of them that are
> incorrect due to being "static_branches".
> 
> As static_branches are rather special, as they are likely or unlikely for
> other reasons than normal annotations are used for, there's no reason to
> have them be profiled.
> 
> Expose the "unlikely_notrace" and "likely_notrace" so that the
> static_branch can use them, and have them be ignored by the branch
> profilers.

The less that abomination does the better ;-), I'll take it through tip
then?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] jump_label: Do not profile branch annotations
  2020-12-14  8:52 ` Peter Zijlstra
@ 2020-12-14 15:33   ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2020-12-14 15:33 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: LKML, Ingo Molnar, Jason Baron

On Mon, 14 Dec 2020 09:52:06 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> On Fri, Dec 11, 2020 at 04:37:54PM -0500, Steven Rostedt wrote:
> > From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > 
> > While running my branch profiler that checks for incorrect "likely" and
> > "unlikely"s around the kernel, there's a large number of them that are
> > incorrect due to being "static_branches".
> > 
> > As static_branches are rather special, as they are likely or unlikely for
> > other reasons than normal annotations are used for, there's no reason to
> > have them be profiled.
> > 
> > Expose the "unlikely_notrace" and "likely_notrace" so that the
> > static_branch can use them, and have them be ignored by the branch
> > profilers.  
> 
> The less that abomination does the better ;-), I'll take it through tip
> then?

Sure, go ahead.

Thanks.

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: locking/core] jump_label: Do not profile branch annotations
  2020-12-11 21:37 [PATCH] jump_label: Do not profile branch annotations Steven Rostedt
  2020-12-14  8:52 ` Peter Zijlstra
@ 2021-01-22 14:05 ` tip-bot2 for Steven Rostedt (VMware)
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Steven Rostedt (VMware) @ 2021-01-22 14:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Steven Rostedt (VMware), Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     2f0df49c89acaa58571d509830bc481250699885
Gitweb:        https://git.kernel.org/tip/2f0df49c89acaa58571d509830bc481250699885
Author:        Steven Rostedt (VMware) <rostedt@goodmis.org>
AuthorDate:    Fri, 11 Dec 2020 16:37:54 -05:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 22 Jan 2021 11:08:56 +01:00

jump_label: Do not profile branch annotations

While running my branch profiler that checks for incorrect "likely" and
"unlikely"s around the kernel, there's a large number of them that are
incorrect due to being "static_branches".

As static_branches are rather special, as they are likely or unlikely for
other reasons than normal annotations are used for, there's no reason to
have them be profiled.

Expose the "unlikely_notrace" and "likely_notrace" so that the
static_branch can use them, and have them be ignored by the branch
profilers.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20201211163754.585174b9@gandalf.local.home
---
 include/linux/compiler.h   |  2 ++
 include/linux/jump_label.h | 12 ++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index b8fe0c2..df5b405 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -76,6 +76,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 #else
 # define likely(x)	__builtin_expect(!!(x), 1)
 # define unlikely(x)	__builtin_expect(!!(x), 0)
+# define likely_notrace(x)	likely(x)
+# define unlikely_notrace(x)	unlikely(x)
 #endif
 
 /* Optimization barrier */
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 3280962..d926912 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -261,14 +261,14 @@ static __always_inline void jump_label_init(void)
 
 static __always_inline bool static_key_false(struct static_key *key)
 {
-	if (unlikely(static_key_count(key) > 0))
+	if (unlikely_notrace(static_key_count(key) > 0))
 		return true;
 	return false;
 }
 
 static __always_inline bool static_key_true(struct static_key *key)
 {
-	if (likely(static_key_count(key) > 0))
+	if (likely_notrace(static_key_count(key) > 0))
 		return true;
 	return false;
 }
@@ -460,7 +460,7 @@ extern bool ____wrong_branch_error(void);
 		branch = !arch_static_branch_jump(&(x)->key, true);		\
 	else									\
 		branch = ____wrong_branch_error();				\
-	likely(branch);								\
+	likely_notrace(branch);								\
 })
 
 #define static_branch_unlikely(x)						\
@@ -472,13 +472,13 @@ extern bool ____wrong_branch_error(void);
 		branch = arch_static_branch(&(x)->key, false);			\
 	else									\
 		branch = ____wrong_branch_error();				\
-	unlikely(branch);							\
+	unlikely_notrace(branch);							\
 })
 
 #else /* !CONFIG_JUMP_LABEL */
 
-#define static_branch_likely(x)		likely(static_key_enabled(&(x)->key))
-#define static_branch_unlikely(x)	unlikely(static_key_enabled(&(x)->key))
+#define static_branch_likely(x)		likely_notrace(static_key_enabled(&(x)->key))
+#define static_branch_unlikely(x)	unlikely_notrace(static_key_enabled(&(x)->key))
 
 #endif /* CONFIG_JUMP_LABEL */
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-22 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 21:37 [PATCH] jump_label: Do not profile branch annotations Steven Rostedt
2020-12-14  8:52 ` Peter Zijlstra
2020-12-14 15:33   ` Steven Rostedt
2021-01-22 14:05 ` [tip: locking/core] " tip-bot2 for Steven Rostedt (VMware)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.