summaryrefslogtreecommitdiffstats
path: root/kernel/posix-cpu-timers.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2010-03-05 13:42:54 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 11:26:33 -0800
commit78d7d407b62a021e6d2e8dc24c0b90e390ab58a1 (patch)
tree8c1074b84db4b977bad6802a3701e0113c0a7739 /kernel/posix-cpu-timers.c
parentd4bb527438b4181cd3c564ae04dd344c381283a1 (diff)
downloadlinux-stable-78d7d407b62a021e6d2e8dc24c0b90e390ab58a1.tar.gz
linux-stable-78d7d407b62a021e6d2e8dc24c0b90e390ab58a1.tar.bz2
linux-stable-78d7d407b62a021e6d2e8dc24c0b90e390ab58a1.zip
kernel core: use helpers for rlimits
Make sure compiler won't do weird things with limits. E.g. fetching them twice may return 2 different values after writable limits are implemented. I.e. either use rlimit helpers added in commit 3e10e716abf3 ("resource: add helpers for fetching rlimits") or ACCESS_ONCE if not applicable. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: john stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r--kernel/posix-cpu-timers.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index dbb16bf15c45..1a22dfd42df9 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -1031,9 +1031,10 @@ static void check_thread_timers(struct task_struct *tsk,
/*
* Check for the special case thread timers.
*/
- soft = sig->rlim[RLIMIT_RTTIME].rlim_cur;
+ soft = ACCESS_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_cur);
if (soft != RLIM_INFINITY) {
- unsigned long hard = sig->rlim[RLIMIT_RTTIME].rlim_max;
+ unsigned long hard =
+ ACCESS_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
if (hard != RLIM_INFINITY &&
tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
@@ -1194,10 +1195,11 @@ static void check_process_timers(struct task_struct *tsk,
SIGPROF);
check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime,
SIGVTALRM);
- soft = sig->rlim[RLIMIT_CPU].rlim_cur;
+ soft = ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
if (soft != RLIM_INFINITY) {
unsigned long psecs = cputime_to_secs(ptime);
- unsigned long hard = sig->rlim[RLIMIT_CPU].rlim_max;
+ unsigned long hard =
+ ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
cputime_t x;
if (psecs >= hard) {
/*