From a2fc047f34a527af7cc313a1f094ffa86e9cbc16 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Tue, 15 Dec 2009 19:07:16 -0500 Subject: trace-cmd: Add sleep_time between splice reads I found that tracing few events causes trace-cmd to almost spin in a busy loop since it can constantly read a page, and the process of reading that page causes it to run again. We end up just causing events to read. This adds a -s sleep time option that forces trace-cmd to sleep. The default is 1ms. But it can be disabled with 0. Signed-off-by: Steven Rostedt --- trace-cmd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'trace-cmd.c') diff --git a/trace-cmd.c b/trace-cmd.c index 0d53e8c..92008cd 100644 --- a/trace-cmd.c +++ b/trace-cmd.c @@ -51,7 +51,7 @@ unsigned int page_size; static const char *output_file = "trace.dat"; static int latency; - +static int sleep_time = 1000; static int cpu_count; static int *pids; @@ -568,7 +568,7 @@ static int create_recorder(int cpu) if (!recorder) die ("can't create recorder"); - tracecmd_start_recording(recorder); + tracecmd_start_recording(recorder, sleep_time); tracecmd_free_recorder(recorder); exit(0); @@ -631,12 +631,13 @@ void usage(char **argv) printf("\n" "%s version %s\n\n" "usage:\n" - " %s record [-e event][-p plugin] [-d] [-o file] [-O option ] [command ...]\n" + " %s record [-e event][-p plugin][-d][-o file][-s usecs][-O option ] [command ...]\n" " -e run command with event enabled\n" " -p run command with plugin enabled\n" " -d disable function tracer when running\n" " -o data output file [default trace.dat]\n" " -O option to enable (or disable)\n" + " -s sleep interval between recording (in usecs) [default: 1000]\n" "\n" " %s start [-e event][-p plugin] [-d] [-O option ]\n" " Uses same options as record, but does not run a command.\n" @@ -726,6 +727,9 @@ int main (int argc, char **argv) option = optarg; set_option(option); break; + case 's': + sleep_time = atoi(optarg); + break; } } -- cgit v1.2.2