All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] perf: Fix AUX software double buffering
@ 2019-05-03  8:55 Alexander Shishkin
  2019-05-03  8:55 ` [PATCH 1/2] " Alexander Shishkin
  2019-05-03  8:55 ` [PATCH 2/2] perf, pt: Remove software double buffering PMU capability Alexander Shishkin
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Shishkin @ 2019-05-03  8:55 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, jolsa,
	adrian.hunter, Alexander Shishkin

Hi Peter,

There was a problem with 04fe30a61514 ("perf/ring_buffer: Use high order
allocations for AUX buffers optimistically") that made buffers that were
previously scattered across multiple pages into one large buffer, breaking
double buffering. In practice, this manifests easily for non-privileged
users, whose buffers are generally smaller than MAX_ORDER and would fit
into one high-order allocation. Root's default AUX buffer size is larger
and would get split, so they are less affected. The fix is trivial and
we also get rid of one PMU capability as a bonus.

Alexander Shishkin (2):
  perf: Fix AUX software double buffering
  perf, pt: Remove software double buffering PMU capability

 arch/x86/events/intel/pt.c  | 3 +--
 include/linux/perf_event.h  | 1 -
 kernel/events/ring_buffer.c | 3 +--
 3 files changed, 2 insertions(+), 5 deletions(-)

-- 
2.20.1


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

* [PATCH 1/2] perf: Fix AUX software double buffering
  2019-05-03  8:55 [PATCH 0/2] perf: Fix AUX software double buffering Alexander Shishkin
@ 2019-05-03  8:55 ` Alexander Shishkin
  2019-05-03 10:49   ` [tip:perf/urgent] perf/ring_buffer: " tip-bot for Alexander Shishkin
  2019-05-03  8:55 ` [PATCH 2/2] perf, pt: Remove software double buffering PMU capability Alexander Shishkin
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Shishkin @ 2019-05-03  8:55 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, jolsa,
	adrian.hunter, Alexander Shishkin, Ammy Yi

Commit 5768402fd9c6e87 ("perf/ring_buffer: Use high order allocations for
AUX buffers optimistically") overlooked the fact that the previous one page
granularity of the AUX buffer provided an implicit double buffering
capability to the PMU driver, which went away when the entire buffer became
one high-order page.

Always make the full-trace mode AUX allocation at least two-part to preserve
the previous behavior and allow the implicit double buffering to continue.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 5768402fd9c6e87 ("perf/ring_buffer: Use high order allocations for AUX buffers optimistically")
Reported-by: Ammy Yi <ammy.yi@intel.com>
---
 kernel/events/ring_buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 5eedb49a65ea..674b35383491 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -610,8 +610,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 	 * PMU requests more than one contiguous chunks of memory
 	 * for SW double buffering
 	 */
-	if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_SW_DOUBLEBUF) &&
-	    !overwrite) {
+	if (!overwrite) {
 		if (!max_order)
 			return -EINVAL;
 
-- 
2.20.1


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

* [PATCH 2/2] perf, pt: Remove software double buffering PMU capability
  2019-05-03  8:55 [PATCH 0/2] perf: Fix AUX software double buffering Alexander Shishkin
  2019-05-03  8:55 ` [PATCH 1/2] " Alexander Shishkin
@ 2019-05-03  8:55 ` Alexander Shishkin
  2019-05-03 10:50   ` [tip:perf/urgent] perf/x86/intel/pt: " tip-bot for Alexander Shishkin
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Shishkin @ 2019-05-03  8:55 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, jolsa,
	adrian.hunter, Alexander Shishkin

Now that all AUX allocations are high-order by default, the software
double buffering PMU capability doesn't make sense any more, get rid
of it. In case some PMUs choose to opt out, we can re-introduce it.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 arch/x86/events/intel/pt.c | 3 +--
 include/linux/perf_event.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index fb3a2f13fc70..339d7628080c 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1525,8 +1525,7 @@ static __init int pt_init(void)
 	}
 
 	if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries))
-		pt_pmu.pmu.capabilities =
-			PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_AUX_SW_DOUBLEBUF;
+		pt_pmu.pmu.capabilities = PERF_PMU_CAP_AUX_NO_SG;
 
 	pt_pmu.pmu.capabilities	|= PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE;
 	pt_pmu.pmu.attr_groups		 = pt_attr_groups;
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index cf023db0e8a2..15a82ff0aefe 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -240,7 +240,6 @@ struct perf_event;
 #define PERF_PMU_CAP_NO_INTERRUPT		0x01
 #define PERF_PMU_CAP_NO_NMI			0x02
 #define PERF_PMU_CAP_AUX_NO_SG			0x04
-#define PERF_PMU_CAP_AUX_SW_DOUBLEBUF		0x08
 #define PERF_PMU_CAP_EXCLUSIVE			0x10
 #define PERF_PMU_CAP_ITRACE			0x20
 #define PERF_PMU_CAP_HETEROGENEOUS_CPUS		0x40
-- 
2.20.1


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

