public inbox for linux-kernel@vger.kernel.org
 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 5/6] tracing/branch-profiling: add variable to disable branch profiling
Date: Thu, 04 Jun 2009 01:25:45 -0400	[thread overview]
Message-ID: <20090604052613.706062044@goodmis.org> (raw)
In-Reply-To: 20090604052540.528802957@goodmis.org

[-- Attachment #1: 0005-tracing-branch-profiling-add-variable-to-disable-bra.patch --]
[-- Type: text/plain, Size: 2602 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

Currently, the branch profiler is either always enabled, or always
disabled. This patch adds a sysctl (/proc/sys/kernel/branch_profiling_enabled)
to be able to enable/disable the branch profiler.

This should help on cache line bouncing when not enabled.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/kernel.h      |    4 +++-
 kernel/sysctl.c             |   10 ++++++++++
 kernel/trace/trace_branch.c |    9 +++++++++
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f96a481..9372a87 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -77,13 +77,15 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 #define unlikely(x)	(__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))
 
 #ifdef CONFIG_PROFILE_ALL_BRANCHES
+extern int sysctl_branch_profiling_enabled;
 /*
  * "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) :			\
+	if ((!sysctl_branch_profiling_enabled ||			\
+	     __builtin_constant_p((cond))) ? !!(cond) :			\
 	({								\
 		int ______r;						\
 		static struct ftrace_branch_data			\
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b2970d5..2628aa7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -912,6 +912,16 @@ static struct ctl_table kern_table[] = {
 		.child		= slow_work_sysctls,
 	},
 #endif
+#ifdef CONFIG_PROFILE_ALL_BRANCHES
+	{
+		.ctl_name       = CTL_UNNUMBERED,
+		.procname       = "branch_profiling_enabled",
+		.data           = &sysctl_branch_profiling_enabled,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = &proc_dointvec,
+	},
+#endif
 /*
  * NOTE: do not add new entries to this table unless you have read
  * Documentation/sysctl/ctl_unnumbered.txt
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 19c618f..e4f1465 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -334,6 +334,15 @@ fs_initcall(init_annotated_branch_stats);
 
 #ifdef CONFIG_PROFILE_ALL_BRANCHES
 
+int sysctl_branch_profiling_enabled __read_mostly;
+
+static int __init set_enable_branch_profiler(char *str)
+{
+	sysctl_branch_profiling_enabled = 1;
+	return 1;
+}
+__setup("enable_branch_profiler", set_enable_branch_profiler);
+
 extern unsigned long __start_branch_profile[];
 extern unsigned long __stop_branch_profile[];
 
-- 
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 ` [PATCH 4/6] tracing/branch-profiler: move macro defines to kernel.h Steven Rostedt
2009-06-04  5:25 ` Steven Rostedt [this message]
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.706062044@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