Commit faba877b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'perf-tools-fixes-v5.11-2-2021-01-22' of...

Merge tag 'perf-tools-fixes-v5.11-2-2021-01-22' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull more perf tools fixes from Arnaldo Carvalho de Melo:

 - Fix id index used in Intel PT for heterogeneous systems

 - Fix overrun issue in 'perf script' for dynamically-allocated PMU type
   number

 - Fix 'perf stat' metrics containing the 'duration_time' synthetic
   event

 - Fix system PMU 'perf stat' metrics

* tag 'perf-tools-fixes-v5.11-2-2021-01-22' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
  perf script: Fix overrun issue for dynamically-allocated PMU type number
  perf metricgroup: Fix system PMU metrics
  perf metricgroup: Fix for metrics containing duration_time
  perf evlist: Fix id index for heterogeneous systems
parents 1c304c77 8adc0a06
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -367,21 +367,13 @@ static struct perf_mmap* perf_evlist__alloc_mmap(struct perf_evlist *evlist, boo
	return map;
}

static void perf_evlist__set_sid_idx(struct perf_evlist *evlist,
				     struct perf_evsel *evsel, int idx, int cpu,
				     int thread)
static void perf_evsel__set_sid_idx(struct perf_evsel *evsel, int idx, int cpu, int thread)
{
	struct perf_sample_id *sid = SID(evsel, cpu, thread);

	sid->idx = idx;
	if (evlist->cpus && cpu >= 0)
		sid->cpu = evlist->cpus->map[cpu];
	else
		sid->cpu = -1;
	if (!evsel->system_wide && evlist->threads && thread >= 0)
		sid->tid = perf_thread_map__pid(evlist->threads, thread);
	else
		sid->tid = -1;
	sid->cpu = perf_cpu_map__cpu(evsel->cpus, cpu);
	sid->tid = perf_thread_map__pid(evsel->threads, thread);
}

static struct perf_mmap*
@@ -500,8 +492,7 @@ mmap_per_evsel(struct perf_evlist *evlist, struct perf_evlist_mmap_ops *ops,
			if (perf_evlist__id_add_fd(evlist, evsel, cpu, thread,
						   fd) < 0)
				return -1;
			perf_evlist__set_sid_idx(evlist, evsel, idx, cpu,
						 thread);
			perf_evsel__set_sid_idx(evsel, idx, cpu, thread);
		}
	}

+17 −1
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ struct output_option {

enum {
	OUTPUT_TYPE_SYNTH = PERF_TYPE_MAX,
	OUTPUT_TYPE_OTHER,
	OUTPUT_TYPE_MAX
};

@@ -283,6 +284,18 @@ static struct {

		.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
	},

	[OUTPUT_TYPE_OTHER] = {
		.user_set = false,

		.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
			      PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
			      PERF_OUTPUT_EVNAME | PERF_OUTPUT_IP |
			      PERF_OUTPUT_SYM | PERF_OUTPUT_SYMOFFSET |
			      PERF_OUTPUT_DSO | PERF_OUTPUT_PERIOD,

		.invalid_fields = PERF_OUTPUT_TRACE | PERF_OUTPUT_BPF_OUTPUT,
	},
};

struct evsel_script {
@@ -343,8 +356,11 @@ static inline int output_type(unsigned int type)
	case PERF_TYPE_SYNTH:
		return OUTPUT_TYPE_SYNTH;
	default:
		if (type < PERF_TYPE_MAX)
			return type;
	}

	return OUTPUT_TYPE_OTHER;
}

static inline unsigned int attr_type(unsigned int type)
+11 −5
Original line number Diff line number Diff line
@@ -162,6 +162,14 @@ static bool contains_event(struct evsel **metric_events, int num_events,
	return false;
}

static bool evsel_same_pmu(struct evsel *ev1, struct evsel *ev2)
{
	if (!ev1->pmu_name || !ev2->pmu_name)
		return false;

	return !strcmp(ev1->pmu_name, ev2->pmu_name);
}

/**
 * Find a group of events in perf_evlist that correspond to those from a parsed
 * metric expression. Note, as find_evsel_group is called in the same order as
@@ -280,8 +288,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
			 */
			if (!has_constraint &&
			    ev->leader != metric_events[i]->leader &&
			    !strcmp(ev->leader->pmu_name,
				    metric_events[i]->leader->pmu_name))
			    evsel_same_pmu(ev->leader, metric_events[i]->leader))
				break;
			if (!strcmp(metric_events[i]->name, ev->name)) {
				set_bit(ev->idx, evlist_used);
@@ -766,7 +773,6 @@ int __weak arch_get_runtimeparam(struct pmu_event *pe __maybe_unused)
struct metricgroup_add_iter_data {
	struct list_head *metric_list;
	const char *metric;
	struct metric **m;
	struct expr_ids *ids;
	int *ret;
	bool *has_match;
@@ -1058,12 +1064,13 @@ static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe,
						  void *data)
{
	struct metricgroup_add_iter_data *d = data;
	struct metric *m = NULL;
	int ret;

	if (!match_pe_metric(pe, d->metric))
		return 0;

	ret = add_metric(d->metric_list, pe, d->metric_no_group, d->m, NULL, d->ids);
	ret = add_metric(d->metric_list, pe, d->metric_no_group, &m, NULL, d->ids);
	if (ret)
		return ret;

@@ -1114,7 +1121,6 @@ static int metricgroup__add_metric(const char *metric, bool metric_no_group,
				.metric_list = &list,
				.metric = metric,
				.metric_no_group = metric_no_group,
				.m = &m,
				.ids = &ids,
				.has_match = &has_match,
				.ret = &ret,