mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 4/6] tracing/branch-profiler: move macro defines to kernel.h
Date: Thu, 04 Jun 2009 01:25:44 -0400	[thread overview]
Message-ID: <20090604052613.424656440@goodmis.org> (raw)
In-Reply-To: <20090604052540.528802957@goodmis.org>

[-- Attachment #1: 0004-tracing-branch-profiler-move-macro-defines-to-kernel.patch --]
[-- Type: text/plain, Size: 5953 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

The branch profiler should not profile boot up code in the archs.
Moving it from compiler.h to kernel.h brings down its use.

This movement means we can also reference functions and variables
from the macros.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/compiler.h |   87 +--------------------------------------------
 include/linux/kernel.h   |   81 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 85 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index dd42294..24b35c6 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -55,91 +55,8 @@ extern void __chk_io_ptr(const volatile void __iomem *);
  * specific implementations come from the above header files
  */
 
-struct ftrace_branch_data {
-	const char *func;
-	const char *file;
-	unsigned line;
-	union {
-		struct {
-			unsigned long correct;
-			unsigned long incorrect;
-		};
-		struct {
-			unsigned long miss;
-			unsigned long hit;
-		};
-		unsigned long miss_hit[2];
-	};
-};
-
-/*
- * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code
- * to disable branch tracing on a per file basis.
- *  We currently do not profile modules.
- */
-#if defined(CONFIG_TRACE_BRANCH_PROFILING)				\
-	&& !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__)	\
-	&& !defined(MODULE)
-void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
-
-#define likely_notrace(x)	__builtin_expect(!!(x), 1)
-#define unlikely_notrace(x)	__builtin_expect(!!(x), 0)
-
-#define __branch_check__(x, expect) ({					\
-			int ______r;					\
-			static struct ftrace_branch_data		\
-				__attribute__((__aligned__(4)))		\
-				__attribute__((section("_ftrace_annotated_branch"))) \
-				______f = {				\
-				.func = __func__,			\
-				.file = __FILE__,			\
-				.line = __LINE__,			\
-			};						\
-			______r = likely_notrace(x);			\
-			ftrace_likely_update(&______f, ______r, expect); \
-			______r;					\
-		})
-
-/*
- * Using __builtin_constant_p(x) to ignore cases where the return
- * value is always the same.  This idea is taken from a similar patch
- * written by Daniel Walker.
- */
-# ifndef likely
-#  define likely(x)	(__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))
-# endif
-# ifndef unlikely
-#  define unlikely(x)	(__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))
-# endif
-
-#ifdef CONFIG_PROFILE_ALL_BRANCHES
-/*
- * "Define 'is'", Bill Clinton
- * "Define 'if'", Steven Rostedt
- */
-#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
-#define __trace_if(cond) \
-	if (__builtin_constant_p((cond)) ? !!(cond) :			\
-	({								\
-		int ______r;						\
-		static struct ftrace_branch_data			\
-			__attribute__((__aligned__(4)))			\
-			__attribute__((section("_ftrace_branch")))	\
-			______f = {					\
-				.func = __func__,			\
-				.file = __FILE__,			\
-				.line = __LINE__,			\
-			};						\
-		______r = !!(cond);					\
-		______f.miss_hit[______r]++;					\
-		______r;						\
-	}))
-#endif /* CONFIG_PROFILE_ALL_BRANCHES */
-
-#else
-# define likely(x)	__builtin_expect(!!(x), 1)
-# define unlikely(x)	__builtin_expect(!!(x), 0)
-#endif
+#define likely(x)	__builtin_expect(!!(x), 1)
+#define unlikely(x)	__builtin_expect(!!(x), 0)
 
 /* Optimization barrier */
 #ifndef barrier
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 883cd44..f96a481 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -20,6 +20,87 @@
 #include <asm/byteorder.h>
 #include <asm/bug.h>
 
