Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-17 Thread Ingo Molnar
* Jason Low wrote: > On Thu, 2015-04-16 at 20:24 +0200, Ingo Molnar wrote: > > Would it make sense to add a few comments to the seq field definition > > site(s), about how it's supposed to be accessed - or to the > > READ_ONCE()/WRITE_ONCE() sites, to keep people from wondering? > > How

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-17 Thread Ingo Molnar
* Jason Low jason.l...@hp.com wrote: On Thu, 2015-04-16 at 20:24 +0200, Ingo Molnar wrote: Would it make sense to add a few comments to the seq field definition site(s), about how it's supposed to be accessed - or to the READ_ONCE()/WRITE_ONCE() sites, to keep people from wondering?

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Jason Low
On Thu, 2015-04-16 at 20:24 +0200, Ingo Molnar wrote: > Would it make sense to add a few comments to the seq field definition > site(s), about how it's supposed to be accessed - or to the > READ_ONCE()/WRITE_ONCE() sites, to keep people from wondering? How about this: --- diff --git

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Jason Low
On Thu, 2015-04-16 at 20:15 +0200, Peter Zijlstra wrote: > On Thu, Apr 16, 2015 at 08:02:27PM +0200, Ingo Molnar wrote: > > > ACCESS_ONCE() is not a compiler barrier > > > > It's not a general compiler barrier (and I didn't claim so) but it is > > still a compiler barrier: it's documented as a

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Paul E. McKenney
On Thu, Apr 16, 2015 at 09:02:08PM +0200, Peter Zijlstra wrote: > On Thu, Apr 16, 2015 at 08:24:27PM +0200, Ingo Molnar wrote: > > Yes ... but that still leaves this weird feeling that it's really > > still a bit wrong because it's not proper parallel code, we just > > reduced the probability of

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Peter Zijlstra
On Thu, Apr 16, 2015 at 08:24:27PM +0200, Ingo Molnar wrote: > Yes ... but that still leaves this weird feeling that it's really > still a bit wrong because it's not proper parallel code, we just > reduced the probability of the remaining races radically. And it's not > like GCC (or any

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Ingo Molnar
* Peter Zijlstra wrote: > On Thu, Apr 16, 2015 at 08:02:27PM +0200, Ingo Molnar wrote: > > > ACCESS_ONCE() is not a compiler barrier > > > > It's not a general compiler barrier (and I didn't claim so) but it is > > still a compiler barrier: it's documented as a weak, variable specific > >

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Peter Zijlstra
On Thu, Apr 16, 2015 at 08:02:27PM +0200, Ingo Molnar wrote: > > ACCESS_ONCE() is not a compiler barrier > > It's not a general compiler barrier (and I didn't claim so) but it is > still a compiler barrier: it's documented as a weak, variable specific > barrier in

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Ingo Molnar
* Peter Zijlstra wrote: > On Wed, Apr 15, 2015 at 09:46:01AM +0200, Ingo Molnar wrote: > > > @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, > int pages, int flags) > > > > static void reset_ptenuma_scan(struct task_struct *p) > > { > > -

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Peter Zijlstra
On Wed, Apr 15, 2015 at 09:46:01AM +0200, Ingo Molnar wrote: > @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, > int pages, int flags) > > static void reset_ptenuma_scan(struct task_struct *p) > { > -ACCESS_ONCE(p->mm->numa_scan_seq)++; > +

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Peter Zijlstra
On Wed, Apr 15, 2015 at 09:46:01AM +0200, Ingo Molnar wrote: @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags) static void reset_ptenuma_scan(struct task_struct *p) { -ACCESS_ONCE(p-mm-numa_scan_seq)++; +

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Ingo Molnar
* Peter Zijlstra pet...@infradead.org wrote: On Wed, Apr 15, 2015 at 09:46:01AM +0200, Ingo Molnar wrote: @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags) static void reset_ptenuma_scan(struct task_struct *p) { -

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Peter Zijlstra
On Thu, Apr 16, 2015 at 08:24:27PM +0200, Ingo Molnar wrote: Yes ... but that still leaves this weird feeling that it's really still a bit wrong because it's not proper parallel code, we just reduced the probability of the remaining races radically. And it's not like GCC (or any compiler)

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Jason Low
On Thu, 2015-04-16 at 20:15 +0200, Peter Zijlstra wrote: On Thu, Apr 16, 2015 at 08:02:27PM +0200, Ingo Molnar wrote: ACCESS_ONCE() is not a compiler barrier It's not a general compiler barrier (and I didn't claim so) but it is still a compiler barrier: it's documented as a weak,

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Paul E. McKenney
On Thu, Apr 16, 2015 at 09:02:08PM +0200, Peter Zijlstra wrote: On Thu, Apr 16, 2015 at 08:24:27PM +0200, Ingo Molnar wrote: Yes ... but that still leaves this weird feeling that it's really still a bit wrong because it's not proper parallel code, we just reduced the probability of the

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Jason Low
On Thu, 2015-04-16 at 20:24 +0200, Ingo Molnar wrote: Would it make sense to add a few comments to the seq field definition site(s), about how it's supposed to be accessed - or to the READ_ONCE()/WRITE_ONCE() sites, to keep people from wondering? How about this: --- diff --git

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Peter Zijlstra
On Thu, Apr 16, 2015 at 08:02:27PM +0200, Ingo Molnar wrote: ACCESS_ONCE() is not a compiler barrier It's not a general compiler barrier (and I didn't claim so) but it is still a compiler barrier: it's documented as a weak, variable specific barrier in Documentation/memor-barriers.txt:

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-16 Thread Ingo Molnar
* Peter Zijlstra pet...@infradead.org wrote: On Thu, Apr 16, 2015 at 08:02:27PM +0200, Ingo Molnar wrote: ACCESS_ONCE() is not a compiler barrier It's not a general compiler barrier (and I didn't claim so) but it is still a compiler barrier: it's documented as a weak, variable

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Jason Low
Hi Ingo, On Wed, 2015-04-15 at 09:46 +0200, Ingo Molnar wrote: > * Steven Rostedt wrote: > > You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, > > and just a: > > > > p->mm->numa_scan_seq = READ_ONCE(p->numa_scan_seq) + 1; > > > > Can be done. But I'm still trying to

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Steven Rostedt
On Wed, 15 Apr 2015 19:29:01 -0700 Jason Low wrote: > On Tue, 2015-04-14 at 22:40 -0400, Steven Rostedt wrote: > > You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, > > and just a: > > > > p->mm->numa_scan_seq = READ_ONCE(p->numa_scan_seq) + 1; > > Just to confirm, is

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Jason Low
On Tue, 2015-04-14 at 22:40 -0400, Steven Rostedt wrote: > You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, > and just a: > > p->mm->numa_scan_seq = READ_ONCE(p->numa_scan_seq) + 1; Just to confirm, is this a typo? Because there really is a numa_scan_seq in the

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Steven Rostedt
On Wed, 15 Apr 2015 11:49:09 -0700 Jason Low wrote: > So I'll keep the READ_ONCE nested inside WRITE_ONCE for the purpose of > this patch since this patch is a conversion from ACCESS_ONCE, but yes, > if the original purpose of ACCESS_ONCE was to do an atomic increment, > then the ACCESS_ONCE

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Jason Low
On Wed, 2015-04-15 at 09:46 +0200, Ingo Molnar wrote: > * Steven Rostedt wrote: > > You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, > > and just a: > > > > p->mm->numa_scan_seq = READ_ONCE(p->numa_scan_seq) + 1; > > > > Can be done. But I'm still trying to wrap my

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Ingo Molnar
* Steven Rostedt wrote: > On Tue, 14 Apr 2015 19:12:33 -0700 > Jason Low wrote: > > > Hi Steven, > > > > On Tue, 2015-04-14 at 19:59 -0400, Steven Rostedt wrote: > > > On Tue, 14 Apr 2015 16:09:44 -0700 > > > Jason Low wrote: > > > > > > > > > > @@ -2088,7 +2088,7 @@ void

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Jason Low
On Wed, 2015-04-15 at 09:46 +0200, Ingo Molnar wrote: * Steven Rostedt rost...@goodmis.org wrote: You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, and just a: p-mm-numa_scan_seq = READ_ONCE(p-numa_scan_seq) + 1; Can be done. But I'm still trying to wrap my

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Steven Rostedt
On Wed, 15 Apr 2015 11:49:09 -0700 Jason Low jason.l...@hp.com wrote: So I'll keep the READ_ONCE nested inside WRITE_ONCE for the purpose of this patch since this patch is a conversion from ACCESS_ONCE, but yes, if the original purpose of ACCESS_ONCE was to do an atomic increment, then the

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Jason Low
On Tue, 2015-04-14 at 22:40 -0400, Steven Rostedt wrote: You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, and just a: p-mm-numa_scan_seq = READ_ONCE(p-numa_scan_seq) + 1; Just to confirm, is this a typo? Because there really is a numa_scan_seq in the task_struct

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Steven Rostedt
On Wed, 15 Apr 2015 19:29:01 -0700 Jason Low jason.l...@hp.com wrote: On Tue, 2015-04-14 at 22:40 -0400, Steven Rostedt wrote: You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, and just a: p-mm-numa_scan_seq = READ_ONCE(p-numa_scan_seq) + 1; Just to confirm,

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Jason Low
Hi Ingo, On Wed, 2015-04-15 at 09:46 +0200, Ingo Molnar wrote: * Steven Rostedt rost...@goodmis.org wrote: You are correct. Now I'm thinking that the WRITE_ONCE() is not needed, and just a: p-mm-numa_scan_seq = READ_ONCE(p-numa_scan_seq) + 1; Can be done. But I'm still trying

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-15 Thread Ingo Molnar
* Steven Rostedt rost...@goodmis.org wrote: On Tue, 14 Apr 2015 19:12:33 -0700 Jason Low jason.l...@hp.com wrote: Hi Steven, On Tue, 2015-04-14 at 19:59 -0400, Steven Rostedt wrote: On Tue, 14 Apr 2015 16:09:44 -0700 Jason Low jason.l...@hp.com wrote: @@ -2088,7

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Steven Rostedt
On Tue, 14 Apr 2015 19:12:33 -0700 Jason Low wrote: > Hi Steven, > > On Tue, 2015-04-14 at 19:59 -0400, Steven Rostedt wrote: > > On Tue, 14 Apr 2015 16:09:44 -0700 > > Jason Low wrote: > > > > > > > @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, > > > int pages,

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Jason Low
Hi Steven, On Tue, 2015-04-14 at 19:59 -0400, Steven Rostedt wrote: > On Tue, 14 Apr 2015 16:09:44 -0700 > Jason Low wrote: > > > > @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, > > int pages, int flags) > > > > static void reset_ptenuma_scan(struct task_struct

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Steven Rostedt
On Tue, 14 Apr 2015 16:09:44 -0700 Jason Low wrote: > @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int > pages, int flags) > > static void reset_ptenuma_scan(struct task_struct *p) > { > - ACCESS_ONCE(p->mm->numa_scan_seq)++; > +

[PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Jason Low
ACCESS_ONCE doesn't work reliably on non-scalar types. This patch removes the rest of the existing usages of ACCESS_ONCE in the scheduler, and use the new READ_ONCE and WRITE_ONCE APIs. Signed-off-by: Jason Low --- include/linux/sched.h |4 ++-- kernel/fork.c |

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Steven Rostedt
On Tue, 14 Apr 2015 16:09:44 -0700 Jason Low jason.l...@hp.com wrote: @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags) static void reset_ptenuma_scan(struct task_struct *p) { - ACCESS_ONCE(p-mm-numa_scan_seq)++; +

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Jason Low
Hi Steven, On Tue, 2015-04-14 at 19:59 -0400, Steven Rostedt wrote: On Tue, 14 Apr 2015 16:09:44 -0700 Jason Low jason.l...@hp.com wrote: @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags) static void reset_ptenuma_scan(struct

Re: [PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Steven Rostedt
On Tue, 14 Apr 2015 19:12:33 -0700 Jason Low jason.l...@hp.com wrote: Hi Steven, On Tue, 2015-04-14 at 19:59 -0400, Steven Rostedt wrote: On Tue, 14 Apr 2015 16:09:44 -0700 Jason Low jason.l...@hp.com wrote: @@ -2088,7 +2088,7 @@ void task_numa_fault(int last_cpupid, int

[PATCH 1/3] sched, timer: Remove usages of ACCESS_ONCE in the scheduler

2015-04-14 Thread Jason Low
ACCESS_ONCE doesn't work reliably on non-scalar types. This patch removes the rest of the existing usages of ACCESS_ONCE in the scheduler, and use the new READ_ONCE and WRITE_ONCE APIs. Signed-off-by: Jason Low jason.l...@hp.com --- include/linux/sched.h |4 ++-- kernel/fork.c