trace-cmd library: Do not write CPU count section in trace files version 7
Writing CPU count as a separate section in the trace file is redundant,
as there is already an option for that. Use that option in trace files
version 7.
Link: https://lore.kernel.org/linux-trace-devel/20220119082507.245600-9-tz.stoyanov@gmail.com
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index 8a8d4e5..c075ab6 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -1482,10 +1482,16 @@
handle->file_state);
return -1;
}
- cpus = convert_endian_4(handle, cpus);
- ret = do_write_check(handle, &cpus, 4);
- if (ret < 0)
- return ret;
+
+ if (!HAS_SECTIONS(handle)) {
+ cpus = convert_endian_4(handle, cpus);
+ ret = do_write_check(handle, &cpus, 4);
+ if (ret < 0)
+ return ret;
+ } else {
+ tracecmd_add_option(handle, TRACECMD_OPTION_CPUCOUNT, sizeof(int), &cpus);
+ }
+
handle->file_state = TRACECMD_FILE_CPU_COUNT;
return 0;
}