aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-01-22 05:24:58 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-22 05:24:58 -0500
commitc61935fd0e7f087a643827b4bf5ef646963c10fa (patch)
tree4bfa925404acd5e5ecb6a3e597ab689415ac35e6 /kernel/sched.c
parentd384e35a25445bb60457b7dab8cffe178c6b7ecb (diff)
sched: group scheduler, set uid share fix
setting cpu share to 1 causes hangs, as reported in: http://bugzilla.kernel.org/show_bug.cgi?id=9779 as the default share is 1024, the values of 0 and 1 can indeed cause problems. Limit it to 2 or higher values. These values can only be set by the root user - but still it makes sense to protect against nonsensical values. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 37cf07aa4164..e76b11ca6df3 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7153,6 +7153,14 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
7153{ 7153{
7154 int i; 7154 int i;
7155 7155
7156 /*
7157 * A weight of 0 or 1 can cause arithmetics problems.
7158 * (The default weight is 1024 - so there's no practical
7159 * limitation from this.)
7160 */
7161 if (shares < 2)
7162 shares = 2;
7163
7156 spin_lock(&tg->lock); 7164 spin_lock(&tg->lock);
7157 if (tg->shares == shares) 7165 if (tg->shares == shares)
7158 goto done; 7166 goto done;