Message ID | 20210914131232.3964615-16-tz.stoyanov@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | trace-cmd fixes and clean-ups | expand |
On Tue, 14 Sep 2021 16:12:26 +0300 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote: > This clean up is needed for the design of the next trace file version, > where only CPUs with trace data could be stored in the file. Each trace > instance may have its own CPU count, depending on collected traces. > As the main input handler is used by the top trace instance, the > CPU count there is for the top trace instance and may differ with cpu > counts of the other instances. Added a new "max_cpu" member of the input > handler, that tracks the maximum CPU count of all instances, recorded in > the file. > > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> > --- > lib/trace-cmd/trace-input.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c > index cb8b9f14..dc82d3ea 100644 > --- a/lib/trace-cmd/trace-input.c > +++ b/lib/trace-cmd/trace-input.c > @@ -125,6 +125,7 @@ struct tracecmd_input { > int long_size; > int page_size; > int page_map_size; > + int max_cpu; > int cpus; > int ref; > int nr_buffers; /* buffer instances */ > @@ -838,6 +839,7 @@ static int read_cpus(struct tracecmd_input *handle) > return -1; > > handle->cpus = cpus; > + handle->max_cpu = cpus; > tep_set_cpus(handle->pevent, handle->cpus); > handle->file_state = TRACECMD_FILE_CPU_COUNT; > > @@ -2794,6 +2796,8 @@ static int handle_options(struct tracecmd_input *handle) > case TRACECMD_OPTION_CPUCOUNT: > cpus = *(int *)buf; > handle->cpus = tep_read_number(handle->pevent, &cpus, 4); > + handle->max_cpu = handle->cpus; Shouldn't this be: if (handles->cpus > handle->max_cpu) handle->max_cpu = handle->cpus; ?? -- Steve > + tep_set_cpus(handle->pevent, handle->cpus); > break; > case TRACECMD_OPTION_PROCMAPS: > if (buf[size-1] == '\0') > @@ -4074,7 +4078,7 @@ int tracecmd_page_size(struct tracecmd_input *handle) > */ > int tracecmd_cpus(struct tracecmd_input *handle) > { > - return handle->cpus; > + return handle->max_cpu; > } > > /**
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index cb8b9f14..dc82d3ea 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -125,6 +125,7 @@ struct tracecmd_input { int long_size; int page_size; int page_map_size; + int max_cpu; int cpus; int ref; int nr_buffers; /* buffer instances */ @@ -838,6 +839,7 @@ static int read_cpus(struct tracecmd_input *handle) return -1; handle->cpus = cpus; + handle->max_cpu = cpus; tep_set_cpus(handle->pevent, handle->cpus); handle->file_state = TRACECMD_FILE_CPU_COUNT; @@ -2794,6 +2796,8 @@ static int handle_options(struct tracecmd_input *handle) case TRACECMD_OPTION_CPUCOUNT: cpus = *(int *)buf; handle->cpus = tep_read_number(handle->pevent, &cpus, 4); + handle->max_cpu = handle->cpus; + tep_set_cpus(handle->pevent, handle->cpus); break; case TRACECMD_OPTION_PROCMAPS: if (buf[size-1] == '\0') @@ -4074,7 +4078,7 @@ int tracecmd_page_size(struct tracecmd_input *handle) */ int tracecmd_cpus(struct tracecmd_input *handle) { - return handle->cpus; + return handle->max_cpu; } /**
This clean up is needed for the design of the next trace file version, where only CPUs with trace data could be stored in the file. Each trace instance may have its own CPU count, depending on collected traces. As the main input handler is used by the top trace instance, the CPU count there is for the top trace instance and may differ with cpu counts of the other instances. Added a new "max_cpu" member of the input handler, that tracks the maximum CPU count of all instances, recorded in the file. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/trace-input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)