mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@o2.pl>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Tejun Heo <htejun@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Chinner <dgc@sgi.com>, David Howells <dhowells@redhat.com>,
	Gautham Shenoy <ego@in.ibm.com>, 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: Fri, 18 May 2007 09:35:17 +0200	[thread overview]
Message-ID: <20070518073517.GB1573@ff.dom.local> (raw)
In-Reply-To: <20070516185203.GB81@tv-sign.ru>

On Wed, May 16, 2007 at 10:52:03PM +0400, Oleg Nesterov wrote:
...
> Ah, but this is something different. Both lock/unlock are full barriers,
> but they protect only one direction. A memory op must not leak out of the
> critical section, but it may leak in.
> 
> 	A = B;		// 1
> 	lock();		// 2
> 	C = D;		// 3
> 
> this can be re-ordered to
> 
> 	lock();		// 2
> 	C = D;		// 3
> 	A = B;		// 1
> 
> but 2 and 3 must not be re-ordered.
> 
> To be sure, I contacted Paul E. McKenney privately, and his reply is
> 
> 	> No.  See for example IA64 in file include/asm-ia64/spinlock.h,
> 	> line 34 for spin_lock() and line 92 for spin_unlock().  The
> 	> spin_lock() case uses a ,acq completer, which will allow preceding
> 	> reads to be reordered into the critical section.  The spin_unlock()
> 	> uses the ,rel completer, which will allow subsequent writes to be
> 	> reordered into the critical section.  The locking primitives are
> 	> guaranteed to keep accesses bound within the critical section, but
> 	> are free to let outside accesses be reordered into the critical
> 	> section.
> 	>
> 	> Download the Itanium Volume 2 manual:
> 	>
> 	>         http://developer.intel.com/design/itanium/manuals/245318.htm
> 	>
> 	> Table 2.3 on page 2:489 (physical page 509) shows an example of how
> 	> the rel and acq completers work.

Hi,

I managed to find some time to look at this all once more,
and here is my current opinion:

1. I think this above mentioned lock vs. barrier behavior is
in compliance with memory-barriers.txt, and BTW I'd like to
thank and congratulate David Howells of very good style
(and beautiful pictures).

2. IMHO the current solution with smp barriers is very good:
these barriers are really needed and they should be enough.
Oleg repeats all the time he hates barriers, but I think
it's wrong approach - they should be seen as something
natural for programming modern processors and trying to
change the code only to avoid them is wrong (unless it
could be done with some minor changes).

3. The alternative solution without barriers, based on the
idea of Tejun Heo and presented in the patch proposal from
2007-05-13, could be probably a little faster (for some
processors), after some changes:

- I think, instead of separate __set_bit and __clear_bit,
WORK_STRUCT_QUEUED bit should be changed during set_wq_data
(additional parameter or new variant eg: set_wq_data_queued),
and similarly something like  work_clear_pending_queued -
so, without additional operations instead of these barriers.

- changing this if condition in try_to_grab_pending.

But there is a question - is this worth of one (last) bit
occupied only for optimisation (but not always)?

So, maybe it would be better to think about solving those
other problems in workqueue, mentioned by Oleg somewhere?

Regards,
Jarek P.

  parent reply	other threads:[~2007-05-18  7:28 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
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 [this message]
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=20070518073517.GB1573@ff.dom.local \
    --to=jarkao2@o2.pl \
    --cc=akpm@linux-foundation.org \
    --cc=dgc@sgi.com \
    --cc=dhowells@redhat.com \
    --cc=ego@in.ibm.com \
    --cc=htejun@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome