]> bbs.cooldavid.org Git - net-next-2.6.git/commit
sched: fair-group: fix a Div0 error of the fair group scheduler
authorMiao Xie <miaox@cn.fujitsu.com>
Mon, 28 Apr 2008 04:54:56 +0000 (12:54 +0800)
committerIngo Molnar <mingo@elte.hu>
Mon, 5 May 2008 21:56:18 +0000 (23:56 +0200)
commitcb4ad1ffc7c0d8ea7dc8cd8ba303d83551716d46
tree79f6b1fe971a270e5e009d695d2bf998936197c8
parent712555ee4f873515612f89554ad1a3fda5fa887e
sched: fair-group: fix a Div0 error of the fair group scheduler

When I echoed 0 into the "cpu.shares" file, a Div0 error occured.

We found it is caused by the following calling.

   sched_group_set_shares(tg, shares)
       set_se_shares(tg->se[i], shares/nr_cpu_ids)
           __set_se_shares(se, shares)
               div64_64((1ULL<<32), shares)

When the echoed value was less than the number of processores, the result of the
sentence "shares/nr_cpu_ids" was 0, and then the system called div64() to divide
the result, the Div0 error occured.

It is unnecessary that the shares value is divided by nr_cpu_ids, I think.
Because in the function  __update_group_shares_cpu() and init_tg_cfs_entry(),
the shares value isn't divided by nr_cpu_ids when setting shares of the sched
entity.

This patch fixes this bug. And echoing ULONG_MAX value into cpu.shares also
causes Div0 error, so we set a macro MAX_SHARES to limit the max value of
shares.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/sched.c