Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf stat: Rename to aggr_cpu_id.thread_idx

The aggr_cpu_id has a thread value but it's actually an index to the
thread_map. To reduce possible confusion, rename it to thread_idx.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20220930202110.845199-8-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
fa2edc07 01b8957b

+16 -16
+5 -5
tools/perf/tests/topology.c
··· 147 147 TEST_ASSERT_VAL("Cpu map - Die ID doesn't match", 148 148 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].die_id == id.die); 149 149 TEST_ASSERT_VAL("Cpu map - Node ID is set", id.node == -1); 150 - TEST_ASSERT_VAL("Cpu map - Thread is set", id.thread == -1); 150 + TEST_ASSERT_VAL("Cpu map - Thread IDX is set", id.thread_idx == -1); 151 151 } 152 152 153 153 // Test that core ID contains socket, die and core ··· 163 163 TEST_ASSERT_VAL("Core map - Die ID doesn't match", 164 164 session->header.env.cpu[perf_cpu_map__cpu(map, i).cpu].die_id == id.die); 165 165 TEST_ASSERT_VAL("Core map - Node ID is set", id.node == -1); 166 - TEST_ASSERT_VAL("Core map - Thread is set", id.thread == -1); 166 + TEST_ASSERT_VAL("Core map - Thread IDX is set", id.thread_idx == -1); 167 167 } 168 168 169 169 // Test that die ID contains socket and die ··· 179 179 TEST_ASSERT_VAL("Die map - Node ID is set", id.node == -1); 180 180 TEST_ASSERT_VAL("Die map - Core is set", id.core == -1); 181 181 TEST_ASSERT_VAL("Die map - CPU is set", id.cpu.cpu == -1); 182 - TEST_ASSERT_VAL("Die map - Thread is set", id.thread == -1); 182 + TEST_ASSERT_VAL("Die map - Thread IDX is set", id.thread_idx == -1); 183 183 } 184 184 185 185 // Test that socket ID contains only socket ··· 193 193 TEST_ASSERT_VAL("Socket map - Die ID is set", id.die == -1); 194 194 TEST_ASSERT_VAL("Socket map - Core is set", id.core == -1); 195 195 TEST_ASSERT_VAL("Socket map - CPU is set", id.cpu.cpu == -1); 196 - TEST_ASSERT_VAL("Socket map - Thread is set", id.thread == -1); 196 + TEST_ASSERT_VAL("Socket map - Thread IDX is set", id.thread_idx == -1); 197 197 } 198 198 199 199 // Test that node ID contains only node ··· 205 205 TEST_ASSERT_VAL("Node map - Die ID is set", id.die == -1); 206 206 TEST_ASSERT_VAL("Node map - Core is set", id.core == -1); 207 207 TEST_ASSERT_VAL("Node map - CPU is set", id.cpu.cpu == -1); 208 - TEST_ASSERT_VAL("Node map - Thread is set", id.thread == -1); 208 + TEST_ASSERT_VAL("Node map - Thread IDX is set", id.thread_idx == -1); 209 209 } 210 210 perf_session__delete(session); 211 211
+4 -4
tools/perf/util/cpumap.c
··· 229 229 else if (a->core != b->core) 230 230 return a->core - b->core; 231 231 else 232 - return a->thread - b->thread; 232 + return a->thread_idx - b->thread_idx; 233 233 } 234 234 235 235 struct cpu_aggr_map *cpu_aggr_map__new(const struct perf_cpu_map *cpus, ··· 667 667 668 668 bool aggr_cpu_id__equal(const struct aggr_cpu_id *a, const struct aggr_cpu_id *b) 669 669 { 670 - return a->thread == b->thread && 670 + return a->thread_idx == b->thread_idx && 671 671 a->node == b->node && 672 672 a->socket == b->socket && 673 673 a->die == b->die && ··· 677 677 678 678 bool aggr_cpu_id__is_empty(const struct aggr_cpu_id *a) 679 679 { 680 - return a->thread == -1 && 680 + return a->thread_idx == -1 && 681 681 a->node == -1 && 682 682 a->socket == -1 && 683 683 a->die == -1 && ··· 688 688 struct aggr_cpu_id aggr_cpu_id__empty(void) 689 689 { 690 690 struct aggr_cpu_id ret = { 691 - .thread = -1, 691 + .thread_idx = -1, 692 692 .node = -1, 693 693 .socket = -1, 694 694 .die = -1,
+1 -1
tools/perf/util/cpumap.h
··· 10 10 /** Identify where counts are aggregated, -1 implies not to aggregate. */ 11 11 struct aggr_cpu_id { 12 12 /** A value in the range 0 to number of threads. */ 13 - int thread; 13 + int thread_idx; 14 14 /** The numa node X as read from /sys/devices/system/node/nodeX. */ 15 15 int node; 16 16 /**
+6 -6
tools/perf/util/stat-display.c
··· 189 189 case AGGR_THREAD: 190 190 if (config->json_output) { 191 191 fprintf(config->output, "\"thread\" : \"%s-%d\", ", 192 - perf_thread_map__comm(evsel->core.threads, id.thread), 193 - perf_thread_map__pid(evsel->core.threads, id.thread)); 192 + perf_thread_map__comm(evsel->core.threads, id.thread_idx), 193 + perf_thread_map__pid(evsel->core.threads, id.thread_idx)); 194 194 } else { 195 195 fprintf(config->output, "%*s-%*d%s", 196 196 config->csv_output ? 0 : 16, 197 - perf_thread_map__comm(evsel->core.threads, id.thread), 197 + perf_thread_map__comm(evsel->core.threads, id.thread_idx), 198 198 config->csv_output ? 0 : -8, 199 - perf_thread_map__pid(evsel->core.threads, id.thread), 199 + perf_thread_map__pid(evsel->core.threads, id.thread_idx), 200 200 config->csv_sep); 201 201 } 202 202 break; ··· 453 453 return perf_cpu_map__idx(cpus, id->cpu); 454 454 455 455 if (config->aggr_mode == AGGR_THREAD) 456 - return id->thread; 456 + return id->thread_idx; 457 457 458 458 if (!config->aggr_get_id) 459 459 return 0; ··· 946 946 947 947 buf[i].counter = counter; 948 948 buf[i].id = aggr_cpu_id__empty(); 949 - buf[i].id.thread = thread; 949 + buf[i].id.thread_idx = thread; 950 950 buf[i].uval = uval; 951 951 buf[i].val = val; 952 952 buf[i].run = run;