mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srivatsa Vaddagiri <vatsa@in.ibm.com>
To: Ingo Molnar <mingo@elte.hu>, Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Sam Vilain <sam@vilain.net>,
	linux-kernel@vger.kernel.org, Kirill Korotaev <dev@openvz.org>,
	Mike Galbraith <efault@gmx.de>, Balbir Singh <balbir@in.ibm.com>,
	sekharan@us.ibm.com, Andrew Morton <akpm@osdl.org>,
	nagar@watson.ibm.com, haveblue@us.ibm.com, pj@sgi.com
Subject: [ RFC, PATCH 4/5 ] CPU controller - deal with dont care groups
Date: Fri, 4 Aug 2006 10:42:10 +0530	[thread overview]
Message-ID: <20060804051210.GH27194@in.ibm.com> (raw)
In-Reply-To: <20060804050753.GD27194@in.ibm.com>


Deal with task-groups whose bandwidth hasnt been explicitly set by the
administrator. Unallocated CPU bandwidth is equally distributed among such
"don't care" groups.

Signed-off-by : Srivatsa Vaddagiri <vatsa@in.ibm.com>


 include/linux/sched.h |    2 -
 kernel/sched.c        |   82 +++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 79 insertions(+), 5 deletions(-)

diff -puN kernel/sched.c~cpu_ctlr_handle_dont_cares kernel/sched.c
--- linux-2.6.18-rc3/kernel/sched.c~cpu_ctlr_handle_dont_cares	2006-08-04 08:20:53.000000000 +0530
+++ linux-2.6.18-rc3-root/kernel/sched.c	2006-08-04 08:31:38.000000000 +0530
@@ -227,6 +227,12 @@ static DEFINE_PER_CPU(struct task_grp_rq
 /* task-group object - maintains information about each task-group */
 struct task_grp {
 	int ticks;	/* bandwidth given to the task-group */
+	int left_over_pct;
+	int total_dont_care_grps;
+	int dont_care;          /* Does this group care for its bandwidth ? */
+	struct task_grp *parent;
+	struct list_head dont_care_list;
+	struct list_head list;
 	struct task_grp_rq *rq[NR_CPUS];   /* runqueue pointer for every cpu */
 };
 
@@ -6922,6 +6928,12 @@ void __init sched_init(void)
 	int i, j, k;
 
 	init_task_grp.ticks = -1;     /* Unlimited bandwidth */
+	init_task_grp.left_over_pct = 100;  /* 100% unallocated bandwidth */
+	init_task_grp.parent = NULL;
+	init_task_grp.total_dont_care_grps = 1;	/* init_task_grp itself */
+	init_task_grp.dont_care = 1;
+	INIT_LIST_HEAD(&init_task_grp.dont_care_list);
+	list_add_tail(&init_task_grp.list, &init_task_grp.dont_care_list);
 
 	for_each_possible_cpu(i) {
 		struct prio_array *array;
@@ -7076,10 +7088,33 @@ void set_curr_task(int cpu, struct task_
 
 #ifdef CONFIG_CPUMETER
 
+/* Distribute left over bandwidth equally to all "dont care" task groups */
+static void recalc_dontcare(struct task_grp *tg_root)
+{
+	int ticks;
+	struct list_head *entry;
+
+	if (!tg_root->total_dont_care_grps)
+		return;
+
+	ticks = ((tg_root->left_over_pct /
+			 tg_root->total_dont_care_grps) * 5 * HZ) / 100;
+
+	list_for_each(entry, &tg_root->dont_care_list) {
+		struct task_grp *tg;
+		int i;
+
+		tg = list_entry(entry, struct task_grp, list);
+		tg->ticks = ticks;
+		for_each_possible_cpu(i)
+			tg->rq[i]->ticks = tg->ticks;
+	}
+}
+
 /* Allocate runqueue structures for the new task-group */
-void *sched_alloc_group(void)
+void *sched_alloc_group(void *grp_parent)
 {
-	struct task_grp *tg;
+	struct task_grp *tg, *tg_parent = (struct task_grp *)grp_parent;
 	struct task_grp_rq *tgrq;
 	int i;
 
@@ -7088,6 +7123,11 @@ void *sched_alloc_group(void)
 		return NULL;
 
 	tg->ticks = -1;		/* No limit */
+	tg->parent = tg_parent;
+	tg->dont_care = 1;
+	tg->left_over_pct = 100;
+	tg->ticks = -1;		/* No limit */
+	INIT_LIST_HEAD(&tg->dont_care_list);
 
 	for_each_possible_cpu(i) {
 		tgrq = kzalloc(sizeof(*tgrq), GFP_KERNEL);
@@ -7097,6 +7137,15 @@ void *sched_alloc_group(void)
 		task_grp_rq_init(tgrq, tg->ticks);
 	}
 
+	if (tg->parent) {
+		tg->parent->total_dont_care_grps++;
+		list_add_tail(&tg->list, &tg->parent->dont_care_list);
+		recalc_dontcare(tg->parent);
+	} else {
+		tg->total_dont_care_grps = 1;
+		list_add_tail(&tg->list, &tg->dont_care_list);
+	}
+
 	return (void *)tg;
 oom:
 	while (i--)
@@ -7109,9 +7158,18 @@ oom:
 /* Deallocate runqueue structures */
 void sched_dealloc_group(void *grp)
 {
-	struct task_grp *tg = (struct task_grp *)grp;
+	struct task_grp *tg = (struct task_grp *)grp, *tg_root = tg->parent;
 	int i;
 
+	if (!tg_root)
+		tg_root = tg;
+
+	if (tg->dont_care) {
+		tg_root->total_dont_care_grps--;
+		list_del(&tg->list);
+		recalc_dontcare(tg_root);
+	}
+
 	for_each_possible_cpu(i)
 		kfree(tg->rq[i]);
 
@@ -7121,14 +7179,27 @@ void sched_dealloc_group(void *grp)
 /* Assign quota to this group */
 void sched_assign_quota(void *grp, int quota)
 {
-	struct task_grp *tg = (struct task_grp *)grp;
+	struct task_grp *tg = (struct task_grp *)grp, *tg_root = tg->parent;
+	int old_quota = 0;
 	int i;
 
+	if (!tg_root)
+		tg_root = tg;
+
+	if (tg->dont_care) {
+		tg->dont_care = 0;
+		tg_root->total_dont_care_grps--;
+		list_del(&tg->list);
+	} else
+		old_quota = (tg->ticks * 100) / (5 * HZ);
+
+	tg_root->left_over_pct -= (quota - old_quota);
 	tg->ticks = (quota * 5 * HZ) / 100;
 
 	for_each_possible_cpu(i)
 		tg->rq[i]->ticks = tg->ticks;
 
+	recalc_dontcare(tg_root);
 }
 
 /* Return assigned quota for this group */
@@ -7137,6 +7208,9 @@ int sched_get_quota(void *grp)
 	struct task_grp *tg = (struct task_grp *)grp;
 	int quota;
 
+	if (tg->dont_care)
+		 return 0;
+
 	quota = (tg->ticks * 100) / (5 * HZ);
 
 	return quota;
diff -puN include/linux/sched.h~cpu_ctlr_handle_dont_cares include/linux/sched.h
--- linux-2.6.18-rc3/include/linux/sched.h~cpu_ctlr_handle_dont_cares	2006-08-04 08:31:56.000000000 +0530
+++ linux-2.6.18-rc3-root/include/linux/sched.h	2006-08-04 08:32:07.000000000 +0530
@@ -1607,7 +1607,7 @@ static inline int try_to_freeze(void) { 
 
 #ifdef CONFIG_CPUMETER
 struct task_grp_ops {
-	void *(*alloc_group)(void);
+	void *(*alloc_group)(void *grp_parent);
 	void (*dealloc_group)(void *grp);
 	void (*assign_quota)(void *grp, int quota);
 	void (*move_task)(struct task_struct *tsk, void *old, void *new);

_
-- 
Regards,
vatsa
-- 
Regards,
vatsa

  parent reply	other threads:[~2006-08-04  5:07 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-04  5:07 [RFC, PATCH 0/5] Going forward with Resource Management - A cpu controller Srivatsa Vaddagiri
2006-08-04  5:09 ` [ RFC, PATCH 1/5 ] CPU controller - base changes Srivatsa Vaddagiri
2006-08-04  7:35   ` Andrew Morton
2006-08-04 11:18     ` Srivatsa Vaddagiri
2006-08-04 14:34   ` Kirill Korotaev
2006-08-04 14:50     ` Balbir Singh
2006-08-04 14:51     ` Srivatsa Vaddagiri
2006-08-04  5:10 ` [ RFC, PATCH 2/5 ] CPU controller - Define group operations Srivatsa Vaddagiri
2006-08-04 23:10   ` Jiri Slaby
2006-08-04  5:11 ` [ RFC, PATCH 3/5 ] CPU controller - deal with movement of tasks Srivatsa Vaddagiri
2006-08-04  5:12 ` Srivatsa Vaddagiri [this message]
2006-08-04  5:13 ` [ RFC, PATCH 5/5 ] CPU controller - interface with cpusets Srivatsa Vaddagiri
2006-08-04  5:36 ` [RFC, PATCH 0/5] Going forward with Resource Management - A cpu controller Andrew Morton
2006-08-04  5:42   ` Andrew Morton
2006-08-04  9:49     ` Alan Cox
2006-08-04 11:41       ` Srivatsa Vaddagiri
2006-08-04 14:51         ` Kirill Korotaev
2006-08-04 15:31           ` Srivatsa Vaddagiri
2006-08-04 16:03             ` Kirill Korotaev
2006-08-04 17:02               ` [ProbableSpam] " Shailabh Nagar
2006-08-04 18:27               ` Rohit Seth
2006-08-04 19:11                 ` Shailabh Nagar
2006-08-04 19:24                   ` Rohit Seth
2006-08-07  7:19                 ` Kirill Korotaev
2006-08-07 17:14                   ` Rohit Seth
2006-08-08  7:17                     ` Kirill Korotaev
2006-08-08 17:16                       ` Rohit Seth
2006-08-04 17:50           ` Martin Bligh
2006-08-07  7:25             ` Kirill Korotaev
2006-08-07 14:34               ` Martin J. Bligh
2006-08-07 16:33                 ` Kirill Korotaev
2006-08-07 18:31                   ` Rohit Seth
2006-08-07 18:43                     ` Dave Hansen
2006-08-07 19:00                       ` Rohit Seth
2006-08-07 19:46                         ` Martin Bligh
2006-08-08 14:19                           ` memory resource accounting (was Re: [RFC, PATCH 0/5] Going forward with Resource Management - A cpu controller) Nick Piggin
2006-08-08 14:57                             ` Dave Hansen
2006-08-08 15:22                               ` Nick Piggin
2006-08-09 13:43                                 ` Kirill Korotaev
2006-08-08 17:08                             ` Martin Bligh
2006-08-09  1:54                               ` Nick Piggin
2006-08-08 17:34                             ` Rohit Seth
2006-08-09  4:33                             ` Andi Kleen
2006-08-09  6:00                               ` Magnus Damm
2006-08-09  6:06                                 ` Andi Kleen
2006-08-09  6:56                             ` Andrey Savochkin
2006-08-08  7:19                     ` [RFC, PATCH 0/5] Going forward with Resource Management - A cpu controller Kirill Korotaev
2006-08-04 16:16         ` Kirill Korotaev
2006-08-04 16:49           ` [ProbableSpam] " Shailabh Nagar
2006-08-04 17:03             ` Dipankar Sarma
2006-08-04 18:17               ` Shailabh Nagar
2006-08-07  7:23               ` Kirill Korotaev
2006-08-04 14:57       ` Kirill Korotaev
2006-08-04  5:58   ` Paul Jackson
2006-08-04  6:02   ` Paul Jackson
2006-08-04  6:16     ` Paul Jackson
2006-08-04  6:20   ` Dipankar Sarma
2006-08-04  6:31     ` Paul Jackson
2006-08-04  6:37       ` Dipankar Sarma
2006-08-04  6:49         ` Andrew Morton
2006-08-04  6:45     ` Andrew Morton
2006-08-04  7:10       ` Dipankar Sarma
2006-08-04  7:24         ` Andrew Morton
2006-08-04 19:10       ` Chandra Seetharaman
2006-08-04  6:56   ` Srivatsa Vaddagiri
2006-08-04  7:13     ` Andrew Morton
2006-08-04 11:16       ` Srivatsa Vaddagiri
2006-08-04 18:51         ` Andrew Morton
2006-08-04 14:20   ` Kirill Korotaev
2006-08-04 14:35     ` Christoph Hellwig
2006-08-04 15:29     ` [ProbableSpam] " Shailabh Nagar
2006-08-07  7:29       ` Kirill Korotaev
2006-08-07  9:30         ` Paul Jackson
2006-08-07 15:58           ` Chandra Seetharaman
2006-08-07 16:10           ` Kirill Korotaev
2006-08-07 17:15             ` Paul Jackson
2006-08-07 18:19               ` Rohit Seth
2006-08-05  3:30   ` Nick Piggin

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=20060804051210.GH27194@in.ibm.com \
    --to=vatsa@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=balbir@in.ibm.com \
    --cc=dev@openvz.org \
    --cc=efault@gmx.de \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nagar@watson.ibm.com \
    --cc=nickpiggin@yahoo.com.au \
    --cc=pj@sgi.com \
    --cc=sam@vilain.net \
    --cc=sekharan@us.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

Powered by JetHome