lkml.org 
[lkml]   [2017]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 13/17] perf: Re-inject shmem buffers after exec
Date
A exec will unmap everything, but we want our shmem buffers to persist.
This tells the page-pinning task work to mmap event's ring buffer after
the task exec'ed.

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

diff --git a/kernel/events/core.c b/kernel/events/core.c
index e00f1f6aaf..f0b77b33b4 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6482,6 +6482,29 @@ static void perf_event_addr_filters_exec(struct perf_event *event, void *data)
perf_event_stop(event, 1);
}

+static void perf_shmem_ctx_exec(struct perf_event_context *ctx)
+{
+ struct perf_event *event;
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&ctx->lock, flags);
+
+ list_for_each_entry(event, &ctx->event_list, event_entry) {
+ if (event->attach_state & PERF_ATTACH_SHMEM) {
+ struct ring_buffer *rb;
+
+ /* called inside rcu read section */
+ rb = rcu_dereference(event->rb);
+ if (!rb)
+ continue;
+
+ rb->shmem_file_addr = 0;
+ }
+ }
+
+ raw_spin_unlock_irqrestore(&ctx->lock, flags);
+}
+
void perf_event_exec(void)
{
struct perf_event_context *ctx;
@@ -6497,6 +6520,7 @@ void perf_event_exec(void)

perf_iterate_ctx(ctx, perf_event_addr_filters_exec, NULL,
true);
+ perf_shmem_ctx_exec(ctx);
}
rcu_read_unlock();
}
--
2.14.1
\
 
 \ /
  Last update: 2017-09-05 15:51    [W:0.144 / U:4.728 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site