* [tip:perf/urgent] perf/ring_buffer: Fix AUX software double buffering
  2019-05-03  8:55 ` [PATCH 1/2] " Alexander Shishkin
@ 2019-05-03 10:49   ` tip-bot for Alexander Shishkin
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Alexander Shishkin @ 2019-05-03 10:49 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: eranian, acme, mingo, tglx, vincent.weaver, ammy.yi,
	a.p.zijlstra, hpa, alexander.shishkin, torvalds, linux-kernel,
	jolsa

Commit-ID:  26ae4f4406f88d82d79c85c11ac5fae18213cd38
Gitweb:     https://git.kernel.org/tip/26ae4f4406f88d82d79c85c11ac5fae18213cd38
Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Fri, 3 May 2019 11:55:35 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 3 May 2019 12:46:10 +0200

perf/ring_buffer: Fix AUX software double buffering

This recent commit:

  5768402fd9c6e87 ("perf/ring_buffer: Use high order allocations for AUX buffers optimistically")

overlooked the fact that the previous one page granularity of the AUX buffer
provided an implicit double buffering capability to the PMU driver, which
went away when the entire buffer became one high-order page.

Always make the full-trace mode AUX allocation at least two-part to preserve
the previous behavior and allow the implicit double buffering to continue.

Reported-by: Ammy Yi <ammy.yi@intel.com>
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@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: adrian.hunter@intel.com
Fixes: 5768402fd9c6e87 ("perf/ring_buffer: Use high order allocations for AUX buffers optimistically")
Link: http://lkml.kernel.org/r/20190503085536.24119-2-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/events/ring_buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 5eedb49a65ea..674b35383491 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -610,8 +610,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 	 * PMU requests more than one contiguous chunks of memory
 	 * for SW double buffering
 	 */
-	if ((event->pmu->capabilities & PERF_PMU_CAP_AUX_SW_DOUBLEBUF) &&
-	    !overwrite) {
+	if (!overwrite) {
 		if (!max_order)
 			return -EINVAL;
 

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

* [tip:perf/urgent] perf/x86/intel/pt: Remove software double buffering PMU capability
  2019-05-03  8:55 ` [PATCH 2/2] perf, pt: Remove software double buffering PMU capability Alexander Shishkin
@ 2019-05-03 10:50   ` tip-bot for Alexander Shishkin
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Alexander Shishkin @ 2019-05-03 10:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, hpa, vincent.weaver, acme, torvalds, eranian,
	jolsa, mingo, tglx, alexander.shishkin, linux-kernel

Commit-ID:  72e830f68428ab9ea9eca65d160795f4e02cecfc
Gitweb:     https://git.kernel.org/tip/72e830f68428ab9ea9eca65d160795f4e02cecfc
Author:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
AuthorDate: Fri, 3 May 2019 11:55:36 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 3 May 2019 12:46:20 +0200

perf/x86/intel/pt: Remove software double buffering PMU capability

Now that all AUX allocations are high-order by default, the software
double buffering PMU capability doesn't make sense any more, get rid
of it. In case some PMUs choose to opt out, we can re-introduce it.

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@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: adrian.hunter@intel.com
Link: http://lkml.kernel.org/r/20190503085536.24119-3-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/events/intel/pt.c | 3 +--
 include/linux/perf_event.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index fb3a2f13fc70..339d7628080c 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1525,8 +1525,7 @@ static __init int pt_init(void)
 	}
 
 	if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries))
-		pt_pmu.pmu.capabilities =
-			PERF_PMU_CAP_AUX_NO_SG | PERF_PMU_CAP_AUX_SW_DOUBLEBUF;
+		pt_pmu.pmu.capabilities = PERF_PMU_CAP_AUX_NO_SG;
 
 	pt_pmu.pmu.capabilities	|= PERF_PMU_CAP_EXCLUSIVE | PERF_PMU_CAP_ITRACE;
 	pt_pmu.pmu.attr_groups		 = pt_attr_groups;
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index e47ef764f613..1f678f023850 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -240,7 +240,6 @@ struct perf_event;
 #define PERF_PMU_CAP_NO_INTERRUPT		0x01
 #define PERF_PMU_CAP_NO_NMI			0x02
 #define PERF_PMU_CAP_AUX_NO_SG			0x04
-#define PERF_PMU_CAP_AUX_SW_DOUBLEBUF		0x08
 #define PERF_PMU_CAP_EXCLUSIVE			0x10
 #define PERF_PMU_CAP_ITRACE			0x20
 #define PERF_PMU_CAP_HETEROGENEOUS_CPUS		0x40

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

end of thread, other threads:[~2019-05-03 10:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03  8:55 [PATCH 0/2] perf: Fix AUX software double buffering Alexander Shishkin
2019-05-03  8:55 ` [PATCH 1/2] " Alexander Shishkin
2019-05-03 10:49   ` [tip:perf/urgent] perf/ring_buffer: " tip-bot for Alexander Shishkin
2019-05-03  8:55 ` [PATCH 2/2] perf, pt: Remove software double buffering PMU capability Alexander Shishkin
2019-05-03 10:50   ` [tip:perf/urgent] perf/x86/intel/pt: " 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.