perf: Fix AUX software double buffering
Subsystems (2)
Alexander Shishkin
reviewercover perf: Fix AUX software double buffering
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(-)
Signature · 1 line
2.20.1
Alexander Shishkin
reviewerPATCH 1/2 perf: Fix AUX software double buffering
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.
--- kernel/events/ring_buffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/events/ring_buffer.c +1 -2
@@ -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 ;
Signature · 1 line
2.20.1
tip-bot for Alexander Shishkin
merge bot[tip:perf/urgent] perf/ring_buffer: Fix AUX software double buffering
perf/ring_buffer: Fix AUX software double buffering
Commit-ID: 26ae4f4406f88d82d79c85c11ac5fae18213cd38 Gitweb: https://git.kernel.org/tip/26ae4f4406f88d82d79c85c11ac5fae18213cd38 Author: Alexander Shishkin <[email protected]> AuthorDate: Fri, 3 May 2019 11:55:35 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- kernel/events/ring_buffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/events/ring_buffer.c +1 -2
@@ -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 ;
Alexander Shishkin
reviewerPATCH 2/2 perf, pt: Remove software double buffering PMU capability
In reply to Alexander ShishkinNow 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.
--- arch/x86/events/intel/pt.c | 3 +-- include/linux/perf_event.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
arch/x86/events/intel/pt.c +1 -2
@@ -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;
include/linux/perf_event.h +0 -1
@@ -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
Signature · 1 line
2.20.1
tip-bot for Alexander Shishkin
merge bot[tip:perf/urgent] perf/x86/intel/pt: Remove software double buffering PMU capability
perf/x86/intel/pt: Remove software double buffering PMU capability
Commit-ID: 72e830f68428ab9ea9eca65d160795f4e02cecfc Gitweb: https://git.kernel.org/tip/72e830f68428ab9ea9eca65d160795f4e02cecfc Author: Alexander Shishkin <[email protected]> AuthorDate: Fri, 3 May 2019 11:55:36 +0300 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/events/intel/pt.c | 3 +-- include/linux/perf_event.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
arch/x86/events/intel/pt.c +1 -2
@@ -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;
include/linux/perf_event.h +0 -1
@@ -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