lkml.org 
[lkml]   [2013]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: BUG: using smp_processor_id() in preemptible [00000000] code: asm/8267
From
Date
On Wed, 2013-03-27 at 10:49 +0100, Borislav Petkov wrote:
> Ok, just for my own understanding: how do the events on the
> ->task_ctx->event_list relate to the current cpu in this path? I mean,
> we're on the task exit path here so is it possible to be rescheduled
> somewhere else and the check in event_filter_match to become
> meaningless?

Events can be per-cpu, so what could happen is that we'd send the exit
notification to a cpu we're not actually running on (anymore).

Furthermore, since we evaluate smp_processor_id() for every
event_filter_match(), it is possible we'd send the notification to
multiple events if our task migrates just right.

Also, I suspect we want something like preempt_disable_notrace() to be
sure we don't recurse or something daft like that... but I'm not
entirely sure.

---
kernel/events/core.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7b4a55d..0097d81 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4444,19 +4444,22 @@ static void perf_event_task_event(struct perf_task_event *task_event)
perf_event_task_ctx(&cpuctx->ctx, task_event);

ctx = task_event->task_ctx;
- if (!ctx) {
- ctxn = pmu->task_ctx_nr;
- if (ctxn < 0)
- goto next;
- ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
- if (ctx)
- perf_event_task_ctx(ctx, task_event);
- }
+ if (ctx)
+ goto next;
+ ctxn = pmu->task_ctx_nr;
+ if (ctxn < 0)
+ goto next;
+ ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
+ if (ctx)
+ perf_event_task_ctx(ctx, task_event);
next:
put_cpu_ptr(pmu->pmu_cpu_context);
}
- if (task_event->task_ctx)
+ if (task_event->task_ctx) {
+ preempt_disable_notrace();
perf_event_task_ctx(task_event->task_ctx, task_event);
+ preempt_enable_notrace();
+ }

rcu_read_unlock();
}



\
 
 \ /
  Last update: 2013-03-27 15:42    [W:0.079 / U:1.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site