[Devel] [PATCH 5/7] announce tasks moving in bio-cgroup

Gui Jianfeng guijianfeng at cn.fujitsu.com
Thu Nov 20 03:14:04 PST 2008


Some subsystems may be of interest to task moving in bio-cgroups.
So just announce each task moving.

Signed-of-by: Gui Jianfeng <guijianfeng at cn.fujitsu.com>
---
 include/linux/biotrack.h |    9 +++++++++
 mm/biotrack.c            |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/include/linux/biotrack.h b/include/linux/biotrack.h
index 371d263..546017c 100644
--- a/include/linux/biotrack.h
+++ b/include/linux/biotrack.h
@@ -7,6 +7,15 @@
 
 #ifdef	CONFIG_CGROUP_BIO
 
+struct tsk_move_msg {
+	int old_id;
+	int new_id;
+	struct task_struct *tsk;
+};
+
+extern int register_biocgroup_notifier(struct notifier_block *nb);
+extern int unregister_biocgroup_notifier(struct notifier_block *nb);
+
 struct io_context;
 struct block_device;
 
diff --git a/mm/biotrack.c b/mm/biotrack.c
index ba6b45b..979efcd 100644
--- a/mm/biotrack.c
+++ b/mm/biotrack.c
@@ -21,6 +21,22 @@
 #include <linux/blkdev.h>
 #include <linux/biotrack.h>
 
+#define MOVETASK 0
+static BLOCKING_NOTIFIER_HEAD(biocgroup_chain);
+
+int register_biocgroup_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&biocgroup_chain, nb);
+}
+EXPORT_SYMBOL(register_biocgroup_notifier);
+
+int unregister_biocgroup_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&biocgroup_chain, nb);
+}
+EXPORT_SYMBOL(unregister_biocgroup_notifier);
+
+
 /*
  * The block I/O tracking mechanism is implemented on the cgroup memory
  * controller framework. It helps to find the the owner of an I/O request 
@@ -299,11 +315,27 @@ static int bio_cgroup_populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
 	return cgroup_add_files(cgrp, ss, bio_files, ARRAY_SIZE(bio_files));
 }
 
+static void bio_cgroup_attach(struct cgroup_subsys *ss,
+			      struct cgroup *cont, struct cgroup *oldcont,
+			      struct task_struct *tsk)
+{
+	struct tsk_move_msg tmm;
+	struct bio_cgroup *old_biog, *new_biog;
+	
+	old_biog = cgroup_bio(oldcont);
+	new_biog = cgroup_bio(cont);
+	tmm.old_id = old_biog->id;
+	tmm.new_id = new_biog->id;
+	tmm.tsk = tsk;
+	blocking_notifier_call_chain(&biocgroup_chain, MOVETASK, &tmm);
+}
+
 struct cgroup_subsys bio_cgroup_subsys = {
 	.name		= "bio",
 	.create		= bio_cgroup_create,
 	.destroy	= bio_cgroup_destroy,
 	.populate	= bio_cgroup_populate,
+	.attach         = bio_cgroup_attach,
 	.subsys_id	= bio_cgroup_subsys_id,
 };
 
-- 1.5.4.rc3 

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list