From: Tejun Heo <htejun@gmail.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
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: Wed, 16 May 2007 13:25:59 +0200 [thread overview]
Message-ID: <464AEA47.7030600@gmail.com> (raw)
In-Reply-To: <20070515220024.GA615@tv-sign.ru>
Hello, Oleg.
Oleg Nesterov wrote:
>>> Yes? I need to think more about this.
>> I don't think the test for PENDING should be atomic too. cwq pointer
>> and VALID is one package. PENDING lives its own life as a atomic bit
>> switch.
>
> Yes sure, it should not be atomic. But (VALID && !PENDING) == BUG, so we
> can't just "kill" PENDING form the check above.
We can also mask it out, which is about the same as what we're currently
doing. :-)
>>> Memory operations that occur before a LOCK operation may appear to happen
>>> after it completes.
>> Which means that spin_lock() isn't a write barrier.
>
> yes, it is not very clear which "Memory operations" memory-barriers.txt
> describes.
>
>> lock is read
>> barrier, unlock is write barrier.
>
> (To avoid a possible confusion: I am not arguing, I am trying to understand,
> and please also note "in _theory_" above)
>
> Is it so? Shoudn't we document this if it is true?
>
>> Otherwise, locking doesn't make much
>> sense.
>
> Why? Could you please give a code example we have which relies on this?
Let's say there's a shared data structure protected by a spinlock and
two threads are accessing it.
1. thr1 locks spin
2. thr1 updates data structure
3. thr1 unlocks spin
4. thr2 locks spin
5. thr2 accesses data structure
6. thr2 unlocks spin
If spin_unlock is not a write barrier and spin_lock is not a read
barrier, nothing guarantees memory accesses from step#5 will see the
changes made in step#2. Memory fetch can occur during updates in step#2
or even before that.
In _theory_, if you have, say, partial/blocked memory barrier thing
which acts as a barrier to certain range of memory accesses, in this
case memory accesses made while holding spinlock, they don't have to be
real memory barriers but AFAIK there isn't any. I don't think it's
practical to worry about such thing at this point. It's way too
theoretical. But, yes, it sure needs documentation.
>> If we're going the barrier way, I think we're better off with
>> explicit smp_wmb(). It's only barrier() on x86/64.
>
> Yes. But note that we don't have any reason to do set_wq_data() under
> cwq->lock (this is also true for wake_up(->more_work) btw), so it makes
> sense to do this change anyway. And "wmb + spin_lock" looks a bit strange,
> I _suspect_ spin_lock() means a full barrier on most platforms.
>
> Could you also look at
> http://marc.info/?t=116275561700001&r=1
>
> and, in particular,
> http://marc.info/?l=linux-kernel&m=116281136122456
This is because spin_lock() isn't a write barrier, right? I totally
agree with you there.
Thanks.
--
tejun
next prev parent reply other threads:[~2007-05-16 11:26 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-03 20:42 [PATCH] make cancel_rearming_delayed_work() reliable 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
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 [this message]
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=464AEA47.7030600@gmail.com \
--to=htejun@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dgc@sgi.com \
--cc=dhowells@redhat.com \
--cc=ego@in.ibm.com \
--cc=jarkao2@o2.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.