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

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-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-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

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

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

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

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

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

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

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

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

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

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(),

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

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

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

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

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

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(),

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

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 is not

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: > > > > > > > > > > ---

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-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 @@ -2031,6

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-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 > > >

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-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 general barrier

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 state is cleared,

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.

wake_up_process implied memory barrier clarification

2015-08-27 Thread Michal Hocko
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. " but try_to_wake_up does smp_mb__before_spinlock and did smp_wmb since

wake_up_process implied memory barrier clarification

2015-08-27 Thread Michal Hocko
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. but try_to_wake_up does smp_mb__before_spinlock and did smp_wmb since

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 * changing the

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.

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 general barrier STORE current-state LOAD