From: Oleg Nesterov <oleg@tv-sign.ru>
To: Tejun Heo <htejun@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Chinner <dgc@sgi.com>, David Howells <dhowells@redhat.com>,
Gautham Shenoy <ego@in.ibm.com>, Jarek Poplawski <jarkao2@o2.pl>,
Ingo Molnar <mingo@elte.hu>,
Srivatsa Vaddagiri <vatsa@in.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] make cancel_rearming_delayed_work() reliable
Date: Mon, 14 May 2007 23:44:46 +0400 [thread overview]
Message-ID: <20070514194446.GA159@tv-sign.ru> (raw)
In-Reply-To: <46477239.9030007@gmail.com>
On 05/13, Tejun Heo wrote:
>
> Oleg Nesterov wrote:
> > Heh. I thought about another bit-in-pointer too. I can't explain this,
> > but I personally hate these bits even more than barriers.
>
> I'm the other way around but it's like saying "I like donkey poo better
> than horse poo". Let's accept that we have different tastes in poos.
Yes sure :)
> >> * run_workqueue() clears the cwq pointer and VALID bit while holding
> >> lock before executing the work.
> >
> > We should not clear cwq. I guess you meant "does list_del() and clears
> > VALID bit".
>
> Yeap, I've used the term 'clearing' as more of a logical term - making
> the pointer invalid, but is there any reason why we can't clear the
> pointer itself?
Because this breaks cancel_work_sync(work), it needs get_wq_data(work) for
wait_on_work(work).
> >> * try_to_grab_pending() checks VALID && pointers equal after grabbing
> >> cwq->lock.
> >
> > We don't even need to check the pointers. VALID bit is always changed
> > under cwq->lock. So, if we see VALID under cwq->lock, we have a right
> > pointer.
>
> But there are multiple cwq->lock's. VALID can be set with one of other
> cwq->lock's locked.
Yes, you are right, thanks.
So, try_to_grab_pending() should check "VALID && pointers equal" atomically.
We can't do "if (VALID && cwq == get_wq_data(work))". We should do something
like this
(((long)cwq) | VALID | PENDING) == atomic_long_read(&work->data)
Yes? I need to think more about this.
> I didn't really get the smp_mb__before_spinlock() thing. How are you
> planning to use it? spinlock() is already a read barrier. What do you
> gain by making it also a write barrier?
As I said, we can shift set_wq_data() from insert_work() to __queue_work(),
static void insert_work(struct cpu_workqueue_struct *cwq,
struct work_struct *work, int tail)
{
if (tail)
list_add_tail(&work->entry, &cwq->worklist);
else
list_add(&work->entry, &cwq->worklist);
wake_up(&cwq->more_work);
}
static void __queue_work(struct cpu_workqueue_struct *cwq,
struct work_struct *work)
{
unsigned long flags;
set_wq_data(work, cwq);
smp_mb_before_spinlock();
spin_lock_irqsave(&cwq->lock, flags);
insert_work(cwq, work, 1);
spin_unlock_irqrestore(&cwq->lock, flags);
}
this needs very minor changes.
BTW, in _theory_, spinlock() is not a read barrier, yes?
>From Documentation/memory-barriers.txt
Memory operations that occur before a LOCK operation may appear to happen
after it completes.
Oleg.
next prev parent reply other threads:[~2007-05-14 19:45 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-03 20:42 Oleg Nesterov
2007-05-04 1:15 ` Andrew Morton
2007-05-04 17:09 ` Oleg Nesterov
2007-05-05 21:32 ` [PATCH] make-cancel_rearming_delayed_work-reliable-fix Oleg Nesterov
2007-05-07 10:31 ` Jarek Poplawski
2007-05-07 10:34 ` Oleg Nesterov
2007-05-07 11:55 ` Anton Vorontsov
2007-05-07 11:33 ` Oleg Nesterov
2007-05-08 9:16 ` Jarek Poplawski
2007-05-08 12:02 ` Oleg Nesterov
2007-05-08 13:07 ` Jarek Poplawski
2007-05-08 7:15 ` [PATCH] make cancel_rearming_delayed_work() reliable Jarek Poplawski
2007-05-08 12:31 ` Oleg Nesterov
2007-05-08 13:56 ` Jarek Poplawski
2007-05-08 14:05 ` Oleg Nesterov
2007-05-08 14:32 ` Jarek Poplawski
2007-05-08 14:12 ` Jarek Poplawski
2007-05-11 13:55 ` Tejun Heo
2007-05-11 13:47 ` Oleg Nesterov
2007-05-11 15:19 ` Tejun Heo
2007-05-11 14:53 ` Oleg Nesterov
2007-05-12 5:50 ` Tejun Heo
2007-05-13 19:27 ` Oleg Nesterov
2007-05-13 20:16 ` Tejun Heo
2007-05-13 21:25 ` Oleg Nesterov
2007-05-14 19:44 ` Oleg Nesterov [this message]
2007-05-15 8:26 ` Tejun Heo
2007-05-15 13:09 ` Jarek Poplawski
2007-05-15 22:08 ` Oleg Nesterov
2007-05-16 5:21 ` Jarek Poplawski
2007-05-15 22:00 ` Oleg Nesterov
2007-05-16 11:25 ` Tejun Heo
2007-05-16 18:52 ` Oleg Nesterov
2007-05-17 9:36 ` Tejun Heo
2007-05-18 7:35 ` Jarek Poplawski
2007-05-18 8:13 ` Jarek Poplawski
2007-05-18 13:33 ` Tejun Heo
2007-05-21 7:00 ` Jarek Poplawski
2007-05-21 8:59 ` Tejun Heo
2007-05-21 10:10 ` Jarek Poplawski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070514194446.GA159@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@linux-foundation.org \
--cc=dgc@sgi.com \
--cc=dhowells@redhat.com \
--cc=ego@in.ibm.com \
--cc=htejun@gmail.com \
--cc=jarkao2@o2.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=vatsa@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®