Re: wake_up_process implied memory barrier clarification

2015-09-07 Thread Boqun Feng
Hi Oleg, On Mon, Sep 07, 2015 at 07:06:52PM +0200, Oleg Nesterov wrote: > Sorry for delay, > > On 09/02, Boqun Feng wrote: > > > > On Tue, Sep 01, 2015 at 06:39:23PM +0200, Oleg Nesterov wrote: > > > On 09/01, Boqun Feng wrote: > > > > > > > > On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nester

Re: wake_up_process implied memory barrier clarification

2015-09-07 Thread Oleg Nesterov
Sorry for delay, On 09/02, Boqun Feng wrote: > > On Tue, Sep 01, 2015 at 06:39:23PM +0200, Oleg Nesterov wrote: > > On 09/01, Boqun Feng wrote: > > > > > > On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nesterov wrote: > > > > > > > > And just in case, wake_up() differs in a sense that it doesn't

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Boqun Feng
On Tue, Sep 01, 2015 at 06:39:23PM +0200, Oleg Nesterov wrote: > On 09/01, Boqun Feng wrote: > > > > On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nesterov wrote: > > > > > > And just in case, wake_up() differs in a sense that it doesn't even need > > > that STORE-LOAD barrier in try_to_wake_up(),

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Oleg Nesterov
On 09/01, Boqun Feng wrote: > > On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nesterov wrote: > > > > And just in case, wake_up() differs in a sense that it doesn't even need > > that STORE-LOAD barrier in try_to_wake_up(), we can rely on > > wait_queue_head_t->lock. Assuming that wake_up() pairs

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Boqun Feng
On Tue, Sep 01, 2015 at 11:59:23AM +0200, Oleg Nesterov wrote: > On 09/01, Boqun Feng wrote: > > > > But I'm still a little confused at Oleg's words: > > > > "What is really important is that we have a barrier before we _read_ the > > task state." > > > > I read is as "What is really important is t

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Oleg Nesterov
On 09/01, Boqun Feng wrote: > > But I'm still a little confused at Oleg's words: > > "What is really important is that we have a barrier before we _read_ the > task state." > > I read is as "What is really important is that we have a barrier before > we _read_ the task state and _after_ we write th

Re: wake_up_process implied memory barrier clarification

2015-09-01 Thread Oleg Nesterov
On 08/31, Paul E. McKenney wrote: > > On Mon, Aug 31, 2015 at 08:33:35PM +0200, Oleg Nesterov wrote: > > On 08/31, Boqun Feng wrote: > > > > > > Fair enough, I went too far. How about just a single paragraph saying > > > that: > > > > > > The wake_up(), wait_event() and their friends have proper ba

Re: wake_up_process implied memory barrier clarification

2015-08-31 Thread Paul E. McKenney
On Tue, Sep 01, 2015 at 11:40:14AM +0800, Boqun Feng wrote: > Hi Paul, > > On Mon, Aug 31, 2015 at 01:37:39PM -0700, Paul E. McKenney wrote: > > On Mon, Aug 31, 2015 at 08:33:35PM +0200, Oleg Nesterov wrote: > > > On 08/31, Boqun Feng wrote: > > > > > > > > Fair enough, I went too far. How about j

Re: wake_up_process implied memory barrier clarification

2015-08-31 Thread Boqun Feng
Hi Paul, On Mon, Aug 31, 2015 at 01:37:39PM -0700, Paul E. McKenney wrote: > On Mon, Aug 31, 2015 at 08:33:35PM +0200, Oleg Nesterov wrote: > > On 08/31, Boqun Feng wrote: > > > > > > Fair enough, I went too far. How about just a single paragraph saying > > > that: > > > > > > The wake_up(), wait_

Re: wake_up_process implied memory barrier clarification

2015-08-31 Thread Paul E. McKenney
On Mon, Aug 31, 2015 at 08:33:35PM +0200, Oleg Nesterov wrote: > On 08/31, Boqun Feng wrote: > > > > Fair enough, I went too far. How about just a single paragraph saying > > that: > > > > The wake_up(), wait_event() and their friends have proper barriers in > > them, but these implicity barriers a

