Satoshi UCHIDA
2008-Oct-31 11:49 UTC
[PATCH][cfq-cgroups] Interface for parameter of cfq driver data
This patch add a interface for parameter of cfq driver data. Signed-off-by: Satoshi UCHIDA <s-uchida at ap.jp.nec.com> --- block/cfq-cgroup.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 58 insertions(+), 1 deletions(-) diff --git a/block/cfq-cgroup.c b/block/cfq-cgroup.c index 4938fa0..776874d 100644 --- a/block/cfq-cgroup.c +++ b/block/cfq-cgroup.c @@ -1028,6 +1028,62 @@ STORE_FUNCTION(cfq_cgroup_slice_async_rq_store, cfq_slice_async_rq, 1, STORE_FUNCTION(cfq_cgroup_ioprio_store, ioprio, 0, CFQ_CGROUP_MAX_IOPRIO, 0); #undef STORE_FUNCTION +static ssize_t +cfq_cgroup_var_show2(unsigned int var, char *page) +{ + return snprintf(page, PAGE_SIZE, "%d\n", var); +} + +static ssize_t +cfq_cgroup_var_store2(unsigned int *var, const char *page, size_t count) +{ + int err; + char *p = (char *) page; + unsigned long new_var; + + err = strict_strtoul(p, 10, &new_var); + if (err) + count = 0; + + *var = new_var; + + return count; +} + +#define SHOW_FUNCTION2(__FUNC, __VAR, __CONV) \ +static ssize_t __FUNC(elevator_t *e, char *page) \ +{ \ + struct cfq_data *cfqd = e->elevator_data; \ + struct cfq_driver_data *cfqdd = cfqd->cfqdd; \ + unsigned int __data = __VAR; \ + if (__CONV) \ + __data = jiffies_to_msecs(__data); \ + return cfq_cgroup_var_show2(__data, (page)); \ +} +SHOW_FUNCTION2(cfq_cgroup_slice_cgroup_show, cfqdd->cfq_cgroup_slice, 1); +#undef SHOW_FUNCTION2 + +#define STORE_FUNCTION2(__FUNC, __PTR, MIN, MAX, __CONV) \ +static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \ +{ \ + struct cfq_data *cfqd = e->elevator_data; \ + struct cfq_driver_data *cfqdd = cfqd->cfqdd; \ + unsigned int __data; \ + int ret = cfq_cgroup_var_store2(&__data, (page), count); \ + if (__data < (MIN)) \ + __data = (MIN); \ + else if (__data > (MAX)) \ + __data = (MAX); \ + if (__CONV) \ + *(__PTR) = msecs_to_jiffies(__data); \ + else \ + *(__PTR) = __data; \ + return ret; \ +} +STORE_FUNCTION2(cfq_cgroup_slice_cgroup_store, &cfqdd->cfq_cgroup_slice, 1, + UINT_MAX, 1); +#undef STORE_FUNCTION2 + #define CFQ_CGROUP_ATTR(name) \ __ATTR(name, S_IRUGO|S_IWUSR, cfq_cgroup_##name##_show, \ cfq_cgroup_##name##_store) @@ -1043,6 +1099,7 @@ static struct elv_fs_entry cfq_cgroup_attrs[] = { CFQ_CGROUP_ATTR(slice_async_rq), CFQ_CGROUP_ATTR(slice_idle), CFQ_CGROUP_ATTR(ioprio), + CFQ_CGROUP_ATTR(slice_cgroup), __ATTR_NULL }; -- 1.5.6.5
Seemingly Similar Threads
- [PATCH][RFC][12+2][v3] A expanded CFQ scheduler for cgroups
- [PATCH][RFC][12+2][v3] A expanded CFQ scheduler for cgroups
- [PATCH][cfq-cgroups] Introduce ioprio class for top layer.
- [PATCH][cfq-cgroups] Introduce ioprio class for top layer.
- [PATCH] block drivers/block: Use octal not symbolic permissions