Skip to contentSkip to conversation

Patch "perf record: Fix -c/-F options for cpu event aliases" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Feb 23, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

perf record: Fix -c/-F options for cpu event aliases

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
perf-record-fix-c-f-options-for-cpu-event-aliases.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Fri Feb 23 11:45:09 CET 2018

From: Andi Kleen <[email protected]>
Date: Fri, 20 Oct 2017 13:27:55 -0700
Subject: perf record: Fix -c/-F options for cpu event aliases

From: Andi Kleen <[email protected]>

[ Upstream commit 59622fd496a3175c7bf549046e091d81c303ecff ]

The Intel PMU event aliases have a implicit period= specifier to set the default period.

Unfortunately this breaks overriding these periods with -c or -F, because the alias terms look like they are user specified to the internal parser, and user specified event qualifiers override the command line options.

Track that they are coming from aliases by adding a "weak" state to the term. Any weak terms don't override command line options.

I only did it for -c/-F for now, I think that's the only case that's broken currently.

Before:

$ perf record -c 1000 -vv -e uops_issued.any
...
  { sample_period, sample_freq }   2000003

After:

$ perf record -c 1000 -vv -e uops_issued.any
...
  { sample_period, sample_freq }   1000
---
 tools/perf/util/evsel.c        |   12 ++++++++----
 tools/perf/util/evsel.h        |    1 +
 tools/perf/util/parse-events.c |    2 ++
 tools/perf/util/parse-events.h |    3 +++
 tools/perf/util/pmu.c          |    5 +++++
 5 files changed, 19 insertions(+), 4 deletions(-)
tools/perf/util/evsel.c +8 -4
@@ -733,12 +733,16 @@ static void apply_config_terms(struct pe
 	list_for_each_entry(term, config_terms, list) {
 		switch (term->type) {
 		case PERF_EVSEL__CONFIG_TERM_PERIOD:
-			attr->sample_period = term->val.period;
-			attr->freq = 0;
+			if (!(term->weak && opts->user_interval != ULLONG_MAX)) {
+				attr->sample_period = term->val.period;
+				attr->freq = 0;
+			}
 			break;
 		case PERF_EVSEL__CONFIG_TERM_FREQ:
-			attr->sample_freq = term->val.freq;
-			attr->freq = 1;
+			if (!(term->weak && opts->user_freq != UINT_MAX)) {
+				attr->sample_freq = term->val.freq;
+				attr->freq = 1;
+			}
 			break;
 		case PERF_EVSEL__CONFIG_TERM_TIME:
 			if (term->val.time)
tools/perf/util/evsel.h +1 -0
@@ -67,6 +67,7 @@ struct perf_evsel_config_term {
 		bool	overwrite;
 		char	*branch;
 	} val;
+	bool weak;
 };
 
 /** struct perf_evsel - event selector
tools/perf/util/parse-events.c +2 -0
@@ -1115,6 +1115,7 @@ do {								\
 	INIT_LIST_HEAD(&__t->list);				\
 	__t->type       = PERF_EVSEL__CONFIG_TERM_ ## __type;	\
 	__t->val.__name = __val;				\
+	__t->weak	= term->weak;				\
 	list_add_tail(&__t->list, head_terms);			\
 } while (0)
 
@@ -2395,6 +2396,7 @@ static int new_term(struct parse_events_
 
 	*term = *temp;
 	INIT_LIST_HEAD(&term->list);
+	term->weak = false;
 
 	switch (term->type_val) {
 	case PARSE_EVENTS__TERM_TYPE_NUM:
tools/perf/util/parse-events.h +3 -0
@@ -101,6 +101,9 @@ struct parse_events_term {
 	/* error string indexes for within parsed string */
 	int err_term;
 	int err_val;
+
+	/* Coming from implicit alias */
+	bool weak;
 };
 
 struct parse_events_error {
tools/perf/util/pmu.c +5 -0
@@ -404,6 +404,11 @@ static int pmu_alias_terms(struct perf_p
 			parse_events_terms__purge(&list);
 			return ret;
 		}
+		/*
+		 * Weak terms don't override command line options,
+		 * which we don't want for implicit terms in aliases.
+		 */
+		cloned->weak = true;
 		list_add_tail(&cloned->list, &list);
 	}
 	list_splice(&list, terms);

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/perf-record-fix-c-f-options-for-cpu-event-aliases.patch