Re: wake_up_process implied memory barrier clarification

2015-08-31 Thread Oleg Nesterov
On 08/31, Boqun Feng wrote: > > Fair enough, I went too far. How about just a single paragraph saying > that: > > The wake_up(), wait_event() and their friends have proper barriers in > them, but these implicity barriers are only for the correctness for > sleep and wakeup. So don't rely on these ba

Re: wake_up_process implied memory barrier clarification

2015-08-30 Thread Boqun Feng
Hi Oleg, On Sat, Aug 29, 2015 at 04:27:07PM +0200, Oleg Nesterov wrote: > Hello Boqun, > ... > > By this, I think you actually means the example below the added text, > > i.e. the example for "to repeat..", right? > > And above. Even > > The barrier occurs before the task state is cleared

Re: wake_up_process implied memory barrier clarification

2015-08-29 Thread Oleg Nesterov
Hello Boqun, On 08/29, Boqun Feng wrote: > Hi Oleg > > On Fri, Aug 28, 2015 at 06:06:37PM +0200, Oleg Nesterov wrote: > > On 08/28, Michal Hocko wrote: > > > > > > On Thu 27-08-15 20:26:54, Oleg Nesterov wrote: > > > > On 08/27, Michal Hocko wrote: > > > > > > > > > > --- a/Documentation/memory-ba

Re: wake_up_process implied memory barrier clarification

2015-08-29 Thread Boqun Feng
Hi Oleg On Fri, Aug 28, 2015 at 06:06:37PM +0200, Oleg Nesterov wrote: > On 08/28, Michal Hocko wrote: > > > > On Thu 27-08-15 20:26:54, Oleg Nesterov wrote: > > > On 08/27, Michal Hocko wrote: > > > > > > > > --- a/Documentation/memory-barriers.txt > > > > +++ b/Documentation/memory-barriers.txt

Re: wake_up_process implied memory barrier clarification

2015-08-28 Thread Oleg Nesterov
On 08/28, Michal Hocko wrote: > > On Thu 27-08-15 20:26:54, Oleg Nesterov wrote: > > On 08/27, Michal Hocko wrote: > > > > > > --- a/Documentation/memory-barriers.txt > > > +++ b/Documentation/memory-barriers.txt > > > @@ -2031,6 +2031,9 @@ something up. The barrier occurs before the task > > > s

Re: wake_up_process implied memory barrier clarification

2015-08-28 Thread Michal Hocko
On Thu 27-08-15 20:26:54, Oleg Nesterov wrote: > On 08/27, Michal Hocko wrote: > > > > --- a/Documentation/memory-barriers.txt > > +++ b/Documentation/memory-barriers.txt > > @@ -2031,6 +2031,9 @@ something up. The barrier occurs before the task > > state is cleared, and so sits > >

Re: wake_up_process implied memory barrier clarification

2015-08-27 Thread Oleg Nesterov
On 08/27, Michal Hocko wrote: > > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -2031,6 +2031,9 @@ something up. The barrier occurs before the task state > is cleared, and so sits >STORE current->state > LOAD event_indicated >

Re: wake_up_process implied memory barrier clarification

2015-08-27 Thread Michal Hocko
On Thu 27-08-15 14:43:34, Peter Zijlstra wrote: > On Thu, Aug 27, 2015 at 02:27:27PM +0200, Michal Hocko wrote: > > Hi, > > I have just stumbled over the comment above wake_up_process which > > claims: > > " > > * It may be assumed that this function implies a write memory barrier > > before > >

Re: wake_up_process implied memory barrier clarification

2015-08-27 Thread Peter Zijlstra
On Thu, Aug 27, 2015 at 02:27:27PM +0200, Michal Hocko wrote: > Hi, > I have just stumbled over the comment above wake_up_process which > claims: > " > * It may be assumed that this function implies a write memory barrier before > * changing the task state if and only if any tasks are woken up. >