lkml.org 
[lkml]   [2011]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH,RFC] perf: panic due to inclied cpu context task_ctx value
    From
    Date
    On Wed, 2011-03-30 at 17:32 +0200, Oleg Nesterov wrote:
    > probably smp_mb__after_atomic_inc() needs a comment...
    >
    > It is needed to avoid the race between perf_sched_events_dec() and
    > perf_sched_events_inc().
    >
    > Suppose that we have a single event, both counters == 1. We create
    > another event and call perf_sched_events_inc(). Without the barrier
    > we could increment the counters in reverse order,
    >
    > jump_label_inc(&perf_sched_events_in);
    > /* ---- WINDOW ---- */
    > jump_label_inc(&perf_sched_events_out);
    >
    > Now, if perf_sched_events_dec() is called in between, it can disable
    > _out but not _in. This means we can leak ->task_ctx again.

    But in that case we need an mb in perf_sched_events_dec() too, because
    for the !JUMP_LABEL case that's a simple atomic_dec() and combined with
    synchronize_sched() being a nop for num_online_cpus()==1 there's no
    ordering there either.

    Also, wouldn't this then require an smp_rmb() in the
    perf_event_task_sched_{in,out} COND_STMT/JUMP_LABEL read side?



    \
     
     \ /
      Last update: 2011-03-30 18:15    [W:0.023 / U:30.164 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site