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, matthltc@us.ibm.com, dipankar@in.ibm.com
Subject: [PATCH 3/7] CPU controller V1 - deal with movement of tasks
Date: Sun, 20 Aug 2006 23:14:42 +0530 [thread overview]
Message-ID: <20060820174442.GD13917@in.ibm.com> (raw)
In-Reply-To: <20060820174015.GA13917@in.ibm.com>
When a task moves between groups (as initiated by an administrator), it has to
be removed from the runqueue of its old group and added to the runqueue of its
new group. This patch defines this move operation.
Signed-off-by : Srivatsa Vaddagiri <vatsa@in.ibm.com>
include/linux/sched.h | 3 ++
kernel/sched.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff -puN kernel/sched.c~cpu_ctlr_move_task kernel/sched.c
--- linux-2.6.18-rc3/kernel/sched.c~cpu_ctlr_move_task 2006-08-20 21:56:09.000000000 +0530
+++ linux-2.6.18-rc3-root/kernel/sched.c 2006-08-20 21:57:36.000000000 +0530
@@ -7141,10 +7141,73 @@ int sched_get_quota(struct task_grp *tg)
return cpu_quota(tg);
}
+/*
+ * Move a task from one group to another. If the task is already on a
+ * runqueue, this involves removing the task from its old group's runqueue
+ * and adding to its new group's runqueue.
+ *
+ * This however is slightly tricky, given the facts that:
+ *
+ * - some pointer in the task struct (ex: cpuset) represents the group
+ * to which it belongs.
+ * - At any give point during the move operation, the pointer either
+ * points to the old group or to the new group, but not both!
+ * - dequeue_task/enqueue_task rely on this pointer to know which
+ * task_grp_rq the task is to be removed from/added to.
+ *
+ * Hence the dequeue_task/enqueue_task is accomplished in two steps.
+ *
+ * 1. In first step, sched_pre_move_task() is called with the group
+ * pointer set to the old group to which the task belonged.
+ * If the task was on a runqueue, sched_pre_move_task() merely
+ * removes it from the runqueue and returns 1 back to its
+ * caller indicating that step 2 is necessary.
+ *
+ * 2. In second step, sched_post_move_task() is called with the group
+ * pointer set to the new group to which the task belongs.
+ * sched_post_move_task() merely invokes __activate_task() to add the
+ * task in its new runqueue.
+ *
+ */
+
+static unsigned long irq_flags;
+
+int sched_pre_move_task(struct task_struct *tsk, struct task_grp *tg_old,
+ struct task_grp *tg_new)
+{
+ int activate = 0;
+ struct rq *rq;
+
+ if (tg_new == tg_old)
+ return 0;
+
+ rq = task_rq_lock(tsk, &irq_flags);
+
+ if (tsk->array) {
+ deactivate_task(tsk, rq);
+ activate = 1;
+ } else
+ task_rq_unlock(rq, &irq_flags);
+
+ return activate;
+}
+
+/* called with rq lock held */
+void sched_post_move_task(struct task_struct *tsk)
+{
+ struct rq *rq = task_rq(tsk);
+
+ __activate_task(tsk, rq);
+
+ task_rq_unlock(rq, &irq_flags);
+}
+
static struct task_grp_ops sched_grp_ops = {
.alloc_group = sched_alloc_group,
.dealloc_group = sched_dealloc_group,
.assign_quota = sched_assign_quota,
+ .pre_move_task = sched_pre_move_task,
+ .post_move_task = sched_post_move_task,
.get_quota = sched_get_quota,
};
diff -puN include/linux/sched.h~cpu_ctlr_move_task include/linux/sched.h
--- linux-2.6.18-rc3/include/linux/sched.h~cpu_ctlr_move_task 2006-08-20 21:56:09.000000000 +0530
+++ linux-2.6.18-rc3-root/include/linux/sched.h 2006-08-20 21:56:09.000000000 +0530
@@ -1611,6 +1611,9 @@ struct task_grp_ops {
void *(*alloc_group)(void);
void (*dealloc_group)(struct task_grp *grp);
void (*assign_quota)(struct task_grp *grp, int quota);
+ int (*pre_move_task)(struct task_struct *tsk, struct task_grp *old,
+ struct task_grp *new);
+ void (*post_move_task)(struct task_struct *tsk);
int (*get_quota)(struct task_grp *grp);
};
_
--
Regards,
vatsa
next prev parent reply other threads:[~2006-08-20 17:45 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-20 17:40 [PATCH 0/7] CPU controller - V1 Srivatsa Vaddagiri
2006-08-20 17:41 ` [PATCH 1/7] CPU controller V1 - split runqueue Srivatsa Vaddagiri
2006-08-25 12:38 ` Kirill Korotaev
2006-08-28 3:33 ` Srivatsa Vaddagiri
2006-08-28 8:15 ` Kirill Korotaev
2006-08-28 11:03 ` Srivatsa Vaddagiri
2006-08-28 12:31 ` Nick Piggin
2006-08-28 12:52 ` Srivatsa Vaddagiri
2006-08-20 17:42 ` [PATCH 2/7] CPU controller V1 - define group operations Srivatsa Vaddagiri
2006-08-20 17:44 ` Srivatsa Vaddagiri [this message]
2006-08-20 17:45 ` [PATCH 4/7] CPU controller V1 - Handle dont care groups Srivatsa Vaddagiri
2006-08-20 17:46 ` [PATCH 5/7] CPU controller V1 - Extend smpnice to be task-group aware Srivatsa Vaddagiri
2006-08-20 17:47 ` [PATCH 6/7] CPU controller V1 - task_cpu(p) needs to be correct always Srivatsa Vaddagiri
2006-08-20 17:48 ` [PATCH 7/7] CPU controller V1 - (temporary) cpuset interface Srivatsa Vaddagiri
2006-08-20 20:48 ` Paul Jackson
2006-08-21 17:49 ` Srivatsa Vaddagiri
2006-08-28 1:50 ` Paul Jackson
2006-08-22 11:10 ` Mike Galbraith
2006-08-22 10:10 ` Srivatsa Vaddagiri
2006-08-22 14:41 ` Mike Galbraith
2006-08-22 15:23 ` Mike Galbraith
2006-08-22 14:01 ` Srivatsa Vaddagiri
2006-08-22 18:01 ` Mike Galbraith
2006-08-22 15:58 ` Srivatsa Vaddagiri
2006-08-22 18:55 ` Paul Jackson
2006-08-22 15:45 ` Mike Galbraith
2006-08-22 13:50 ` Srivatsa Vaddagiri
2006-08-22 18:05 ` Mike Galbraith
2006-08-22 16:02 ` Srivatsa Vaddagiri
2006-08-22 19:09 ` Mike Galbraith
2006-08-23 9:43 ` Mike Galbraith
2006-08-23 15:24 ` Mike Galbraith
2006-08-23 13:25 ` Srivatsa Vaddagiri
2006-08-21 10:42 ` [PATCH 0/7] CPU controller - V1 Mike Galbraith
2006-08-21 12:48 ` Srivatsa Vaddagiri
2006-08-21 17:10 ` Mike Galbraith
2006-08-21 16:45 ` Srivatsa Vaddagiri
2006-08-21 20:33 ` Mike Galbraith
2006-08-21 18:36 ` Srivatsa Vaddagiri
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=20060820174442.GD13917@in.ibm.com \
--to=vatsa@in.ibm.com \
--cc=akpm@osdl.org \
--cc=balbir@in.ibm.com \
--cc=dev@openvz.org \
--cc=dipankar@in.ibm.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=matthltc@us.ibm.com \
--cc=mingo@elte.hu \
--cc=nagar@watson.ibm.com \
--cc=nickpiggin@yahoo.com.au \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.