perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event
PATCH 1/1 perf evsel: Don't set sample_regs_intr/sample_regs_user for dummy event
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) ]
--- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +2 -2
@@ -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 ); }
Signature · 1 line
2.17.1
Quoted 42 lines · Jin Yao
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->capabilitiesis not set withPERF_PMU_CAP_EXTENDED_REGS, the kernel will return-EOPNOTSUPPerror.See following code pieces.
/* in
kernel/events/core.c*/
static intperf_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 withPERF_REG_EXTENDED_MASKbit.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_MASKbit.It doesn't make sense to set
attr->sample_regs_intrfor a software dummy event.
Quoted 7 lines
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/[email protected]/
jirka
Quoted 29 lines
Fixes 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis")Signed-off-by Jin Yao <[email protected]>--- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/util/evsel.c +2
-2@@ -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 ); }Signature · 1 line
2.17.1
Hi Jiri,
Quoted 51 lines · Jiri Olsa
Quoted 42 lines · Jin Yao
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->capabilitiesis not set withPERF_PMU_CAP_EXTENDED_REGS, the kernel will return-EOPNOTSUPPerror.See following code pieces.
/* in
kernel/events/core.c*/
static intperf_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 withPERF_REG_EXTENDED_MASKbit.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_MASKbit.It doesn't make sense to set
attr->sample_regs_intrfor a software dummy event.Quoted 7 lines
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) ]
Quoted 7 lines
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/[email protected]/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
Quoted 30 lines
Quoted 29 lines
Fixes 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis")Signed-off-by Jin Yao <[email protected]>--- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/util/evsel.c +2
-2@@ -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 ); }Signature · 1 line
2.17.1
Ian Rogers
reviewerQuoted 14 lines · Yao
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
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'
Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with:
$ perf record -e cycles:p -IAX -a -- sleep 1
succeeds.
Thanks,
Ian
Quoted 86 lines
Quoted 41 lines
Quoted 33 lines
The issue is, if we enable the extended regs (-IXMM0), but the
pmu->capabilitiesis not set withPERF_PMU_CAP_EXTENDED_REGS, the kernel will return-EOPNOTSUPPerror.See following code pieces.
/* in
kernel/events/core.c*/
static intperf_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 withPERF_REG_EXTENDED_MASKbit.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_MASKbit.It doesn't make sense to set
attr->sample_regs_intrfor a software dummy event.Quoted 7 lines
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) ]Quoted 7 lines
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/[email protected]/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 YaoQuoted 30 lines
Quoted 29 lines
Fixes 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis")Signed-off-by Jin Yao <[email protected]>--- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/util/evsel.c +2
-3@@ -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
Hi Ian,
Quoted 21 lines · Ian Rogers
Quoted 14 lines · Yao
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
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'Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in
tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with:
Quoted 7 lines
$ perf record -e cycles:p -IAX -a -- sleep 1succeeds.
Thanks,
Ian
-IAX should be no problem. The issue only occurs on the platform with extended regs supports, such as ICL. So I don't know if it's suitable to add it to perf test suite.
Thanks
Jin Yao
Quoted 86 lines
Quoted 86 lines
Quoted 41 lines
Quoted 33 lines
The issue is, if we enable the extended regs (-IXMM0), but the
pmu->capabilitiesis not set withPERF_PMU_CAP_EXTENDED_REGS, the kernel will return-EOPNOTSUPPerror.See following code pieces.
/* in
kernel/events/core.c*/
static intperf_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 withPERF_REG_EXTENDED_MASKbit.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_MASKbit.It doesn't make sense to set
attr->sample_regs_intrfor a software dummy event.Quoted 7 lines
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) ]Quoted 7 lines
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/[email protected]/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 YaoQuoted 30 lines
Quoted 29 lines
Fixes 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis")Signed-off-by Jin Yao <[email protected]>--- tools/perf/util/evsel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/util/evsel.c +2
-3@@ -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
Hi,
Quoted 32 lines · Yao
Hi Ian,
Quoted 21 lines · Ian Rogers
Quoted 14 lines · Yao
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
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'Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in
tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with:Quoted 7 lines
$ perf record -e cycles:p -IAX -a -- sleep 1succeeds.
Thanks,
Ian
Quoted 6 lines
-IAX should be no problem. The issue only occurs on the platform with extended regs supports, such as ICL. So I don't know if it's suitable to add it to perf test suite.
Thanks
Jin Yao
Can this fix patch be accepted?
Thanks
Jin Yao
Quoted 86 lines
Quoted 86 lines
Quoted 86 lines
Quoted 41 lines
Quoted 33 lines
The issue is, if we enable the extended regs (-IXMM0), but the
pmu->capabilitiesis not set withPERF_PMU_CAP_EXTENDED_REGS, the kernel will return-EOPNOTSUPPerror.See following code pieces.
/* in
kernel/events/core.c*/
static intperf_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 withPERF_REG_EXTENDED_MASKbit.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_MASKbit.It doesn't make sense to set
attr->sample_regs_intrfor a software dummy event.Quoted 7 lines
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) ]Quoted 7 lines
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/[email protected]/
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 YaoQuoted 30 lines
Quoted 29 lines
Fixes 0a892c1c9472 ("perf record: Add dummy event during system wide synthesis")Signed-off-by Jin Yao <[email protected]>---
tools/perf/util/evsel.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/util/evsel.c +2
-2@@ -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); }Signature · 1 line
2.17.1
Jiri Olsa
Acked-byQuoted 39 lines · Yao
Hi,
Quoted 36 lines · Yao
Hi Ian,
Quoted 21 lines · Ian Rogers
Quoted 14 lines · Yao
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
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'Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in
tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with:Quoted 7 lines
$ perf record -e cycles:p -IAX -a -- sleep 1succeeds.
Thanks,
Ian-IAX should be no problem. The issue only occurs on the platform with extended regs supports, such as ICL. So I don't know if it's suitable to add it to perf test suite.
Quoted 5 lines
Quoted 3 lines
Thanks
Jin YaoCan this fix patch be accepted?
hi,
my only concern was that it would conflict with Adrian's patch, other than that:
thanks,
jirka
Quoted 46 lines · Jiri Olsa
Quoted 39 lines · Yao
Hi,
Quoted 36 lines · Yao
Hi Ian,
Quoted 21 lines · Ian Rogers
Quoted 14 lines · Yao
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
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'Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in
tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with:Quoted 7 lines
$ perf record -e cycles:p -IAX -a -- sleep 1succeeds.
Thanks,
Ian-IAX should be no problem. The issue only occurs on the platform with extended regs supports, such as ICL. So I don't know if it's suitable to add it to perf test suite.
Quoted 5 lines
Quoted 3 lines
Thanks
Jin YaoCan this fix patch be accepted?
Quoted 9 lines
hi,
my only concern was that it would conflict with Adrian's patch, other than that:Acked-by Jiri Olsa <[email protected]>thanks,
jirka
Thanks Jiri!
Adrian's patch has not been merged otherwise I can rebase my patch on top of Adrian's patch.
Thanks
Jin Yao
Arnaldo Carvalho de Melo
maintainerEm Fri, Jul 17, 2020 at 04:30:21PM +0800, Jin, Yao escreveu:
Quoted 55 lines · Jiri Olsa
Quoted 52 lines · Yao
Quoted 39 lines
Hi,
Quoted 36 lines · Yao
Hi Ian,
Quoted 21 lines · Ian Rogers
Quoted 14 lines · Yao
Hi Jiri,
Quoted 10 lines · Jiri Olsa
Quoted 9 lines · Jin Yao
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'Sorry for the breakage caused by modifying the dummy event. Could we add a test to cover the issue? Perhaps in
tools/perf/tests/shell/. Trying to reproduce with a register on my skylakex on a 5.6.14 kernel with:Quoted 7 lines
$ perf record -e cycles:p -IAX -a -- sleep 1succeeds.
Thanks,
Ian-IAX should be no problem. The issue only occurs on the platform with extended regs supports, such as ICL. So I don't know if it's suitable to add it to perf test suite.
Quoted 5 lines
Quoted 3 lines
Thanks
Jin YaoCan this fix patch be accepted?
hi,
my only concern was that it would conflict with Adrian's patch, other than that:Acked-by Jiri Olsa <[email protected]>
Quoted 7 lines
Quoted 3 lines
thanks,
jirkaThanks Jiri!
Adrian's patch has not been merged otherwise I can rebase my patch on top of Adrian's patch.
I'll check this today.
- Arnaldo