diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 561b3b39bdb8..f98f75f3c708 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -321,7 +321,13 @@ static DEFINE_SPINLOCK(task_group_lock); | |||
321 | # define INIT_TASK_GROUP_LOAD NICE_0_LOAD | 321 | # define INIT_TASK_GROUP_LOAD NICE_0_LOAD |
322 | #endif | 322 | #endif |
323 | 323 | ||
324 | /* | ||
325 | * A weight of 0, 1 or ULONG_MAX can cause arithmetics problems. | ||
326 | * (The default weight is 1024 - so there's no practical | ||
327 | * limitation from this.) | ||
328 | */ | ||
324 | #define MIN_SHARES 2 | 329 | #define MIN_SHARES 2 |
330 | #define MAX_SHARES (ULONG_MAX - 1) | ||
325 | 331 | ||
326 | static int init_task_group_load = INIT_TASK_GROUP_LOAD; | 332 | static int init_task_group_load = INIT_TASK_GROUP_LOAD; |
327 | #endif | 333 | #endif |
@@ -1804,6 +1810,8 @@ __update_group_shares_cpu(struct task_group *tg, struct sched_domain *sd, | |||
1804 | 1810 | ||
1805 | if (shares < MIN_SHARES) | 1811 | if (shares < MIN_SHARES) |
1806 | shares = MIN_SHARES; | 1812 | shares = MIN_SHARES; |
1813 | else if (shares > MAX_SHARES) | ||
1814 | shares = MAX_SHARES; | ||
1807 | 1815 | ||
1808 | __set_se_shares(tg->se[tcpu], shares); | 1816 | __set_se_shares(tg->se[tcpu], shares); |
1809 | } | 1817 | } |
@@ -8785,13 +8793,10 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares) | |||
8785 | if (!tg->se[0]) | 8793 | if (!tg->se[0]) |
8786 | return -EINVAL; | 8794 | return -EINVAL; |
8787 | 8795 | ||
8788 | /* | ||
8789 | * A weight of 0 or 1 can cause arithmetics problems. | ||
8790 | * (The default weight is 1024 - so there's no practical | ||
8791 | * limitation from this.) | ||
8792 | */ | ||
8793 | if (shares < MIN_SHARES) | 8796 | if (shares < MIN_SHARES) |
8794 | shares = MIN_SHARES; | 8797 | shares = MIN_SHARES; |
8798 | else if (shares > MAX_SHARES) | ||
8799 | shares = MAX_SHARES; | ||
8795 | 8800 | ||
8796 | mutex_lock(&shares_mutex); | 8801 | mutex_lock(&shares_mutex); |
8797 | if (tg->shares == shares) | 8802 | if (tg->shares == shares) |
@@ -8816,7 +8821,7 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares) | |||
8816 | * force a rebalance | 8821 | * force a rebalance |
8817 | */ | 8822 | */ |
8818 | cfs_rq_set_shares(tg->cfs_rq[i], 0); | 8823 | cfs_rq_set_shares(tg->cfs_rq[i], 0); |
8819 | set_se_shares(tg->se[i], shares/nr_cpu_ids); | 8824 | set_se_shares(tg->se[i], shares); |
8820 | } | 8825 | } |
8821 | 8826 | ||
8822 | /* | 8827 | /* |