aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-12-09 03:32:03 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-09 04:01:07 -0500
commitdba091b9e3522b9d32fc9975e48d3b69633b45f0 (patch)
tree91549e3921971b6d0074fd34c29223b593381c8a /kernel/sched.c
parent3160568371da441b7f2fb57f2f1225404207e8f2 (diff)
sched: Protect sched_rr_get_param() access to task->sched_class
sched_rr_get_param calls task->sched_class->get_rr_interval(task) without protection against a concurrent sched_setscheduler() call which modifies task->sched_class. Serialize the access with task_rq_lock(task) and hand the rq pointer into get_rr_interval() as it's needed at least in the sched_fair implementation. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <alpine.LFD.2.00.0912090930120.3089@localhost.localdomain> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index c4635f74540..68db5a2e654 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6887,6 +6887,8 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
6887{ 6887{
6888 struct task_struct *p; 6888 struct task_struct *p;
6889 unsigned int time_slice; 6889 unsigned int time_slice;
6890 unsigned long flags;
6891 struct rq *rq;
6890 int retval; 6892 int retval;
6891 struct timespec t; 6893 struct timespec t;
6892 6894
@@ -6903,7 +6905,9 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
6903 if (retval) 6905 if (retval)
6904 goto out_unlock; 6906 goto out_unlock;
6905 6907
6906 time_slice = p->sched_class->get_rr_interval(p); 6908 rq = task_rq_lock(p, &flags);
6909 time_slice = p->sched_class->get_rr_interval(rq, p);
6910 task_rq_unlock(rq, &flags);
6907 6911
6908 read_unlock(&tasklist_lock); 6912 read_unlock(&tasklist_lock);
6909 jiffies_to_timespec(time_slice, &t); 6913 jiffies_to_timespec(time_slice, &t);