--- kernel/sched.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) Index: linux-2.6/kernel/sched.c =================================================================== --- linux-2.6.orig/kernel/sched.c +++ linux-2.6/kernel/sched.c @@ -8494,6 +8494,30 @@ unsigned long sched_group_shares(struct { return inv_WLS(tg->weight); } + +int sched_group_set_nice(struct task_group *tg, int nice) +{ + unsigned int prio = nice + 20; + + if (prio > ARRAY_SIZE(prio_to_weight)) + return -EINVAL; + + sched_group_set_shares(tg, prio_to_weight[prio]); + return 0; +} + +int sched_group_nice(struct task_group *tg) +{ + unsigned long weight = sched_group_shares(tg); + int prio; + + for (prio = 0; prio < ARRAY_SIZE(prio_to_weight); prio++) + if (prio_to_weight[prio] <= weight) + break; + + return prio - 20; +} + #endif #ifdef CONFIG_RT_GROUP_SCHED @@ -8787,6 +8811,17 @@ static u64 cpu_shares_read_u64(struct cg { return (u64) sched_group_shares(cgroup_tg(cgrp)); } + +static int cpu_nice_write(struct cgroup *cgrp, struct cftype *cftype, + s64 niceval) +{ + return sched_group_set_nice(cgroup_tg(cgrp), niceval); +} + +static s64 cpu_nice_read(struct cgroup *cgrp, struct cftype *cftype) +{ + return sched_group_nice(cgroup_tg(cgrp)); +} #endif #ifdef CONFIG_RT_GROUP_SCHED @@ -8820,6 +8855,11 @@ static struct cftype cpu_files[] = { .read_u64 = cpu_shares_read_u64, .write_u64 = cpu_shares_write_u64, }, + { + .name = "nice", + .read_s64 = cpu_nice_read, + .write_s64 = cpu_nice_write, + }, #endif #ifdef CONFIG_RT_GROUP_SCHED {