: perf: Allocate mmap buffer using vmalloc_user().
PATCH 2/2 : perf: Allocate mmap buffer using vmalloc_user().
This is necessary to make the mmap ring buffer work properly on platforms where D-cache aliasing is an issue.
vmalloc_user() ensures that the kernel side mapping is SHMLBA aligned, and on platforms with D-cache aliasing matters the presence of VM_SHARED will similarly SHMLBA align the user side mapping.
Thus the kernel and the user will be writing to the same D-cache aliases and we'll avoid inconsistencies and corruption.
The only trick with this change is that vfree() cannot be invoked from interrupt context, and thus it's not allowed from RCU callbacks.
We deal with this by using schedule_work().
Since the ring buffer is now completely linear even on the kernel side, several simplifications are probably now possible in the code where we add entries to the ring.
With help from Peter Zijlstra.
--- include/linux/perf_counter.h | 1 + kernel/perf_counter.c | 70 ++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 32 deletions(-)
include/linux/perf_counter.h +1 -0
@@ -503,6 +503,7 @@ struct file;struct perf_mmap_data {struct rcu_head rcu_head; +struct work_struct work;int nr_pages;/* nr of data pages */ int writable;/* are we writable */ int nr_locked;/* nr pages mlocked */
kernel/perf_counter.c +38 -32
122 lines not on this page · raw message
Signature · 1 line
1.6.4.2