The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Satoshi UCHIDA" <s-uchida@ap.jp.nec.com>
To: <linux-kernel@vger.kernel.org>,
	<containers@lists.linux-foundation.org>,
	<virtualization@lists.linux-foundation.org>,
	<jens.axboe@oracle.com>, "'Ryo Tsuruta'" <ryov@valinux.co.jp>,
	"'Andrea Righi'" <righi.andrea@gmail.com>, <ngupta@google.com>,
	<fernando@oss.ntt.co.jp>, <vtaras@openvz.org>
Cc: "'Andrew Morton'" <akpm@linux-foundation.org>,
	"'SUGAWARA Tomoyoshi'" <tom-sugawara@ap.jp.nec.com>,
	<menage@google.com>, <balbir@linux.vnet.ibm.com>
Subject: [PATCH][cfq-cgroups][04/12] Register or unregister "cfq-cgroups" module.
Date: Wed, 12 Nov 2008 17:26:18 +0900	[thread overview]
Message-ID: <001101c944a0$561b0fc0$02512f40$@jp.nec.com> (raw)
In-Reply-To: <000c01c9449e$c5bcdc20$51369460$@jp.nec.com>


  This patch introduce a register/unregister functions of 
  "cfq-cgroups" module.
  A elevator_type variables is inherited one of the original CFQ
  scheduler.


    Signed-off-by: Satoshi UCHIDA <s-uchida@ap.jp.nec.com>

---
 block/cfq-cgroup.c          |  122 +++++++++++++++++++++++++++++++++++++++++++
 block/cfq-iosched.c         |    2 +-
 include/linux/cfq-iosched.h |    2 +
 3 files changed, 125 insertions(+), 1 deletions(-)

diff --git a/block/cfq-cgroup.c b/block/cfq-cgroup.c
index 3deef41..aaa00ef 100644
--- a/block/cfq-cgroup.c
+++ b/block/cfq-cgroup.c
@@ -15,13 +15,135 @@
 #include <linux/cgroup.h>
 #include <linux/cfq-iosched.h>
 
