sched/loadavg: Use {READ,WRITE}_ONCE() for sample window
authorMatt Fleming <matt@codeblueprint.co.uk>
Fri, 17 Feb 2017 12:07:31 +0000 (12:07 +0000)
committerIngo Molnar <mingo@kernel.org>
Thu, 16 Mar 2017 08:21:01 +0000 (09:21 +0100)
commitcaeb5882979bc6f3c8766fcf59c6269b38f521bc
treeee5e0c30b3ecfd99651f74ffd1403db8ac530280
parent6e5f32f7a43f45ee55c401c0b9585eb01f9629a8
sched/loadavg: Use {READ,WRITE}_ONCE() for sample window

'calc_load_update' is accessed without any kind of locking and there's
a clear assumption in the code that only a single value is read or
written.

Make this explicit by using READ_ONCE() and WRITE_ONCE(), and avoid
unintentionally seeing multiple values, or having the load/stores
split.

Technically the loads in calc_global_*() don't require this since
those are the only functions that update 'calc_load_update', but I've
added the READ_ONCE() for consistency.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: Morten Rasmussen <morten.rasmussen@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Link: http://lkml.kernel.org/r/20170217120731.11868-3-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/loadavg.c