All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [for-next][PATCH 17/18] tracing: Add trace_clock=<clock> kernel parameter
Date: Thu, 20 Feb 2014 21:49:23 -0500	[thread overview]
Message-ID: <20140221025003.592091532@goodmis.org> (raw)
In-Reply-To: 20140221024906.901631810@goodmis.org

[-- Attachment #1: 0017-tracing-Add-trace_clock-clock-kernel-parameter.patch --]
[-- Type: text/plain, Size: 3569 bytes --]

From: Steven Rostedt <rostedt@goodmis.org>

Being able to change the trace clock at boot can be advantageous if
you need a better source of when things happen across CPUs. The default
trace clock is the fastest, but it uses local clocks which may not be
synced across CPUs and it does not let you know when events took place
with respect to events on other CPUs.

The global trace clock can help in this case, and if you do not care
about timings, the counter "clock" is the best, as that is just a  simple
atomic counter that is incremented for every event.

Usage is to add "trace_clock=counter" on the kernel command line. You
can replace counter with "global" or any of the clocks listed in
/sys/kernel/debug/tracing/trace_clock

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Appreciated-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 61 ++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 45 insertions(+), 16 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d95ec28..c90f55d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -181,6 +181,17 @@ static int __init set_trace_boot_options(char *str)
 }
 __setup("trace_options=", set_trace_boot_options);
 
+static char trace_boot_clock_buf[MAX_TRACER_SIZE] __initdata;
+static char *trace_boot_clock __initdata;
+
+static int __init set_trace_boot_clock(char *str)
+{
+	strlcpy(trace_boot_clock_buf, str, MAX_TRACER_SIZE);
+	trace_boot_clock = trace_boot_clock_buf;
+	return 0;
+}
+__setup("trace_clock=", set_trace_boot_clock);
+
 
 unsigned long long ns2usecs(cycle_t nsec)
 {
@@ -4746,25 +4757,10 @@ static int tracing_clock_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
-				   size_t cnt, loff_t *fpos)
+static int tracing_set_clock(struct trace_array *tr, const char *clockstr)
 {
-	struct seq_file *m = filp->private_data;
-	struct trace_array *tr = m->private;
-	char buf[64];
-	const char *clockstr;
 	int i;
 
-	if (cnt >= sizeof(buf))
-		return -EINVAL;
-
-	if (copy_from_user(&buf, ubuf, cnt))
-		return -EFAULT;
-
-	buf[cnt] = 0;
-
-	clockstr = strstrip(buf);
-
 	for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) {
 		if (strcmp(trace_clocks[i].name, clockstr) == 0)
 			break;
@@ -4792,6 +4788,32 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
 
 	mutex_unlock(&trace_types_lock);
 
+	return 0;
+}
+
+static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
+				   size_t cnt, loff_t *fpos)
+{
+	struct seq_file *m = filp->private_data;
+	struct trace_array *tr = m->private;
+	char buf[64];
+	const char *clockstr;
+	int ret;
+
+	if (cnt >= sizeof(buf))
+		return -EINVAL;
+
+	if (copy_from_user(&buf, ubuf, cnt))
+		return -EFAULT;
+
+	buf[cnt] = 0;
+
+	clockstr = strstrip(buf);
+
+	ret = tracing_set_clock(tr, clockstr);
+	if (ret)
+		return ret;
+
 	*fpos += cnt;
 
 	return cnt;
@@ -6574,6 +6596,13 @@ __init static int tracer_alloc_buffers(void)
 
 	trace_init_cmdlines();
 
+	if (trace_boot_clock) {
+		ret = tracing_set_clock(&global_trace, trace_boot_clock);
+		if (ret < 0)
+			pr_warning("Trace clock %s not defined, going back to default\n",
+				   trace_boot_clock);
+	}
+
 	/*
 	 * register_tracer() might reference current_trace, so it
 	 * needs to be set before we register anything. This is
-- 
1.8.5.3



  parent reply	other threads:[~2014-02-21  2:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21  2:49 [for-next][PATCH 00/18] tracing: Function tracing in instances, uprobe triggers and more Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 01/18] tracing: Pass trace_array to set_flag callback Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 02/18] tracing: Pass trace_array to flag_changed callback Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 03/18] tracing: Set up infrastructure to allow tracers for instances Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 04/18] tracing: Only let top level have option files Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 05/18] ftrace: Add private data to ftrace_ops Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 06/18] ftrace: Copy ops private to global_ops private Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 07/18] tracing: Disable tracers before deletion of instance Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 08/18] tracing: Convert tracer->enabled to counter Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 09/18] ftrace: Allow instances to use function tracing Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 10/18] ftrace: Pass in global_ops for use with filtering files Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 11/18] ftrace: Allow for function tracing instance to filter functions Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 12/18] tracing/uprobes: Rename uprobe_{trace,perf}_print() functions Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 13/18] tracing/uprobes: Move argument fetching to uprobe_dispatcher() Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 14/18] tracing/uprobes: Support ftrace_event_file base multibuffer Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 15/18] tracing/uprobes: Support event triggering Steven Rostedt
2014-02-21  2:49 ` [for-next][PATCH 16/18] tracing/uprobes: Support mix of ftrace and perf Steven Rostedt
2014-02-21  2:49 ` Steven Rostedt [this message]
2014-02-21  2:49 ` [for-next][PATCH 18/18] ftrace: Have static function trace clear ENABLED flag on unregister Steven Rostedt

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=20140221025003.592091532@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    /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 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.