diff mbox series

[v5,12/25] trace-cmd library: Do not write CPUs with empty trace data

Message ID 20211111151112.86751-3-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series Trace file version 7 - sections | expand

Commit Message

Tzvetomir Stoyanov (VMware) Nov. 11, 2021, 3:11 p.m. UTC
Trace file version 7 has more flexible design, which allows to write only
CPUs with trace data in the file. If a CPU has no recorded trace data,
do not put it in the trace file version 7.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/trace-output.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Steven Rostedt Nov. 24, 2021, 7:30 p.m. UTC | #1
On Thu, 11 Nov 2021 17:11:05 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> Trace file version 7 has more flexible design, which allows to write only
> CPUs with trace data in the file. If a CPU has no recorded trace data,
> do not put it in the trace file version 7.
> 

Will both trace-cmd record and report still report that a CPU had no data?
Because that is useful information.

-- Steve


> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  lib/trace-cmd/trace-output.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
> index 028ad580..2ed7155b 100644
> --- a/lib/trace-cmd/trace-output.c
> +++ b/lib/trace-cmd/trace-output.c
> @@ -2079,8 +2079,10 @@ int tracecmd_write_cpu_data(struct tracecmd_output *handle,
>  
>  	if (i < cpus)
>  		ret = -1;
> -	else
> +	else if (size || !HAS_SECTIONS(handle))
>  		ret = out_write_cpu_data(handle, cpus, data, buff_name);
> +	else
> +		ret = 0;
>  
>  	for (i--; i >= 0; i--)
>  		close(data[i].fd);
Steven Rostedt Nov. 24, 2021, 7:32 p.m. UTC | #2
On Wed, 24 Nov 2021 14:30:00 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> Will both trace-cmd record and report still report that a CPU had no data?
> Because that is useful information.

That is, we must differentiate between when a CPU was being recorded but
produced no information, and when the user used a CPU mask to record.

If CPU 1 has no data, it should report it did in both the record and the
report commands of trace-cmd, unless, the user had masked out CPU 1, where
it was not part of the record.

That information needs to be saved somewhere. If the user did mask out
CPUs, that could be saved in an option. And then when a CPU does not have
data, if it was masked out, nothing is to be reported, otherwise it is. We
also have to know how many CPUs were recorded, such that if he last CPU
doesn't have data, we report that if it was recorded.

-- Steve
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index 028ad580..2ed7155b 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -2079,8 +2079,10 @@  int tracecmd_write_cpu_data(struct tracecmd_output *handle,
 
 	if (i < cpus)
 		ret = -1;
-	else
+	else if (size || !HAS_SECTIONS(handle))
 		ret = out_write_cpu_data(handle, cpus, data, buff_name);
+	else
+		ret = 0;
 
 	for (i--; i >= 0; i--)
 		close(data[i].fd);