+/*
+ * sysfs parts below -->
+ */
+static ssize_t
+cfq_cgroup_var_show(char *page, struct cfq_data *cfqd,
+		    int (func)(struct cfq_data *))
+{
+	int val, retval = 0;
+
+	val = func(cfqd);
+
+	retval = snprintf(page, PAGE_SIZE, "%d\n", val);
+
+	return retval;
+}
+
+#define SHOW_FUNCTION(__FUNC, __VAR, __CONV)				\
+static int val_transrate_##__FUNC(struct cfq_data *cfqd)		\
+{									\
+	if (__CONV)							\
+		return jiffies_to_msecs(cfqd->__VAR);			\
+	else								\
+		return cfqd->__VAR;					\
+}									\
+static ssize_t __FUNC(elevator_t *e, char *page)			\
+{									\
+	struct cfq_data *cfqd = e->elevator_data;			\
+									\
+	return cfq_cgroup_var_show((page), (cfqd),			\
+				   val_transrate_##__FUNC);		\
+}
+SHOW_FUNCTION(cfq_cgroup_quantum_show, cfq_quantum, 0);
+SHOW_FUNCTION(cfq_cgroup_fifo_expire_sync_show, cfq_fifo_expire[1], 1);
+SHOW_FUNCTION(cfq_cgroup_fifo_expire_async_show, cfq_fifo_expire[0], 1);
+SHOW_FUNCTION(cfq_cgroup_back_seek_max_show, cfq_back_max, 0);
+SHOW_FUNCTION(cfq_cgroup_back_seek_penalty_show, cfq_back_penalty, 0);
+SHOW_FUNCTION(cfq_cgroup_slice_idle_show, cfq_slice_idle, 1);
+SHOW_FUNCTION(cfq_cgroup_slice_sync_show, cfq_slice[1], 1);
+SHOW_FUNCTION(cfq_cgroup_slice_async_show, cfq_slice[0], 1);
+SHOW_FUNCTION(cfq_cgroup_slice_async_rq_show, cfq_slice_async_rq, 0);
+#undef SHOW_FUNCTION
+
+static ssize_t
+cfq_cgroup_var_store(const char *page, size_t count, struct cfq_data *cfqd,
+		     void (func)(struct cfq_data *, unsigned int))
+{
+	int err;
+	unsigned long val;
+
+	err = strict_strtoul(page, 10, &val);
+	if (err)
+		return 0;
+
+	func(cfqd, val);
+
+	return count;
+}
+
+#define STORE_FUNCTION(__FUNC, __VAR, MIN, MAX, __CONV)			\
+static void val_transrate_##__FUNC(struct cfq_data *cfqd,		\
+				   unsigned int __data)			\
+{									\
+	if (__data < (MIN))						\
+		__data = (MIN);						\
+	else if (__data > (MAX))					\
+		__data = (MAX);						\
+	if (__CONV)							\
+		cfqd->__VAR = msecs_to_jiffies(__data);			\
+	else								\
+		cfqd->__VAR = __data;					\
+}									\
+static ssize_t __FUNC(elevator_t *e, const char *page, size_t count)	\
+{									\
+	struct cfq_data *cfqd = e->elevator_data;			\
+	int ret = cfq_cgroup_var_store((page), count, cfqd,		\
+				      val_transrate_##__FUNC);		\
+	return ret;							\
+}
+STORE_FUNCTION(cfq_cgroup_quantum_store, cfq_quantum, 1, UINT_MAX, 0);
+STORE_FUNCTION(cfq_cgroup_fifo_expire_sync_store, cfq_fifo_expire[1], 1,
+		UINT_MAX, 1);
+STORE_FUNCTION(cfq_cgroup_fifo_expire_async_store, cfq_fifo_expire[0], 1,
+		UINT_MAX, 1);
+STORE_FUNCTION(cfq_cgroup_back_seek_max_store, cfq_back_max, 0, UINT_MAX, 0);
+STORE_FUNCTION(cfq_cgroup_back_seek_penalty_store, cfq_back_penalty, 1,
+		UINT_MAX, 0);
+STORE_FUNCTION(cfq_cgroup_slice_idle_store, cfq_slice_idle,
+		0, UINT_MAX, 1);
+STORE_FUNCTION(cfq_cgroup_slice_sync_store, cfq_slice[1], 1, UINT_MAX, 1);
+STORE_FUNCTION(cfq_cgroup_slice_async_store, cfq_slice[0], 1, UINT_MAX, 1);
+STORE_FUNCTION(cfq_cgroup_slice_async_rq_store, cfq_slice_async_rq, 1,
+		UINT_MAX, 0);
+#undef STORE_FUNCTION
+
+#define CFQ_CGROUP_ATTR(name)					\
+	__ATTR(name, S_IRUGO|S_IWUSR, cfq_cgroup_##name##_show,	\
+	       cfq_cgroup_##name##_store)
+
+static struct elv_fs_entry cfq_cgroup_attrs[] = {
+	CFQ_CGROUP_ATTR(quantum),
+	CFQ_CGROUP_ATTR(fifo_expire_sync),
+	CFQ_CGROUP_ATTR(fifo_expire_async),
+	CFQ_CGROUP_ATTR(back_seek_max),
+	CFQ_CGROUP_ATTR(back_seek_penalty),
+	CFQ_CGROUP_ATTR(slice_sync),
+	CFQ_CGROUP_ATTR(slice_async),
+	CFQ_CGROUP_ATTR(slice_async_rq),
+	CFQ_CGROUP_ATTR(slice_idle),
+	__ATTR_NULL
+};
+
+static struct elevator_type iosched_cfq_cgroup = {
+	.elevator_attrs	= cfq_cgroup_attrs,
+	.elevator_name	= "cfq-cgroups",
+	.elevator_owner	= THIS_MODULE,
+};
+
 static int __init cfq_cgroup_init(void)
 {
+	iosched_cfq_cgroup.ops = iosched_cfq.ops;
+
+	elv_register(&iosched_cfq_cgroup);
+
 	return 0;
 }
 
 static void __exit cfq_cgroup_exit(void)
 {
+	elv_unregister(&iosched_cfq_cgroup);
 }
 
 module_init(cfq_cgroup_init);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index b726e85..e105827 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -2332,7 +2332,7 @@ static struct elv_fs_entry cfq_attrs[] = {
 	__ATTR_NULL
 };
 
-static struct elevator_type iosched_cfq = {
+struct elevator_type iosched_cfq = {
 	.ops = {
 		.elevator_merge_fn = 		cfq_merge,
 		.elevator_merged_fn =		cfq_merged_request,
diff --git a/include/linux/cfq-iosched.h b/include/linux/cfq-iosched.h
index 50003f7..a28ef00 100644
--- a/include/linux/cfq-iosched.h
+++ b/include/linux/cfq-iosched.h
@@ -82,4 +82,6 @@ struct cfq_data {
 	struct cfq_driver_data *cfqdd;
 };
 
+extern struct elevator_type iosched_cfq;
+
 #endif  /* _LINUX_CFQ_IOSCHED_H */
-- 
1.5.6.5



  parent reply	other threads:[~2008-11-12  8:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12  8:15 [PATCH][RFC][12+2][v3] A expanded CFQ scheduler for cgroups Satoshi UCHIDA
2008-11-12  8:23 ` [PATCH][cfq-cgroups][01/12] Move basic strcture variable to header file Satoshi UCHIDA
2008-11-12  8:24 ` [PATCH][cfq-cgroups][02/12] Introduce "cfq_driver_data" structure Satoshi UCHIDA
2008-11-12  8:25 ` [PATCH][cfq-cgroups][03/12] Add cgroup file and modify configure files Satoshi UCHIDA
2008-11-12  8:26 ` Satoshi UCHIDA [this message]
2008-11-12  8:26 ` [PATCH][cfq-cgroups][05/12] Introduce cgroups structure with ioprio entry Satoshi UCHIDA
2008-11-12  8:27 ` [PATCH][cfq-cgroups][06/12] Add siblings tree control for driver data(cfq_driver_data) Satoshi UCHIDA
2008-11-12  8:28 ` [PATCH][cfq-cgroups][07/12] Add sibling tree control for group data(cfq_cgroup) Satoshi UCHIDA
2008-11-12  8:29 ` [PATCH][cfq-cgroups][08/12] Interface to new cfq data structure in cfq_cgroup module Satoshi UCHIDA
2008-11-12  8:29 ` [PATCH][cfq-cgroups][09/12] Develop service tree control Satoshi UCHIDA
2008-11-12  8:30 ` [PATCH][cfq-cgroups][10/12] Introduce request control for two layer Satoshi UCHIDA
2008-11-12  8:31 ` [PATCH][cfq-cgroups][11/12] Expand idle slice timer function Satoshi UCHIDA
2008-11-12  8:31 ` [PATCH][cfq-cgroups][12/12] Interface for parameter of cfq driver data Satoshi UCHIDA
2008-11-12  8:37 ` [PATCH][cfq-cgroups][Option 1] Introduce a think time valid entry Satoshi UCHIDA
2008-11-12  8:37 ` [PATCH][cfq-cgroups][Option 2] Introduce ioprio class for top layer Satoshi UCHIDA
2008-11-12  8:57 ` [PATCH][RFC][12+2][v3] A expanded CFQ scheduler for cgroups Peter Zijlstra
2008-11-12  9:22   ` Satoshi UCHIDA

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='001101c944a0$561b0fc0$02512f40$@jp.nec.com' \
    --to=s-uchida@ap.jp.nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=fernando@oss.ntt.co.jp \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    --cc=ngupta@google.com \
    --cc=righi.andrea@gmail.com \
    --cc=ryov@valinux.co.jp \
    --cc=tom-sugawara@ap.jp.nec.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=vtaras@openvz.org \
    /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