+
+struct ftrace_branch_data {
+	const char *func;
+	const char *file;
+	unsigned line;
+	union {
+		struct {
+			unsigned long correct;
+			unsigned long incorrect;
+		};
+		struct {
+			unsigned long miss;
+			unsigned long hit;
+		};
+		unsigned long miss_hit[2];
+	};
+};
+
+/*
+ * Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code
+ * to disable branch tracing on a per file basis.
+ *  We currently do not profile modules.
+ */
+#if defined(CONFIG_TRACE_BRANCH_PROFILING)				\
+	&& !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__)	\
+	&& !defined(MODULE)
+void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
+
+#define likely_notrace(x)	__builtin_expect(!!(x), 1)
+#define unlikely_notrace(x)	__builtin_expect(!!(x), 0)
+
+#define __branch_check__(x, expect) ({					\
+			int ______r;					\
+			static struct ftrace_branch_data		\
+				__attribute__((__aligned__(4)))		\
+				__attribute__((section("_ftrace_annotated_branch"))) \
+				______f = {				\
+				.func = __func__,			\
+				.file = __FILE__,			\
+				.line = __LINE__,			\
+			};						\
+			______r = likely_notrace(x);			\
+			ftrace_likely_update(&______f, ______r, expect); \
+			______r;					\
+		})
+
+/*
+ * Using __builtin_constant_p(x) to ignore cases where the return
+ * value is always the same.  This idea is taken from a similar patch
+ * written by Daniel Walker.
+ */
+#undef likely
+#define likely(x)	(__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))
+#undef unlikely
+#define unlikely(x)	(__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))
+
+#ifdef CONFIG_PROFILE_ALL_BRANCHES
+/*
+ * "Define 'is'", Bill Clinton
+ * "Define 'if'", Steven Rostedt
+ */
+#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
+#define __trace_if(cond) \
+	if (__builtin_constant_p((cond)) ? !!(cond) :			\
+	({								\
+		int ______r;						\
+		static struct ftrace_branch_data			\
+			__attribute__((__aligned__(4)))			\
+			__attribute__((section("_ftrace_branch")))	\
+			______f = {					\
+				.func = __func__,			\
+				.file = __FILE__,			\
+				.line = __LINE__,			\
+			};						\
+		______r = !!(cond);					\
+		______f.miss_hit[______r]++;				\
+		______r;						\
+	}))
+#endif /* CONFIG_PROFILE_ALL_BRANCHES */
+#endif
+
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
-- 
1.6.3.1

-- 

  parent reply	other threads:[~2009-06-04  5:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-04  5:25 [PATCH 0/6] [GIT PULL] tracing/branch-profiler: per cpu and other things Steven Rostedt
2009-06-04  5:25 ` [PATCH 1/6] tracing/function-profiler: do not free per cpu variable stat Steven Rostedt
2009-06-04  5:25 ` [PATCH 2/6] tracing/branch-profiler: fix return value check on register_stat_tracer Steven Rostedt
2009-06-04  5:25 ` [PATCH 3/6] tracing/branch-profiler: do not profile managers Steven Rostedt
2009-06-04  5:25 ` Steven Rostedt [this message]
2009-06-04  5:25 ` [PATCH 5/6] tracing/branch-profiling: add variable to disable branch profiling Steven Rostedt
2009-06-04  5:25 ` [PATCH 6/6] tracing/branch-profiler: add option to profile branches per cpu Steven Rostedt
2009-06-06  7:31 ` [PATCH 0/6] [GIT PULL] tracing/branch-profiler: per cpu and other things Ingo Molnar
2009-06-06 14:37   ` [PATCH] tracing/branch-tracer: PROFILE_BRANCHES_PER_CPU must depend on SMP Frederic Weisbecker
2009-06-06 14:42     ` Steven Rostedt
2009-06-06 14:56       ` Frederic Weisbecker
2009-06-07 13:44     ` 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=20090604052613.424656440@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

Powered by JetHome