linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 38/83] perf record: Fix -c/-F options for cpu event aliases
Date: Fri, 17 Nov 2017 17:15:16 -0300	[thread overview]
Message-ID: <20171117201601.24110-39-acme@kernel.org> (raw)
In-Reply-To: <20171117201601.24110-1-acme@kernel.org>

From: Andi Kleen <ak@linux.intel.com>

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

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20171020202755.21410-2-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f894893c203d..bfde6a7a80f2 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -733,12 +733,16 @@ static void apply_config_terms(struct perf_evsel *evsel,
 	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)
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 9277df96ffda..157f49e8a772 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -67,6 +67,7 @@ struct perf_evsel_config_term {
 		bool	overwrite;
 		char	*branch;
 	} val;
+	bool weak;
 };
 
 struct perf_stat_evsel;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index a7fcd95961ef..170316795a18 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1116,6 +1116,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)
 
@@ -2410,6 +2411,7 @@ static int new_term(struct parse_events_term **_term,
 
 	*term = *temp;
 	INIT_LIST_HEAD(&term->list);
+	term->weak = false;
 
 	switch (term->type_val) {
 	case PARSE_EVENTS__TERM_TYPE_NUM:
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index be337c266697..88108cd11b4c 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -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 {
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 07cb2ac041d7..80fb1593913a 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -405,6 +405,11 @@ static int pmu_alias_terms(struct perf_pmu_alias *alias,
 			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);
-- 
2.13.6

  parent reply	other threads:[~2017-11-17 20:18 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 20:14 [GIT PULL 00/83] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 01/83] perf evlist: Set the correct idx when adding dummy events Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 02/83] perf record: Generate PERF_RECORD_{MMAP,COMM,EXEC} with --delay Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 03/83] perf annotate: Add annotation_line struct Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 04/83] perf annotate: Move line/offset into " Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 05/83] perf annotate: Move ipc/cycles " Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 06/83] perf annotate: Add symbol__annotate function Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 07/83] perf annotate: Add struct annotate_args Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 08/83] perf annotate: Add arch into " Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 09/83] perf annotate: Add map " Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 10/83] perf annotate: Add offset/line/line_nr " Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 11/83] perf annotate: Add evsel into struct annotation_line_args Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 12/83] perf annotate: Add annotation_line__next function Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 13/83] perf annotate: Add annotation_line__add function Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 14/83] perf annotate: Move rb_node to struct annotation_line Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 15/83] perf annotate: Add annotation_line__(new|delete) functions Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 16/83] perf annotate: Add annotated_source__purge function Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 17/83] perf annotate: Add samples into struct annotation_line Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 18/83] perf annotate: Add symbol__calc_percent function Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 19/83] perf annotate: Add symbol__calc_lines function Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 20/83] perf annotate: Remove disasm__calc_percent() from disasm_line__print() Arnaldo Carvalho de Melo
2017-11-17 20:14 ` [PATCH 21/83] perf annotate: Remove disasm__calc_percent() from annotate_browser__calc_percent() Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 22/83] perf annotate: Remove disasm__calc_percent function Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 23/83] perf annotate: Remove struct source_line Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 24/83] perf annotate: Add annotation_line__print function Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 25/83] perf annotate: Factor annotation_line__print from disasm_line__print Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 26/83] perf annotate browser: Use samples data from struct annotation_line Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 27/83] perf annotate browser: Do not pass nr_events in disasm_rb_tree__insert Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 28/83] perf annotate browser: Rename struct browser_disasm_line to browser_line Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 29/83] perf annotate browser: Rename disasm_line__browser " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 30/83] perf annotate browser: Change selection to struct annotation_line Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 31/83] perf annotate browser: Change offsets " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 32/83] perf annotate browser: Use struct annotation_line in browser_line Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 33/83] perf annotate browser: Use struct annotation_line in find functions Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 34/83] perf annotate browser: Use struct annotation_line in browser top Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 35/83] perf annotate browser: Add disasm_line__write function Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 36/83] perf annotate: Align source and offset lines Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 37/83] tools headers: Synchronize kernel ABI headers wrt SPDX tags Arnaldo Carvalho de Melo
2017-11-17 20:15 ` Arnaldo Carvalho de Melo [this message]
2017-11-17 20:15 ` [PATCH 39/83] perf evsel: Enable type checking for perf_evsel_config_term types Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 40/83] perf trace: Fix an exit code of trace__symbols_init Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 41/83] perf tools: Use shell function for perl cflags retrieval Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 42/83] perf evsel: Fix up leftover perf_evsel_stat usage via evsel->priv Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 43/83] perf tests: Add missing WRITE_ASS for new fields of perf_event_attr Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 44/83] perf script: Fix --per-event-dump for auxtrace synth evsels Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 45/83] perf vendor events powerpc: Update POWER9 events Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 46/83] perf buildid-cache: Update help text for purge command Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 47/83] perf tools: Document some missing perf.data headers Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 48/83] perf script: Allow printing period for non freq mode groups Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 49/83] perf top: Document missing options Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 50/83] perf top: Remove a duplicate word Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 51/83] perf tests: Set evlist of test__backward_ring_buffer() to !overwrite Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 52/83] perf tests: Set evlist of test__sw_clock_freq() " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 53/83] perf tests: Set evlist of test__basic_mmap() " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 54/83] perf tests: Set evlist of test__task_exit() " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 55/83] perf machine: Guard against NULL in machine__exit() Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 56/83] perf help: Fix a bug during strstart() conversion Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 57/83] perf annotate: Do not truncate instruction names at 6 chars Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 58/83] perf test shell: Fix check open filename arg using 'perf trace' on s390x Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 59/83] perf test shell: Fix test case probe libc's inet_pton " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 60/83] perf evlist: Add helper to check if attr.exclude_kernel is set in all evsels Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 61/83] perf report: Ignore kptr_restrict when not sampling the kernel Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 62/83] perf record: " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 63/83] perf top: " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 64/83] perf c2c: Fix spelling mistakes in browser help text Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 65/83] perf evsel: Say which PMU Hardware event doesn't support sampling/overflow-interrupts Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 66/83] perf lock: Document missing options Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 67/83] perf: Fix header.size for namespace events Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 68/83] perf inject: Document missing options Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 69/83] perf trace: Document missing option, colons Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 70/83] perf timechart: Document missing --force option Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 71/83] perf sched: " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 72/83] perf evlist: " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 73/83] perf buildid-cache: " Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 74/83] perf callchain: Reset cursor arg instead of callchain_cursor Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 75/83] perf evsel: Centralize perf_sample initialization Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 76/83] perf evlist: Add perf_evlist__parse_sample_timestamp function Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 77/83] perf ordered_events: Pass timestamp arg in perf_session__queue_event Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 78/83] perf tools: Optimize sample parsing for ordered events Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 79/83] perf top: Fix window dimensions change handling Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 80/83] perf top: Use signal interface for SIGWINCH handler Arnaldo Carvalho de Melo
2017-11-17 20:15 ` [PATCH 81/83] perf top: Fix crash when annotating symbol Arnaldo Carvalho de Melo
2017-11-17 20:16 ` [PATCH 82/83] perf tools: Change (symbol|annotation)__calc_percent return type to void Arnaldo Carvalho de Melo
2017-11-17 20:16 ` [PATCH 83/83] perf tools: Move symbol__calc_percent() call to outside symbol__disassemble() Arnaldo Carvalho de Melo
2017-11-18  8:06 ` [GIT PULL 00/83] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171117201601.24110-39-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).