@@ -171,7 +171,7 @@ struct opt_aggr_mode {
171171};
172172
173173/* Turn command line option into most generic aggregation mode setting. */
174- static enum aggr_mode opt_aggr_mode_to_aggr_mode (struct opt_aggr_mode * opt_mode )
174+ static enum aggr_mode opt_aggr_mode_to_aggr_mode (const struct opt_aggr_mode * opt_mode )
175175{
176176 enum aggr_mode mode = AGGR_GLOBAL ;
177177
@@ -1154,8 +1154,8 @@ static int parse_cache_level(const struct option *opt,
11541154 int unset __maybe_unused )
11551155{
11561156 int level ;
1157- struct opt_aggr_mode * opt_aggr_mode = ( struct opt_aggr_mode * ) opt -> value ;
1158- u32 * aggr_level = ( u32 * ) opt -> data ;
1157+ bool * per_cache = opt -> value ;
1158+ u32 * aggr_level = opt -> data ;
11591159
11601160 /*
11611161 * If no string is specified, aggregate based on the topology of
@@ -1193,7 +1193,7 @@ static int parse_cache_level(const struct option *opt,
11931193 return - EINVAL ;
11941194 }
11951195out :
1196- opt_aggr_mode -> cache = true;
1196+ * per_cache = true;
11971197 * aggr_level = level ;
11981198 return 0 ;
11991199}
@@ -2316,31 +2316,34 @@ static struct perf_stat perf_stat = {
23162316static int __cmd_report (int argc , const char * * argv )
23172317{
23182318 struct perf_session * session ;
2319+ struct opt_aggr_mode opt_mode = {};
23192320 const struct option options [] = {
23202321 OPT_STRING ('i' , "input" , & input_name , "file" , "input file name" ),
2321- OPT_SET_UINT (0 , "per-socket" , & perf_stat .aggr_mode ,
2322- "aggregate counts per processor socket" , AGGR_SOCKET ),
2323- OPT_SET_UINT (0 , "per-die" , & perf_stat .aggr_mode ,
2324- "aggregate counts per processor die" , AGGR_DIE ),
2325- OPT_SET_UINT (0 , "per-cluster" , & perf_stat .aggr_mode ,
2326- "aggregate counts perf processor cluster" , AGGR_CLUSTER ),
2327- OPT_CALLBACK_OPTARG (0 , "per-cache" , & perf_stat .aggr_mode , & perf_stat .aggr_level ,
2328- "cache level" ,
2329- "aggregate count at this cache level (Default: LLC)" ,
2322+ OPT_BOOLEAN (0 , "per-thread" , & opt_mode .thread , "aggregate counts per thread" ),
2323+ OPT_BOOLEAN (0 , "per-socket" , & opt_mode .socket ,
2324+ "aggregate counts per processor socket" ),
2325+ OPT_BOOLEAN (0 , "per-die" , & opt_mode .die , "aggregate counts per processor die" ),
2326+ OPT_BOOLEAN (0 , "per-cluster" , & opt_mode .cluster ,
2327+ "aggregate counts per processor cluster" ),
2328+ OPT_CALLBACK_OPTARG (0 , "per-cache" , & opt_mode .cache , & perf_stat .aggr_level ,
2329+ "cache level" , "aggregate count at this cache level (Default: LLC)" ,
23302330 parse_cache_level ),
2331- OPT_SET_UINT (0 , "per-core" , & perf_stat .aggr_mode ,
2332- "aggregate counts per physical processor core" , AGGR_CORE ),
2333- OPT_SET_UINT (0 , "per-node" , & perf_stat .aggr_mode ,
2334- "aggregate counts per numa node" , AGGR_NODE ),
2335- OPT_SET_UINT ('A' , "no-aggr" , & perf_stat .aggr_mode ,
2336- "disable CPU count aggregation" , AGGR_NONE ),
2331+ OPT_BOOLEAN (0 , "per-core" , & opt_mode .core ,
2332+ "aggregate counts per physical processor core" ),
2333+ OPT_BOOLEAN (0 , "per-node" , & opt_mode .node , "aggregate counts per numa node" ),
2334+ OPT_BOOLEAN ('A' , "no-aggr" , & opt_mode .no_aggr ,
2335+ "disable aggregation across CPUs or PMUs" ),
23372336 OPT_END ()
23382337 };
23392338 struct stat st ;
23402339 int ret ;
23412340
23422341 argc = parse_options (argc , argv , options , stat_report_usage , 0 );
23432342
2343+ perf_stat .aggr_mode = opt_aggr_mode_to_aggr_mode (& opt_mode );
2344+ if (perf_stat .aggr_mode == AGGR_GLOBAL )
2345+ perf_stat .aggr_mode = AGGR_UNSET ; /* No option found so leave unset. */
2346+
23442347 if (!input_name || !strlen (input_name )) {
23452348 if (!fstat (STDIN_FILENO , & st ) && S_ISFIFO (st .st_mode ))
23462349 input_name = "-" ;
@@ -2490,7 +2493,7 @@ int cmd_stat(int argc, const char **argv)
24902493 OPT_BOOLEAN (0 , "per-die" , & opt_mode .die , "aggregate counts per processor die" ),
24912494 OPT_BOOLEAN (0 , "per-cluster" , & opt_mode .cluster ,
24922495 "aggregate counts per processor cluster" ),
2493- OPT_CALLBACK_OPTARG (0 , "per-cache" , & opt_mode , & stat_config .aggr_level ,
2496+ OPT_CALLBACK_OPTARG (0 , "per-cache" , & opt_mode . cache , & stat_config .aggr_level ,
24942497 "cache level" , "aggregate count at this cache level (Default: LLC)" ,
24952498 parse_cache_level ),
24962499 OPT_BOOLEAN (0 , "per-core" , & opt_mode .core ,
0 commit comments