Skip to content

Commit

Permalink
trace-cmd: Add split -C <cpu> to strip out a single cpu from file
Browse files Browse the repository at this point in the history
The -C option for trace-cmd split was always partially implemented, but
never fully. That is, you could pass in -C 1, but it did nothing and was
ignored. Now add that feature to actualy work.

Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
rostedt committed Apr 22, 2014
1 parent d205dec commit 52de056
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Documentation/trace-cmd-split.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ OPTIONS

This will create a file that has 10 pages per each CPU from the input.

*-C* 'cpu'::
This option will split for a single CPU. Only the cpu named will be extracted
from the file.

trace-cmd split -C 1

This will split out all the events for cpu 1 in the file.

SEE ALSO
--------
Expand Down
9 changes: 6 additions & 3 deletions trace-split.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int parse_cpu(struct tracecmd_input *handle,
static double parse_file(struct tracecmd_input *handle,
const char *output_file,
unsigned long long start,
unsigned long long end, int percpu,
unsigned long long end, int percpu, int only_cpu,
int count, enum split_types type)
{
unsigned long long current;
Expand Down Expand Up @@ -375,7 +375,10 @@ static double parse_file(struct tracecmd_input *handle,
tracecmd_set_cpu_to_timestamp(handle, cpu, start);
}

if (percpu) {
if (only_cpu >= 0) {
parse_cpu(handle, cpu_data, start, end, count,
1, only_cpu, type);
} else if (percpu) {
for (cpu = 0; cpu < cpus; cpu++)
parse_cpu(handle, cpu_data, start,
end, count, percpu, cpu, type);
Expand Down Expand Up @@ -534,7 +537,7 @@ void trace_split (int argc, char **argv)
strcpy(output_file, output);

current = parse_file(handle, output_file, start_ns, end_ns,
percpu, count, type);
percpu, cpu, count, type);
if (!repeat)
break;
start_ns = 0;
Expand Down

0 comments on commit 52de056

Please sign in to comment.