[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACvQF52uELYus6qSk0b_K=LRXByN1nr_ExSYojS02gY-yrdYSw@mail.gmail.com>
Date: Thu, 8 Mar 2012 22:17:44 +0800
From: Lai Jiangshan <eag0628@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Lai Jiangshan <laijs@...fujitsu.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org, mingo@...e.hu, dipankar@...ibm.com,
akpm@...ux-foundation.org, mathieu.desnoyers@...ymtl.ca,
josh@...htriplett.org, niv@...ibm.com, tglx@...utronix.de,
rostedt@...dmis.org, Valdis.Kletnieks@...edu, dhowells@...hat.com,
eric.dumazet@...il.com, darren@...art.com, fweisbec@...il.com,
patches@...aro.org
Subject: Re: [RFC PATCH 5/5 single-thread-version] implement per-domain
single-thread state machine call_srcu()
On Thu, Mar 8, 2012 at 9:04 PM, Peter Zijlstra <peterz@...radead.org> wrote:
> 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);
>> + }
>> + }
>> + }
>> + }
>> +}
>
Good, Thanks,
I'm thinking how to introduce the comments(original in __synchronize_srcu())
back. Your code will make it easier. (the comments are still needed to rewrite
before bring them back, need help!)
I will use your code with a little changed.
> static void srcu_advance_batches(struct srcu_struct *sp)
> {
> int idx = 1 - (sp->completed & 1);
(sp->completed & 1) ^ 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 (rcu_batch_empty(&sp->batch_check0))
return;
srcu_flip(sp);
rcu_batch_move(&sp->batch_check1, &sp->batch_check0);
make it match the changlog:
3) ->batch_check1 after finish its first check_zero and the flip
>
> 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.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists