lkml.org 
[lkml]   [2013]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 17/19] perf ftrace: Add --clock option
Date
From: Namhyung Kim <namhyung.kim@lge.com>

The --clock (-c) option is for controlling trace_clock. Default to
'perf' if exists, or 'local'.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-ftrace.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 3b6bcc29715b..48dc54851765 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -35,6 +35,7 @@ struct perf_ftrace {
struct perf_target target;
const char *tracer;
const char *dirname;
+ const char *clock;
struct pevent *pevent;
bool show_full_info;
};
@@ -113,6 +114,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
if (reset_tracing_cpu() < 0)
return -1;

+ if (write_tracing_file("trace_clock", "local") < 0)
+ return -1;
+
return 0;
}

@@ -187,6 +191,24 @@ static int reset_tracing_cpu(void)
return 0;
}

+static int set_tracing_clock(struct perf_ftrace *ftrace)
+{
+ const char *clock = ftrace->clock;
+
+ if (clock == NULL)
+ clock = "perf";
+
+ if (!write_tracing_file("trace_clock", clock))
+ return 0;
+
+ /* exit if user specified an invalid clock */
+ if (ftrace->clock)
+ return -1;
+
+ pr_debug("'perf' clock is not supported.. falling back to 'local' clock\n");
+ return write_tracing_file("trace_clock", "local");
+}
+
static int setup_tracing_files(struct perf_ftrace *ftrace)
{
int ret = -1;
@@ -212,6 +234,11 @@ static int setup_tracing_files(struct perf_ftrace *ftrace)
goto out;
}

+ if (set_tracing_clock(ftrace) < 0) {
+ pr_err("failed to set trace clock\n");
+ goto out;
+ }
+
if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
goto out;
@@ -1445,6 +1472,8 @@ __cmd_ftrace_live(struct perf_ftrace *ftrace, int argc, const char **argv)
"system-wide collection from all CPUs"),
OPT_STRING('C', "cpu", &ftrace->target.cpu_list, "cpu",
"list of cpus to monitor"),
+ OPT_STRING('c', "clock", &ftrace->clock, "clock",
+ "clock to be used for tracer"),
OPT_END()
};

@@ -1487,6 +1516,8 @@ __cmd_ftrace_record(struct perf_ftrace *ftrace, int argc, const char **argv)
"list of cpus to monitor"),
OPT_STRING('o', "output", &ftrace->dirname, "dirname",
"input directory name to use (default: perf.data)"),
+ OPT_STRING('c', "clock", &ftrace->clock, "clock",
+ "clock to be used for tracer"),
OPT_END()
};

--
1.7.11.7


\
 
 \ /
  Last update: 2013-06-26 09:41    [W:1.476 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site