Netdev Archive on lore.kernel.org help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com> To: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@chromium.org>, Adrian Hunter <adrian.hunter@intel.com>, Andi Kleen <ak@linux.intel.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, LKML <linux-kernel@vger.kernel.org>, Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>, Stephane Eranian <eranian@google.com> Subject: Re: [PATCH v2 1/5] perf record: Set PERF_RECORD_PERIOD if attr->freq is set. Date: Thu, 3 Sep 2020 22:39:01 -0700 [thread overview] Message-ID: <CAP-5=fXbLtiX5Syji7X=-tV8r=PbbTw7X63h4PfggT-XvUemtQ@mail.gmail.com> (raw) In-Reply-To: <CAP-5=fUJW+UkL-jZkzkCKqTLh7DC0XnFx06kdfYiu2CK85Wq1w@mail.gmail.com> On Wed, Jul 29, 2020 at 2:43 PM Ian Rogers <irogers@google.com> wrote: > > On Wed, Jul 29, 2020 at 11:52 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > Em Tue, Jul 28, 2020 at 01:57:30AM -0700, Ian Rogers escreveu: > > > From: David Sharp <dhsharp@google.com> > > > > > > evsel__config() would only set PERF_RECORD_PERIOD if it set attr->freq > > > > There is no such thing as 'PERF_RECORD_PERIOD', its PERF_SAMPLE_PERIOD, > > also... > > > > > 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); > > > > Why can't the libpfm code set opts? > > > > With this patch we will end up calling evsel__set_sample_bit(evsel, > > PERIOD) twice, which isn't a problem but looks strange. > > Thanks Arnaldo! The case I was looking at was something like: > perf record --pfm-events cycles:freq=1000 > > For regular events this would be: > perf record -e cycles/freq=1000/ > > With libpfm4 events the perf_event_attr is set up (a public API in > linux/perf_event.h) and then parse_events__add_event is used (an > internal API) to make the evsel and this added to the evlist > (parse_libpfm_events_option). This is similar to the parse_events > function except rather than set up a perf_event_attr the regular > parsing sets up config terms that are then applied to evsel and attr > later in evsel__config, via evsel__apply_config_terms. > > I think we can update this change so that in pfm.c after > parse_events__add_event we do: > if (attr.freq) > evsel__set_sample_bit(evsel, PERIOD); > > This code could also be part of parse_events__add_event. I think the > intent in placing this code here was that it is close to the similar > evsel__apply_config_terms and setting of sample bits in the evsel. The > logic here is already dependent on reading the attr->sample_period. > > I'm not sure I follow the double setting case - I think that is only > possible with a config term or with period_set (-P). > > Thanks, > Ian Polite ping. Thanks, Ian > > > - Arnaldo > > > > > > > > if (opts->no_samples) > > > attr->sample_freq = 0; > > > -- > > > 2.28.0.163.g6104cc2f0b6-goog > > > > > > > -- > > > > - Arnaldo
next prev parent reply other threads:[~2020-09-04 5:39 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-28 8:57 [PATCH v2 0/5] Fixes for setting event freq/periods Ian Rogers 2020-07-28 8:57 ` [PATCH v2 1/5] perf record: Set PERF_RECORD_PERIOD if attr->freq is set Ian Rogers 2020-07-28 15:43 ` Jiri Olsa 2020-07-28 16:03 ` Arnaldo Carvalho de Melo 2020-07-29 15:11 ` Athira Rajeev 2020-07-29 18:52 ` Arnaldo Carvalho de Melo 2020-07-29 21:43 ` Ian Rogers 2020-09-04 5:39 ` Ian Rogers [this message] 2020-07-28 8:57 ` [PATCH v2 2/5] perf record: Prevent override of attr->sample_period for libpfm4 events Ian Rogers 2020-07-28 15:59 ` Jiri Olsa 2020-07-28 16:09 ` Jiri Olsa 2020-07-29 23:24 ` Ian Rogers 2020-09-04 5:41 ` Ian Rogers 2020-09-04 16:03 ` Jiri Olsa 2020-09-04 16:22 ` Ian Rogers 2020-09-04 18:48 ` Arnaldo Carvalho de Melo 2020-09-04 18:50 ` Arnaldo Carvalho de Melo 2020-09-04 18:51 ` Arnaldo Carvalho de Melo 2020-09-11 22:34 ` Ian Rogers 2020-09-12 3:02 ` Ian Rogers 2020-07-29 18:54 ` Arnaldo Carvalho de Melo 2020-07-28 8:57 ` [PATCH v2 3/5] perf test: Ensure sample_period is set " Ian Rogers 2020-07-28 12:45 ` Arnaldo Carvalho de Melo 2020-07-28 8:57 ` [PATCH v2 4/5] perf record: Don't clear event's period if set by a term Ian Rogers 2020-07-29 18:58 ` Arnaldo Carvalho de Melo 2020-08-04 10:08 ` Adrian Hunter 2020-08-04 13:33 ` Ian Rogers 2020-08-04 14:48 ` Adrian Hunter 2020-08-04 15:50 ` Ian Rogers 2020-09-04 5:43 ` Ian Rogers 2020-09-07 6:36 ` Adrian Hunter 2020-07-28 8:57 ` [PATCH v2 5/5] perf test: Leader sampling shouldn't clear sample period Ian Rogers
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='CAP-5=fXbLtiX5Syji7X=-tV8r=PbbTw7X63h4PfggT-XvUemtQ@mail.gmail.com' \ --to=irogers@google.com \ --cc=acme@kernel.org \ --cc=adrian.hunter@intel.com \ --cc=ak@linux.intel.com \ --cc=alexander.shishkin@linux.intel.com \ --cc=andriin@fb.com \ --cc=ast@kernel.org \ --cc=atrajeev@linux.vnet.ibm.com \ --cc=bpf@vger.kernel.org \ --cc=daniel@iogearbox.net \ --cc=eranian@google.com \ --cc=john.fastabend@gmail.com \ --cc=jolsa@redhat.com \ --cc=kafai@fb.com \ --cc=kpsingh@chromium.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=mingo@redhat.com \ --cc=namhyung@kernel.org \ --cc=netdev@vger.kernel.org \ --cc=peterz@infradead.org \ --cc=songliubraving@fb.com \ --cc=yhs@fb.com \ /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: linkBe 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).