Skip to contentSkip to conversation

perf record: Fix to honor user freq/interval properly

PATCH In review Namhyung Kim 4 participants 4 messages Jun 9, 2014 – Jun 13, 2014 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf record: Fix to honor user freq/interval properly

When configuring event perf checked a wrong condition that user specified both of freq (-F) and period (-c) or the event has no default value. This worked because most of events don't have default value and only tracepoint events have default of 1 (and it's not desirable to change it for those events).

However, Andi's downloadable event patch changes the situation so it cannot change the value for those events. Fix it by allowing override the default value if user gives one of the options.

  $ perf record -a -e uops_retired.all -F 4000 sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.325 MB perf.data (~14185 samples) ]
  $ perf evlist -F
  cpu/uops_retired.all/: sample_freq=4000
Cc Andi Kleen <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/evsel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +2 -2
index 5c28d82b76c4..5ff811c67adc 100644
@@ -589,10 +589,10 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	}
 
 	/*
-	 * We default some events to a 1 default interval. But keep
+	 * We default some events to have a default interval. But keep
 	 * it a weak assumption overridable by the user.
 	 */
-	if (!attr->sample_period || (opts->user_freq != UINT_MAX &&
+	if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
 				     opts->user_interval != ULLONG_MAX)) {
 		if (opts->freq) {
 			perf_evsel__set_sample_bit(evsel, PERIOD);
Signature · 1 line
2.0.0
Acked-by on v1 1/1
#1 lore raw
Quoted 29 lines · Namhyung Kim

When configuring event perf checked a wrong condition that user specified both of freq (-F) and period (-c) or the event has no default value. This worked because most of events don't have default value and only tracepoint events have default of 1 (and it's not desirable to change it for those events).

However, Andi's downloadable event patch changes the situation so it cannot change the value for those events. Fix it by allowing override the default value if user gives one of the options.

  $ perf record -a -e uops_retired.all -F 4000 sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.325 MB perf.data (~14185 samples) ]
  $ perf evlist -F
  cpu/uops_retired.all/: sample_freq=4000
Cc Andi Kleen <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/evsel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +0 -0
index 5c28d82b76c4..5ff811c67adc 100644

tools/perf/util/evsel.c void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) · line 596

Quoted 10 lines
tools/perf/util/evsel.c +2 -2
@@ -589,10 +589,10 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	}
 
 	/*
-	 * We default some events to a 1 default interval. But keep
+	 * We default some events to have a default interval. But keep
 	 * it a weak assumption overridable by the user.
 	 */
-	if (!attr->sample_period || (opts->user_freq != UINT_MAX &&
+	if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
 				     opts->user_interval != ULLONG_MAX)) {

seems ok to me, maybe we could fixup brackets in that condition so it does not seems like there's some hidden message ;-)

thanks,
jirka

#2 lore raw
In reply to Namhyung Kim
Quoted 9 lines · Namhyung Kim

When configuring event perf checked a wrong condition that user specified both of freq (-F) and period (-c) or the event has no default value. This worked because most of events don't have default value and only tracepoint events have default of 1 (and it's not desirable to change it for those events).

However, Andi's downloadable event patch changes the situation so it cannot change the value for those events. Fix it by allowing override the default value if user gives one of the options.

Thanks. Looks good. I'll drop my version.

-Andi

#3 lore raw

[tip:perf/core] perf record: Fix to honor user freq/ interval properly

In reply to Namhyung Kim
perf record: Fix to honor user freq/interval properly
Commit-ID:  17314e2385c6627fcab4b8f97bd6668bb63495c0
Gitweb:     http://git.kernel.org/tip/17314e2385c6627fcab4b8f97bd6668bb63495c0
Author:     Namhyung Kim <[email protected]>
AuthorDate: Mon, 9 Jun 2014 14:43:37 +0900
Committer:  Jiri Olsa <[email protected]>
CommitDate: Thu, 12 Jun 2014 16:53:18 +0200

perf record: Fix to honor user freq/interval properly

When configuring event perf checked a wrong condition that user specified both of freq (-F) and period (-c) or the event has no default value. This worked because most of events don't have default value and only tracepoint events have default of 1 (and it's not desirable to change it for those events).

However, Andi's downloadable event patch changes the situation so it cannot change the value for those events. Fix it by allowing override the default value if user gives one of the options.

  $ perf record -a -e uops_retired.all -F 4000 sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.325 MB perf.data (~14185 samples) ]
  $ perf evlist -F
  cpu/uops_retired.all/: sample_freq=4000
---
 tools/perf/util/evsel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +2 -2
index 21154da..8606175 100644
@@ -589,10 +589,10 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 	}
 
 	/*
-	 * We default some events to a 1 default interval. But keep
+	 * We default some events to have a default interval. But keep
 	 * it a weak assumption overridable by the user.
 	 */
-	if (!attr->sample_period || (opts->user_freq != UINT_MAX &&
+	if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
 				     opts->user_interval != ULLONG_MAX)) {
 		if (opts->freq) {
 			perf_evsel__set_sample_bit(evsel, PERIOD);