[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJhGHyCMx-8cUzJ=_cFb4YWNXT4=HANH4CUTNRVG38YG3oc7MQ@mail.gmail.com>
Date: Tue, 20 Mar 2018 18:04:59 +0800
From: Lai Jiangshan <jiangshanlai+lkml@...il.com>
To: Tejun Heo <tj@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Jann Horn <jannh@...gle.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Benjamin LaHaise <bcrl@...ck.org>,
Al Viro <viro@...iv.linux.org.uk>,
Kent Overstreet <kent.overstreet@...il.com>,
security@...nel.org, LKML <linux-kernel@...r.kernel.org>,
kernel-team@...com
Subject: Re: [PATCH 6/8] RCU, workqueue: Implement rcu_work
On Tue, Mar 20, 2018 at 12:45 AM, Tejun Heo <tj@...nel.org> wrote:
> Hello, Lai.
>
> On Fri, Mar 16, 2018 at 02:01:35PM +0800, Lai Jiangshan wrote:
>> > +bool flush_rcu_work(struct rcu_work *rwork)
>> > +{
>> > + if (test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&rwork->work))) {
>> > + rcu_barrier();
>> > + flush_work(&rwork->work);
>> > + return true;
>>
>> A possible tiny improvement: check if it was already queued on wq.
>> For example:
>>
>> if (test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&rwork->work))) {
>> if (!flush_work(&rwork->work)) {
>> rcu_barrier();
>> flush_work(&rwork->work);
>> }
>> return true;
>
> But this breaks the guarantee that flush_work waits for the latest
> queueing instance. Please consider the following scenario.
Oh, I'm sorry I was wrong. It is so evident that
"flush_work(&rwork->work) return true"
doesn't equals to "it has been queued on wq".
To detect if "it has been queued on wq" requires
a bunch of code. It is not worthy to complicate
this function.
>
>
> 1. rcu-work is queued
> 2. rcu-work starts executing
> 3. rcu-work is queued again
> 4. rcu-work is flushed
> 5. execution finishes
> 6. flush finishes
> 7. execution finishes
>
> 6 should happen after 7 but it didn't.
>
> Thanks.
>
> --
> tejun
Powered by blists - more mailing lists