diff options
| author | Ingo Molnar <mingo@kernel.org> | 2024-03-25 13:32:29 +0300 | 
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2024-03-25 13:32:29 +0300 | 
| commit | f4566a1e73957800df75a3dd2dccee8a4697f327 (patch) | |
| tree | b043b875228c0b25988af66c680d60cae69d761d /tools/perf/util/stat-shadow.c | |
| parent | b9e6e28663928cab836a19abbdec3d036a07db3b (diff) | |
| parent | 4cece764965020c22cff7665b18a012006359095 (diff) | |
| download | linux-f4566a1e73957800df75a3dd2dccee8a4697f327.tar.xz | |
Merge tag 'v6.9-rc1' into sched/core, to pick up fixes and to refresh the branch
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/stat-shadow.c')
| -rw-r--r-- | tools/perf/util/stat-shadow.c | 72 | 
1 files changed, 44 insertions, 28 deletions
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index e31426167852..3466aa952442 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -355,11 +355,13 @@ static void print_nsecs(struct perf_stat_config *config,  		print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0);  } -static int prepare_metric(struct evsel **metric_events, -			  struct metric_ref *metric_refs, +static int prepare_metric(const struct metric_expr *mexp, +			  const struct evsel *evsel,  			  struct expr_parse_ctx *pctx,  			  int aggr_idx)  { +	struct evsel * const *metric_events = mexp->metric_events; +	struct metric_ref *metric_refs = mexp->metric_refs;  	int i;  	for (i = 0; metric_events[i]; i++) { @@ -398,12 +400,33 @@ static int prepare_metric(struct evsel **metric_events,  			source_count = 1;  		} else {  			struct perf_stat_evsel *ps = metric_events[i]->stats; -			struct perf_stat_aggr *aggr = &ps->aggr[aggr_idx]; +			struct perf_stat_aggr *aggr; +			/* +			 * If there are multiple uncore PMUs and we're not +			 * reading the leader's stats, determine the stats for +			 * the appropriate uncore PMU. +			 */ +			if (evsel && evsel->metric_leader && +			    evsel->pmu != evsel->metric_leader->pmu && +			    mexp->metric_events[i]->pmu == evsel->metric_leader->pmu) { +				struct evsel *pos; + +				evlist__for_each_entry(evsel->evlist, pos) { +					if (pos->pmu != evsel->pmu) +						continue; +					if (pos->metric_leader != mexp->metric_events[i]) +						continue; +					ps = pos->stats; +					source_count = 1; +					break; +				} +			} +			aggr = &ps->aggr[aggr_idx];  			if (!aggr)  				break; -                        if (!metric_events[i]->supported) { +			if (!metric_events[i]->supported) {  				/*  				 * Not supported events will have a count of 0,  				 * which can be confusing in a @@ -414,13 +437,9 @@ static int prepare_metric(struct evsel **metric_events,  				val = NAN;  				source_count = 0;  			} else { -				/* -				 * If an event was scaled during stat gathering, -				 * reverse the scale before computing the -				 * metric. -				 */ -				val = aggr->counts.val * (1.0 / metric_events[i]->scale); -				source_count = evsel__source_count(metric_events[i]); +				val = aggr->counts.val; +				if (!source_count) +					source_count = evsel__source_count(metric_events[i]);  			}  		}  		n = strdup(evsel__metric_id(metric_events[i])); @@ -441,18 +460,18 @@ static int prepare_metric(struct evsel **metric_events,  }  static void generic_metric(struct perf_stat_config *config, -			   const char *metric_expr, -			   const char *metric_threshold, -			   struct evsel **metric_events, -			   struct metric_ref *metric_refs, -			   char *name, -			   const char *metric_name, -			   const char *metric_unit, -			   int runtime, +			   struct metric_expr *mexp, +			   struct evsel *evsel,  			   int aggr_idx,  			   struct perf_stat_output_ctx *out)  {  	print_metric_t print_metric = out->print_metric; +	const char *metric_name = mexp->metric_name; +	const char *metric_expr = mexp->metric_expr; +	const char *metric_threshold = mexp->metric_threshold; +	const char *metric_unit = mexp->metric_unit; +	struct evsel * const *metric_events = mexp->metric_events; +	int runtime = mexp->runtime;  	struct expr_parse_ctx *pctx;  	double ratio, scale, threshold;  	int i; @@ -467,7 +486,7 @@ static void generic_metric(struct perf_stat_config *config,  		pctx->sctx.user_requested_cpu_list = strdup(config->user_requested_cpu_list);  	pctx->sctx.runtime = runtime;  	pctx->sctx.system_wide = config->system_wide; -	i = prepare_metric(metric_events, metric_refs, pctx, aggr_idx); +	i = prepare_metric(mexp, evsel, pctx, aggr_idx);  	if (i < 0) {  		expr__ctx_free(pctx);  		return; @@ -502,18 +521,18 @@ static void generic_metric(struct perf_stat_config *config,  				print_metric(config, ctxp, color, "%8.2f",  					metric_name ?  					metric_name : -					out->force_header ?  name : "", +					out->force_header ?  evsel->name : "",  					ratio);  			}  		} else {  			print_metric(config, ctxp, color, /*unit=*/NULL,  				     out->force_header ? -				     (metric_name ? metric_name : name) : "", 0); +				     (metric_name ?: evsel->name) : "", 0);  		}  	} else {  		print_metric(config, ctxp, color, /*unit=*/NULL,  			     out->force_header ? -			     (metric_name ? metric_name : name) : "", 0); +			     (metric_name ?: evsel->name) : "", 0);  	}  	expr__ctx_free(pctx); @@ -528,7 +547,7 @@ double test_generic_metric(struct metric_expr *mexp, int aggr_idx)  	if (!pctx)  		return NAN; -	if (prepare_metric(mexp->metric_events, mexp->metric_refs, pctx, aggr_idx) < 0) +	if (prepare_metric(mexp, /*evsel=*/NULL, pctx, aggr_idx) < 0)  		goto out;  	if (expr__parse(&ratio, pctx, mexp->metric_expr)) @@ -630,10 +649,7 @@ void *perf_stat__print_shadow_stats_metricgroup(struct perf_stat_config *config,  		if ((*num)++ > 0)  			out->new_line(config, ctxp); -		generic_metric(config, mexp->metric_expr, mexp->metric_threshold, -			       mexp->metric_events, mexp->metric_refs, evsel->name, -			       mexp->metric_name, mexp->metric_unit, mexp->runtime, -			       aggr_idx, out); +		generic_metric(config, mexp, evsel, aggr_idx, out);  	}  	return NULL;  | 
