linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf record: Set PERF_RECORD_SAMPLE if attr->freq is set.
@ 2020-07-27  6:59 Ian Rogers
  2020-07-28  3:07 ` Athira Rajeev
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2020-07-27  6:59 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Adrian Hunter, Andi Kleen, linux-kernel, netdev, bpf
  Cc: Stephane Eranian, David Sharp, Ian Rogers

From: David Sharp <dhsharp@google.com>

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.

Signed-off-by: David Sharp <dhsharp@google.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/evsel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ef802f6d40c1..811f538f7d77 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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;
-- 
2.28.0.rc0.142.g3c755180ce-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf record: Set PERF_RECORD_SAMPLE if attr->freq is set.
  2020-07-27  6:59 [PATCH] perf record: Set PERF_RECORD_SAMPLE if attr->freq is set Ian Rogers
@ 2020-07-28  3:07 ` Athira Rajeev
  0 siblings, 0 replies; 2+ messages in thread
From: Athira Rajeev @ 2020-07-28  3:07 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Adrian Hunter, Andi Kleen, linux-kernel, netdev, bpf,
	Stephane Eranian, David Sharp



> On 27-Jul-2020, at 12:29 PM, Ian Rogers <irogers@google.com> wrote:
> 
> From: David Sharp <dhsharp@google.com>
> 
> 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 

> 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.
> 
> Signed-off-by: David Sharp <dhsharp@google.com>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/evsel.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index ef802f6d40c1..811f538f7d77 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -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;
> -- 
> 2.28.0.rc0.142.g3c755180ce-goog
> 
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-28  3:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27  6:59 [PATCH] perf record: Set PERF_RECORD_SAMPLE if attr->freq is set Ian Rogers
2020-07-28  3:07 ` Athira Rajeev

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).