lkml.org 
[lkml]   [2012]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [RFC PATCH 5/5 single-thread-version] implement per-domain single-thread state machine call_srcu()
    From
    Date
    On Wed, 2012-03-07 at 11:54 +0800, Lai Jiangshan wrote:
    > +static void srcu_advance_batches(struct srcu_struct *sp)
    > +{
    > + int idx = 1 - (sp->completed & 0x1UL);
    > +
    > + /*
    > + * SRCU read-side critical sections are normally short, so check
    > + * twice after a flip.
    > + */
    > + if (!rcu_batch_empty(&sp->batch_check1) ||
    > + !rcu_batch_empty(&sp->batch_check0)) {
    > + if (try_check_zero(sp, idx, 1)) {
    > + rcu_batch_move(&sp->batch_done, &sp->batch_check1);
    > + rcu_batch_move(&sp->batch_check1, &sp->batch_check0);
    > + if (!rcu_batch_empty(&sp->batch_check1)) {
    > + srcu_flip(sp);
    > + if (try_check_zero(sp, 1 - idx, 2)) {
    > + rcu_batch_move(&sp->batch_done,
    > + &sp->batch_check1);
    > + }
    > + }
    > + }
    > + }
    > +}

    static void srcu_advance_batches(struct srcu_struct *sp)
    {
    int idx = 1 - (sp->completed & 1);

    if (rcu_batch_empty(&sp->batch_check0) &&
    rcu_batch_empty(&sp->batch_check1))
    return;

    if (!try_check_zero(sp, idx, 1))
    return;

    rcu_batch_move(&sp->batch_done, &sp->batch_check1);
    rcu_batch_move(&sp->batch_check1, &sp->batch_check0);

    if (rcu_batch_empty(&sp->batch_check1))
    return;

    srcu_flip(sp);

    if (!try_check_zero(sp, idx^1, 2))
    return;

    rcu_batch_move(&sp->batch_done, &sp->batch_check1);
    }

    Seems like a more readable version.. do check I didn't mess up the logic
    though.


    \
     
     \ /
      Last update: 2012-03-08 14:07    [W:4.102 / U:0.196 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site