lkml.org 
[lkml]   [2008]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] sched: group nice
allow to use nice values to set group weights

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/sched.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -8558,6 +8558,17 @@ static inline void unregister_fair_sched
{
list_del_rcu(&tg->cfs_rq[cpu]->leaf_cfs_rq_list);
}
+
+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));
+}
#else /* !CONFG_FAIR_GROUP_SCHED */
static inline void free_fair_sched_group(struct task_group *tg)
{
@@ -8867,6 +8878,29 @@ unsigned long sched_group_weight(struct
{
return tg->weight;
}
+
+static 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_weight(tg, prio_to_weight[prio]);
+ return 0;
+}
+
+static int sched_group_nice(struct task_group *tg)
+{
+ unsigned long weight = sched_group_weight(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
@@ -9233,6 +9267,11 @@ static struct cftype cpu_files[] = {
.read_u64 = cpu_weight_read_u64,
.write_u64 = cpu_weight_write_u64,
},
+ {
+ .name = "nice",
+ .read_s64 = cpu_nice_read,
+ .write_s64 = cpu_nice_write,
+ },
#endif
#ifdef CONFIG_RT_GROUP_SCHED
{
--



\
 
 \ /
  Last update: 2008-12-10 20:47    [W:0.060 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site