From: "Jin, Yao" <yao.jin@linux.intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com,
Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com, irogers@google.com,
Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH] perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event
Date: Sat, 4 Jul 2020 08:31:50 +0800 [thread overview]
Message-ID: <9fa0bd83-b21e-7bc2-af81-799f8e99f73b@linux.intel.com> (raw)
In-Reply-To: <20200703110042.GA3282312@krava>
Hi Jiri,
On 7/3/2020 7:00 PM, Jiri Olsa wrote:
> On Fri, Jul 03, 2020 at 08:42:15AM +0800, Jin Yao wrote:
>> Since commit 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis"),
>> a dummy event is added to capture mmaps.
>>
>> But if we run perf-record as,
>>
>> # perf record -e cycles:p -IXMM0 -a -- sleep 1
>> Error:
>> dummy:HG: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
>>
>> The issue is, if we enable the extended regs (-IXMM0), but the
>> pmu->capabilities is not set with PERF_PMU_CAP_EXTENDED_REGS, the kernel
>> will return -EOPNOTSUPP error.
>>
>> See following code pieces.
>>
>> /* in kernel/events/core.c */
>> static int perf_try_init_event(struct pmu *pmu, struct perf_event *event)
>>
>> {
>> ....
>> if (!(pmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS) &&
>> has_extended_regs(event))
>> ret = -EOPNOTSUPP;
>> ....
>> }
>>
>> For software dummy event, the PMU should be not set with
>> PERF_PMU_CAP_EXTENDED_REGS. But unfortunately in current code, the dummy
>> event has possibility to be set with PERF_REG_EXTENDED_MASK bit.
>>
>> In evsel__config, /* tools/perf/util/evsel.c */
>>
>> if (opts->sample_intr_regs) {
>> attr->sample_regs_intr = opts->sample_intr_regs;
>> }
>>
>> If we use -IXMM0, the attr>sample_regs_intr will be set with
>> PERF_REG_EXTENDED_MASK bit.
>>
>> It doesn't make sense to set attr->sample_regs_intr for a
>> software dummy event.
>>
>> This patch adds dummy event checking before setting
>> attr->sample_regs_intr.
>>
>> After:
>> # ./perf record -e cycles:p -IXMM0 -a -- sleep 1
>> [ perf record: Woken up 1 times to write data ]
>> [ perf record: Captured and wrote 0.413 MB perf.data (45 samples) ]
>
> LGTM, Adrian (cc-ed) just added another check to the same place,
> but it looks like both of them should be there:
>
> https://lore.kernel.org/lkml/20200630133935.11150-2-adrian.hunter@intel.com/
>
> jirka
>
Thanks Jiri! Yes, it looks like both of checks should be added here.
So do I post v2 (just rebase) once Adrian's patch gets merged?
Thanks
Jin Yao
>>
>> Fixes: 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis")
>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>> ---
>> tools/perf/util/evsel.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
>> index 96e5171dce41..df3315543e86 100644
>> --- a/tools/perf/util/evsel.c
>> +++ b/tools/perf/util/evsel.c
>> @@ -1020,12 +1020,12 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
>> if (callchain && callchain->enabled && !evsel->no_aux_samples)
>> evsel__config_callchain(evsel, opts, callchain);
>>
>> - if (opts->sample_intr_regs) {
>> + if (opts->sample_intr_regs && !is_dummy_event(evsel)) {
>> attr->sample_regs_intr = opts->sample_intr_regs;
>> evsel__set_sample_bit(evsel, REGS_INTR);
>> }
>>
>> - if (opts->sample_user_regs) {
>> + if (opts->sample_user_regs && !is_dummy_event(evsel)) {
>> attr->sample_regs_user |= opts->sample_user_regs;
>> evsel__set_sample_bit(evsel, REGS_USER);
>> }
>> --
>> 2.17.1
>>
>
next prev parent reply other threads:[~2020-07-04 0:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 0:42 Jin Yao
2020-07-03 11:00 ` Jiri Olsa
2020-07-04 0:31 ` Jin, Yao [this message]
2020-07-06 0:47 ` Ian Rogers
2020-07-06 0:55 ` Jin, Yao
2020-07-17 3:33 ` Jin, Yao
2020-07-17 8:24 ` Jiri Olsa
2020-07-17 8:30 ` Jin, Yao
2020-07-17 11:38 ` Arnaldo Carvalho de Melo
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=9fa0bd83-b21e-7bc2-af81-799f8e99f73b@linux.intel.com \
--to=yao.jin@linux.intel.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.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: 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
Powered by JetHome