Skip to contentSkip to conversation

perf record: Set PERF_RECORD_SAMPLE if attr->freq is set.

PATCH Superseded Ian Rogers 2 participants 2 messages Jul 27, 2020 – Jul 28, 2020

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf record: Set PERF_RECORD_SAMPLE if attr->freq is set.

From: David Sharp <[email protected]>

evsel__config() would only set PERF_RECORD_SAMPLE if it set attr->freq from perf record options. When it is set by libpfm events, it would not get set. This changes evsel__config to see if attr->freq is set outside of whether or not it changes attr->freq itself.

---
 tools/perf/util/evsel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +6 -1
index ef802f6d40c1..811f538f7d77 100644
@@ -979,13 +979,18 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
 	if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
 				     opts->user_interval != ULLONG_MAX)) {
 		if (opts->freq) {
-			evsel__set_sample_bit(evsel, PERIOD);
 			attr->freq		= 1;
 			attr->sample_freq	= opts->freq;
 		} else {
 			attr->sample_period = opts->default_interval;
 		}
 	}
+	/*
+	 * If attr->freq was set (here or earlier), ask for period
+	 * to be sampled.
+	 */
+	if (attr->freq)
+		evsel__set_sample_bit(evsel, PERIOD);
 
 	if (opts->no_samples)
 		attr->sample_freq = 0;
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog
#1 lore raw
Quoted 7 lines · Ian Rogers

From: David Sharp <[email protected]>

evsel__config() would only set PERF_RECORD_SAMPLE if it set attr->freq

Hi Ian,

Commit message says PERF_RECORD_SAMPLE. But since we are setting period here, it has to say “PERF_SAMPLE_PERIOD” ?

Thanks
Athira

Quoted 39 lines

from perf record options. When it is set by libpfm events, it would not get set. This changes evsel__config to see if attr->freq is set outside of whether or not it changes attr->freq itself.

---
tools/perf/util/evsel.c | 7 ++++++-

1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +6 -1
index ef802f6d40c1..811f538f7d77 100644
@@ -979,13 +979,18 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
 	if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
 				     opts->user_interval != ULLONG_MAX)) {
 		if (opts->freq) {
-			evsel__set_sample_bit(evsel, PERIOD);
 			attr->freq		= 1;
 			attr->sample_freq	= opts->freq;
 		} else {
 			attr->sample_period = opts->default_interval;
 		}
 	}
+	/*
+	 * If attr->freq was set (here or earlier), ask for period
+	 * to be sampled.
+	 */
+	if (attr->freq)
+		evsel__set_sample_bit(evsel, PERIOD);
 
 	if (opts->no_samples)
 		attr->sample_freq = 0;
Signature · 1 line
2.28.0.rc0.142.g3c755180ce-goog