perf, bts: Make BTS exclusive again
Subsystems (2)
Alexander Shishkin
reviewercover perf, bts: Make BTS exclusive again
Hi Peter,
While looking at something else I noticed that the exclusive event filter only allows one such event per context, whereas it should allow one such event from each PMU that has PERF_PMU_CAP_EXCLUSIVE. At the same time, intel_bts PMU doesn't even have this capability set (which is why on systems that allow coexistance of PT and BTS it still works, see ccbebba4c6 for more context).
Alexander Shishkin (2):
perf/x86/intel/bts: Make it an exclusive PMU
perf: Limit matching exclusive events to one PMU
arch/x86/events/intel/bts.c | 3 ++- kernel/events/core.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.3
Alexander Shishkin
reviewerPATCH 1/2 perf/x86/intel/bts: Make it an exclusive PMU
Just like intel_pt, intel_bts can only handle one event at a time, which is the reason we introduced PERF_PMU_CAP_EXCLUSIVE in the first place. However, at the moment one can have as many intel_bts events within the same context at the same time as one pleases. Only one of them, however, will get scheduled and receive the actual trace data.
Fix this by making intel_bts an "exclusive" PMU.
--- arch/x86/events/intel/bts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/events/intel/bts.c +2 -1
@@ -584,7 +584,8 @@ static __init int bts_init(void)if (!boot_cpu_has (X86_FEATURE_DTES64 ) || !x86_pmu.bts)return -ENODEV ; - bts_pmu.capabilities =PERF_PMU_CAP_AUX_NO_SG |PERF_PMU_CAP_ITRACE ; + bts_pmu.capabilities =PERF_PMU_CAP_AUX_NO_SG |PERF_PMU_CAP_ITRACE | +PERF_PMU_CAP_EXCLUSIVE ; bts_pmu.task_ctx_nr = perf_sw_context; bts_pmu.event_init = bts_event_init; bts_pmu.add = bts_event_add;
Signature · 1 line
2.9.3
tip-bot for Alexander Shishkin
merge bot[tip:perf/urgent] perf/x86/intel/bts: Make it an exclusive PMU
perf/x86/intel/bts: Make it an exclusive PMU
Commit-ID: 08b90f0655258411a1b41d856331e20e7ec8d55c Gitweb: http://git.kernel.org/tip/08b90f0655258411a1b41d856331e20e7ec8d55c Author: Alexander Shishkin <[email protected]> AuthorDate: Tue, 20 Sep 2016 18:48:10 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 22 Sep 2016 14:56:08 +0200
perf/x86/intel/bts: Make it an exclusive PMU
Just like intel_pt, intel_bts can only handle one event at a time, which is the reason we introduced PERF_PMU_CAP_EXCLUSIVE in the first place. However, at the moment one can have as many intel_bts events within the same context at the same time as one pleases. Only one of them, however, will get scheduled and receive the actual trace data.
Fix this by making intel_bts an "exclusive" PMU.
--- arch/x86/events/intel/bts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/events/intel/bts.c +2 -1
@@ -584,7 +584,8 @@ static __init int bts_init(void)if (!boot_cpu_has (X86_FEATURE_DTES64 ) || !x86_pmu.bts)return -ENODEV ; - bts_pmu.capabilities =PERF_PMU_CAP_AUX_NO_SG |PERF_PMU_CAP_ITRACE ; + bts_pmu.capabilities =PERF_PMU_CAP_AUX_NO_SG |PERF_PMU_CAP_ITRACE | +PERF_PMU_CAP_EXCLUSIVE ; bts_pmu.task_ctx_nr = perf_sw_context; bts_pmu.event_init = bts_event_init; bts_pmu.add = bts_event_add;
Alexander Shishkin
reviewerPATCH 2/2 perf: Limit matching exclusive events to one PMU
In reply to Alexander ShishkinAn "exclusive" PMU is the one that can only have one event scheduled in at any given time. There may be more than one of such PMUs in a system, though, like Intel PT and BTS. It should be allowed to have one event for either of those inside the same context (there may be other constraints that may prevent this, but those would be hardware-specific). However, the exclusivity code is written so that only one event from any of the "exclusive" PMUs is allowed in a context.
Fix this by making the exclusive event filter explicitly match two events' PMUs.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -3958,7 +3958,7 @@ static void exclusive_event_destroy(struct perf_event *event)static bool exclusive_event_match (struct perf_event *e1,struct perf_event *e2) { -if ((e1->pmu->capabilities &PERF_PMU_CAP_EXCLUSIVE ) && +if ((e1->pmu == e2->pmu) && (e1->cpu == e2->cpu || e1->cpu ==-1 || e2->cpu ==-1 ))
Signature · 1 line
2.9.3
tip-bot for Alexander Shishkin
merge bot[tip:perf/urgent] perf/core: Limit matching exclusive events to one PMU
perf/core: Limit matching exclusive events to one PMU
Commit-ID: 3bf6215a1b30db7df6083c708caab3fe1a8e8abe Gitweb: http://git.kernel.org/tip/3bf6215a1b30db7df6083c708caab3fe1a8e8abe Author: Alexander Shishkin <[email protected]> AuthorDate: Tue, 20 Sep 2016 18:48:11 +0300 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 22 Sep 2016 14:56:09 +0200
perf/core: Limit matching exclusive events to one PMU
An "exclusive" PMU is the one that can only have one event scheduled in at any given time. There may be more than one of such PMUs in a system, though, like Intel PT and BTS. It should be allowed to have one event for either of those inside the same context (there may be other constraints that may prevent this, but those would be hardware-specific). However, the exclusivity code is written so that only one event from any of the "exclusive" PMUs is allowed in a context.
Fix this by making the exclusive event filter explicitly match two events' PMUs.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -3929,7 +3929,7 @@ static void exclusive_event_destroy(struct perf_event *event)static bool exclusive_event_match (struct perf_event *e1,struct perf_event *e2) { -if ((e1->pmu->capabilities &PERF_PMU_CAP_EXCLUSIVE ) && +if ((e1->pmu == e2->pmu) && (e1->cpu == e2->cpu || e1->cpu ==-1 || e2->cpu ==-1 ))