public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: mingo@elte.hu, dhaval@linux.vnet.ibm.com,
	vatsa@linux.vnet.ibm.com, cfriesen@nortel.com
Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 2/2] sched: group nice
Date: Wed, 10 Dec 2008 20:40:50 +0100	[thread overview]
Message-ID: <20081210194255.370293849@chello.nl> (raw)
In-Reply-To: 20081210194048.464111787@chello.nl

[-- Attachment #1: sched-group-nice.patch --]
[-- Type: text/plain, Size: 1769 bytes --]

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
 	{

-- 


  parent reply	other threads:[~2008-12-10 19:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10 19:40 [PATCH 0/2] sched: task group weight interface Peter Zijlstra
2008-12-10 19:40 ` [PATCH 1/2] sched: tg->weight Peter Zijlstra
2008-12-10 19:40 ` Peter Zijlstra [this message]
2008-12-12  9:31 ` [PATCH 0/2] sched: task group weight interface Ingo Molnar
2008-12-14  4:58   ` [RESEND][PATCH]: sched: Fix compile errors introduced by new group scheduler interface Dhaval Giani
2009-01-12 15:14 ` [PATCH 0/2] sched: task group weight interface Dhaval Giani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081210194255.370293849@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=cfriesen@nortel.com \
    --cc=dhaval@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=vatsa@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox