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

Configure Feed

Select the types of activity you want to include in your feed.

perf stat: Fix opt->value type for parse_cache_level

Commit f5803651b4a4 ("perf stat: Choose the most disaggregate command
line option") changed aggregation option handling for `perf stat` but
not `perf stat report` leading to parse_cache_level being passed a
struct in the `perf stat` case but erroneously an aggr_mode enum value
for `perf stat report`. Change the `perf stat report` aggregation
handling to use the same opt_aggr_mode as `perf stat`. Also, just pass
the boolean for consistency with other boolean argument handling.

Fixes: f5803651b4a4 ("perf stat: Choose the most disaggregate command line option")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
44311ae8 cfaade34

+23 -20
+23 -20
tools/perf/builtin-stat.c
··· 164 164 }; 165 165 166 166 /* Turn command line option into most generic aggregation mode setting. */ 167 - static enum aggr_mode opt_aggr_mode_to_aggr_mode(struct opt_aggr_mode *opt_mode) 167 + static enum aggr_mode opt_aggr_mode_to_aggr_mode(const struct opt_aggr_mode *opt_mode) 168 168 { 169 169 enum aggr_mode mode = AGGR_GLOBAL; 170 170 ··· 1219 1219 int unset __maybe_unused) 1220 1220 { 1221 1221 int level; 1222 - struct opt_aggr_mode *opt_aggr_mode = (struct opt_aggr_mode *)opt->value; 1223 - u32 *aggr_level = (u32 *)opt->data; 1222 + bool *per_cache = opt->value; 1223 + u32 *aggr_level = opt->data; 1224 1224 1225 1225 /* 1226 1226 * If no string is specified, aggregate based on the topology of ··· 1258 1258 return -EINVAL; 1259 1259 } 1260 1260 out: 1261 - opt_aggr_mode->cache = true; 1261 + *per_cache = true; 1262 1262 *aggr_level = level; 1263 1263 return 0; 1264 1264 } ··· 2305 2305 static int __cmd_report(int argc, const char **argv) 2306 2306 { 2307 2307 struct perf_session *session; 2308 + struct opt_aggr_mode opt_mode = {}; 2308 2309 const struct option options[] = { 2309 2310 OPT_STRING('i', "input", &input_name, "file", "input file name"), 2310 - OPT_SET_UINT(0, "per-socket", &perf_stat.aggr_mode, 2311 - "aggregate counts per processor socket", AGGR_SOCKET), 2312 - OPT_SET_UINT(0, "per-die", &perf_stat.aggr_mode, 2313 - "aggregate counts per processor die", AGGR_DIE), 2314 - OPT_SET_UINT(0, "per-cluster", &perf_stat.aggr_mode, 2315 - "aggregate counts perf processor cluster", AGGR_CLUSTER), 2316 - OPT_CALLBACK_OPTARG(0, "per-cache", &perf_stat.aggr_mode, &perf_stat.aggr_level, 2317 - "cache level", 2318 - "aggregate count at this cache level (Default: LLC)", 2311 + OPT_BOOLEAN(0, "per-thread", &opt_mode.thread, "aggregate counts per thread"), 2312 + OPT_BOOLEAN(0, "per-socket", &opt_mode.socket, 2313 + "aggregate counts per processor socket"), 2314 + OPT_BOOLEAN(0, "per-die", &opt_mode.die, "aggregate counts per processor die"), 2315 + OPT_BOOLEAN(0, "per-cluster", &opt_mode.cluster, 2316 + "aggregate counts per processor cluster"), 2317 + OPT_CALLBACK_OPTARG(0, "per-cache", &opt_mode.cache, &perf_stat.aggr_level, 2318 + "cache level", "aggregate count at this cache level (Default: LLC)", 2319 2319 parse_cache_level), 2320 - OPT_SET_UINT(0, "per-core", &perf_stat.aggr_mode, 2321 - "aggregate counts per physical processor core", AGGR_CORE), 2322 - OPT_SET_UINT(0, "per-node", &perf_stat.aggr_mode, 2323 - "aggregate counts per numa node", AGGR_NODE), 2324 - OPT_SET_UINT('A', "no-aggr", &perf_stat.aggr_mode, 2325 - "disable CPU count aggregation", AGGR_NONE), 2320 + OPT_BOOLEAN(0, "per-core", &opt_mode.core, 2321 + "aggregate counts per physical processor core"), 2322 + OPT_BOOLEAN(0, "per-node", &opt_mode.node, "aggregate counts per numa node"), 2323 + OPT_BOOLEAN('A', "no-aggr", &opt_mode.no_aggr, 2324 + "disable aggregation across CPUs or PMUs"), 2326 2325 OPT_END() 2327 2326 }; 2328 2327 struct stat st; 2329 2328 int ret; 2330 2329 2331 2330 argc = parse_options(argc, argv, options, stat_report_usage, 0); 2331 + 2332 + perf_stat.aggr_mode = opt_aggr_mode_to_aggr_mode(&opt_mode); 2333 + if (perf_stat.aggr_mode == AGGR_GLOBAL) 2334 + perf_stat.aggr_mode = AGGR_UNSET; /* No option found so leave unset. */ 2332 2335 2333 2336 if (!input_name || !strlen(input_name)) { 2334 2337 if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode)) ··· 2509 2506 OPT_BOOLEAN(0, "per-die", &opt_mode.die, "aggregate counts per processor die"), 2510 2507 OPT_BOOLEAN(0, "per-cluster", &opt_mode.cluster, 2511 2508 "aggregate counts per processor cluster"), 2512 - OPT_CALLBACK_OPTARG(0, "per-cache", &opt_mode, &stat_config.aggr_level, 2509 + OPT_CALLBACK_OPTARG(0, "per-cache", &opt_mode.cache, &stat_config.aggr_level, 2513 2510 "cache level", "aggregate count at this cache level (Default: LLC)", 2514 2511 parse_cache_level), 2515 2512 OPT_BOOLEAN(0, "per-core", &opt_mode.core,