All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] perf, bts: Make BTS exclusive again
@ 2016-09-20 15:48 Alexander Shishkin
  2016-09-20 15:48 ` [PATCH 1/2] perf/x86/intel/bts: Make it an exclusive PMU Alexander Shishkin
  2016-09-20 15:48 ` [PATCH 2/2] perf: Limit matching exclusive events to one PMU Alexander Shishkin
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Shishkin @ 2016-09-20 15:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, linux-kernel, vince, eranian,
	Arnaldo Carvalho de Melo, tglx, Alexander Shishkin

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

-- 
2.9.3

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

* [PATCH 1/2] perf/x86/intel/bts: Make it an exclusive PMU
  2016-09-20 15:48 [PATCH 0/2] perf, bts: Make BTS exclusive again Alexander Shishkin
@ 2016-09-20 15:48 ` Alexander Shishkin
  2016-09-22 14:00   ` [tip:perf/urgent] " tip-bot for Alexander Shishkin
  2016-09-20 15:48 ` [PATCH 2/2] perf: Limit matching exclusive events to one PMU Alexander Shishkin
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Shishkin @ 2016-09-20 15:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, linux-kernel, vince, eranian,
	Arnaldo Carvalho de Melo, tglx, Alexander Shishkin

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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 arch/x86/events/intel/bts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index bdcd651099..6112c3d538 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -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;
-- 
2.9.3

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

* [PATCH 2/2] perf: Limit matching exclusive events to one PMU
  2016-09-20 15:48 [PATCH 0/2] perf, bts: Make BTS exclusive again Alexander Shishkin
  2016-09-20 15:48 ` [PATCH 1/2] perf/x86/intel/bts: Make it an exclusive PMU Alexander Shishkin
@ 2016-09-20 15:48 ` Alexander Shishkin
  2016-09-22 14:01   ` [tip:perf/urgent] perf/core: " tip-bot for Alexander Shishkin
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Shishkin @ 2016-09-20 15:48 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Ingo Molnar, linux-kernel, vince, eranian,
	Arnaldo Carvalho de Melo, tglx, Alexander Shishkin

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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index fedba316cc..7c0d263f6b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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))
-- 
2.9.3

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

* [tip:perf/urgent] perf/x86/intel/bts: Make it an exclusive PMU
  2016-09-20 15:48 ` [PATCH 1/2] perf/x86/intel/bts: Make it an exclusive PMU Alexander Shishkin
@ 2016-09-22 14:00   ` tip-bot for Alexander Shishkin
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Alexander Shishkin @ 2016-09-22 14:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, eranian, jolsa, alexander.shishkin, vincent.weaver,
	peterz, linux-kernel, mingo, acme, acme, a.p.zijlstra, hpa, tglx

Commit-ID:  08b90f0655258411a1b41d856331e20e7ec8d55c
Gitweb:     http://git.kernel.org/tip/08b90f0655258411a1b41d856331e20e7ec8d55c
Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Tue, 20 Sep 2016 18:48:10 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: vince@deater.net
Link: http://lkml.kernel.org/r/20160920154811.3255-2-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/intel/bts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 6ff66ef..982c9e3 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -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;

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

* [tip:perf/urgent] perf/core: Limit matching exclusive events to one PMU
  2016-09-20 15:48 ` [PATCH 2/2] perf: Limit matching exclusive events to one PMU Alexander Shishkin
@ 2016-09-22 14:01   ` tip-bot for Alexander Shishkin
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Alexander Shishkin @ 2016-09-22 14:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: vincent.weaver, hpa, peterz, torvalds, acme, jolsa, linux-kernel,
	acme, mingo, alexander.shishkin, a.p.zijlstra, eranian, tglx

Commit-ID:  3bf6215a1b30db7df6083c708caab3fe1a8e8abe
Gitweb:     http://git.kernel.org/tip/3bf6215a1b30db7df6083c708caab3fe1a8e8abe
Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Tue, 20 Sep 2016 18:48:11 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: vince@deater.net
Link: http://lkml.kernel.org/r/20160920154811.3255-3-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index a54f2c2..fc9bb22 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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))

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

end of thread, other threads:[~2016-09-22 14:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20 15:48 [PATCH 0/2] perf, bts: Make BTS exclusive again Alexander Shishkin
2016-09-20 15:48 ` [PATCH 1/2] perf/x86/intel/bts: Make it an exclusive PMU Alexander Shishkin
2016-09-22 14:00   ` [tip:perf/urgent] " tip-bot for Alexander Shishkin
2016-09-20 15:48 ` [PATCH 2/2] perf: Limit matching exclusive events to one PMU Alexander Shishkin
2016-09-22 14:01   ` [tip:perf/urgent] perf/core: " tip-bot for Alexander Shishkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.