@@ -126,6 +126,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 */
@@ -827,6 +828,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;
@@ -2779,6 +2781,9 @@ static int handle_options(struct tracecmd_input *handle)
case TRACECMD_OPTION_CPUCOUNT:
cpus = *(int *)buf;
handle->cpus = tep_read_number(handle->pevent, &cpus, 4);
+ if (handle->cpus > handle->max_cpu)
+ handle->max_cpu = handle->cpus;
+ tep_set_cpus(handle->pevent, handle->cpus);
break;
case TRACECMD_OPTION_PROCMAPS:
if (buf[size-1] == '\0')
@@ -4053,7 +4058,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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)