aboutsummaryrefslogtreecommitdiff
path: root/idlestat.c
diff options
context:
space:
mode:
authorTuukka Tikkanen <tuukka.tikkanen@linaro.org>2015-01-21 00:44:32 +0200
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2015-01-21 00:44:32 +0200
commit6efac9bed0ec6b7a2e9abc8872e03245d4918f06 (patch)
tree37455aa61d15feed236f2db5e7e12b25c0981de5 /idlestat.c
parent7d3394ec671ee1f4a80080dcdaac31ed2247a24d (diff)
Idlestat: Add command line options for managing trace buffer
As the kernel trace buffer is a finite resource, the default trace buffer size idlestat sets may either be impossibly large or insufficient to hold the data. This patch adds two new command line options to control buffer size and whether or not it will be polled during the trace period. The polling functionality while tracing is not yet implemented. Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
Diffstat (limited to 'idlestat.c')
-rw-r--r--idlestat.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/idlestat.c b/idlestat.c
index 68b47f5..1c1e8ac 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -1000,6 +1000,8 @@ int getoptions(int argc, char *argv[], struct program_options *options)
{ "wakeup", no_argument, NULL, 'w' },
{ "boxless-report", no_argument, NULL, 'B' },
{ "csv-report", no_argument, NULL, 'C' },
+ { "poll-interval", required_argument, NULL, 'I' },
+ { "buffer-size", required_argument, NULL, 'S' },
{ "version", no_argument, NULL, 'V' },
{ 0, 0, 0, 0 }
};
@@ -1014,7 +1016,7 @@ int getoptions(int argc, char *argv[], struct program_options *options)
int optindex = 0;
- c = getopt_long(argc, argv, ":b:ce:f:ho:pr:t:vwBCV",
+ c = getopt_long(argc, argv, ":b:ce:f:ho:pr:t:vwBCI:S:V",
long_options, &optindex);
if (c == -1)
break;
@@ -1079,6 +1081,12 @@ int getoptions(int argc, char *argv[], struct program_options *options)
fprintf(stderr, "-B: report type already set to %s\n",
options->report_type_name);
return -1;
+ case 'I':
+ options->tbs.poll_interval = atoi(optarg);
+ break;
+ case 'S':
+ options->tbs.percpu_buffer_size = atoi(optarg);
+ break;
case 0: /* getopt_long() set a variable, just keep going */
break;
case ':': /* missing option argument */
@@ -1374,11 +1382,22 @@ int main(int argc, char *argv[], char *const envp[])
if (is_err(saved_trace_options))
return 1;
+ /*
+ * Calculate/verify buffer size and polling trace data
+ * interval. The interval or may may not be used to
+ * transfer data from kernel trace buffer to some
+ * storage media. It is needed for long eventful traces,
+ * but is not preferred. If the user does not specify
+ * the values, we will calculate reasonable defaults.
+ */
+ if (calculate_buffer_parameters(options.duration, &options.tbs))
+ return 1;
+
/* Initialize the traces for cpu_idle and increase the
- * buffer size to let 'idlestat' to sleep instead of
- * acquiring data, hence preventing it to pertubate the
+ * buffer size to let 'idlestat' to possibly sleep instead
+ * of acquiring data, hence preventing it to pertubate the
* measurements. */
- if (idlestat_init_trace(options.duration))
+ if (idlestat_init_trace(options.tbs.percpu_buffer_size))
goto err_restore_trace_options;
/* Remove all the previous traces */