IO Controller
Subsystems (3)
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Thanks
Vivek
PATCH 1/10 Documentation
o Documentation for io-controller.
--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txt
Documentation/block/io-controller.txt new file +221 -0
@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/s
Signature · 1 line
1.6.0.1
PATCH 2/10 Common flat fair queuing code in elevaotor layer
In reply to a message not in the archiveThis is common fair queuing code in elevator layer. This is controlled by config option CONFIG_ELV_FAIR_QUEUING. This patch initially only introduces flat fair queuing support where there is only one group, "root group" and all the tasks belong to root group.
This elevator layer changes are backward compatible. That means any ioscheduler using old interfaces will continue to work.
--- block/Kconfig.iosched | 13 + block/Makefile | 1 + block/blk-sysfs.c | 10 + block/elevator-fq.c | 1882 ++++++++++++++++++++++++++++++++++++++++++++++ block/elevator-fq.h | 479 ++++++++++++ block/elevator.c | 46 +- include/linux/blkdev.h | 5 + include/linux/elevator.h | 48 ++ 8 files changed, 2473 insertions(+), 11 deletions(-) create mode 100644 block/elevator-fq.c create mode 100644 block/elevator-fq.h
block/Kconfig.iosched +13 -0
@@ -2,6 +2,19 @@ if BLOCK menu "IO Schedulers" +config ELV_FAIR_QUEUING + bool "Elevator Fair Queuing Support" + default n + ---help--- + Traditionally only cfq had notion of multiple queues and it did + fair queuing at its own. With the cgroups and need of controlling + IO, now even the simple io schedulers like noop, deadline, as will + have one queue per cgroup and will need hierarchical fair queuing. + Instead of every io scheduler implementing its own fair queuing + logic, this option enables fair queuing in elevator layer so that + other ioschedulers can make use of it. + If unsure, say N. + config IOSCHED_NOOP bool default y
block/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o obj-$(CONFIG_BLK_DEV_INTEGRITY) += blk-integrity.o +obj-$(CONFIG_ELV_FAIR_QUEUING) += elevator-fq.o
block/blk-sysfs.c +10 -0
@@ -276,6 +276,13 @@ static struct queue_sysfs_entry queue_iostats_entry = { .store = queue_iostats_store, }; +#ifdef CONFIG_ELV_FAIR_QUEUING +static struct queue_sysfs_entry queue_slice_idle_entry = { + .attr = {.name ="slice_idle" , .mode =S_IRUGO |S_IWUSR }, + .show = elv_slice_idle_show, + .store = elv_slice_idle_store, +}; +#endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr, &queue_ra_entry.attr,
@@ -287,6 +294,9 @@ static struct attribute *default_attrs[] = { &queue_nomerges_entry.attr, &queue_rq_affinity_entry.attr, &queue_iostats_entry.attr, +#ifdef CONFIG_ELV_FAIR_QUEUING + &queue_slice_idle_entry.attr, +#endif NULL, };
block/elevator-fq.c new file +1882 -0
1,882 lines not on this page · raw message
block/elevator-fq.h new file +479 -0
479 lines not on this page · raw message
block/elevator.c +35 -11
116 lines not on this page · raw message
include/linux/blkdev.h +5 -0
@@ -234,6 +234,11 @@ struct request {/* for bidi */ struct request *next_rq; + +#ifdef CONFIG_ELV_FAIR_QUEUING +/* io queue request belongs to */ +struct io_queue *ioq; +#endif };static inline unsigned short req_get_ioprio (struct request *req)
include/linux/elevator.h +48 -0
83 lines not on this page · raw message
Signature · 1 line
1.6.0.1
PATCH 3/10 Modify cfq to make use of flat elevator fair queuing
In reply to a message not in the archiveThis patch changes cfq to use fair queuing code from elevator layer.
o must_dispatch logic sounds like a dead code. Nobody seems to be making use of that flag. Retaining it for the time being.
--- block/Kconfig.iosched | 3 +- block/cfq-iosched.c | 1082 +++++++++++-------------------------------------- 2 files changed, 232 insertions(+), 853 deletions(-)
block/Kconfig.iosched +2 -1
@@ -3,7 +3,7 @@ if BLOCK menu "IO Schedulers" config ELV_FAIR_QUEUING - bool "Elevator Fair Queuing Support" + bool default n ---help--- Traditionally only cfq had notion of multiple queues and it did
@@ -46,6 +46,7 @@ config IOSCHED_DEADLINE config IOSCHED_CFQ tristate "CFQ I/O scheduler" + select ELV_FAIR_QUEUING default y ---help--- The CFQ I/O scheduler tries to distribute bandwidth equally
block/cfq-iosched.c +230 -852
1,757 lines not on this page · raw message
Signature · 1 line
1.6.0.1
PATCH 4/10 Common hierarchical fair queuing code in elevaotor layer
In reply to Vivek GoyalThis patch enables hierarchical fair queuing in common layer. It is controlled by config option CONFIG_GROUP_IOSCHED.
--- block/blk-ioc.c | 3 + block/elevator-fq.c | 991 ++++++++++++++++++++++++++++++++++++++--- block/elevator-fq.h | 113 +++++ block/elevator.c | 2 + include/linux/blkdev.h | 7 +- include/linux/cgroup_subsys.h | 7 + include/linux/iocontext.h | 5 + init/Kconfig | 8 + 8 files changed, 1064 insertions(+), 72 deletions(-)
block/blk-ioc.c +3 -0
@@ -95,6 +95,9 @@ struct io_context *alloc_io_context(gfp_t gfp_flags, int node)spin_lock_init (&ret->lock); ret->ioprio_changed =0 ; ret->ioprio =0 ; +#ifdef CONFIG_GROUP_IOSCHED + ret->cgroup_changed =0 ; +#endif ret->last_waited = jiffies;/* doesn't matter... */ ret->nr_batch_requests =0 ;/* because this is 0 */ ret->aic =NULL ;
block/elevator-fq.c +920 -71
1,109 lines not on this page · raw message
block/elevator-fq.h +113 -0
153 lines not on this page · raw message
block/elevator.c +2 -0
@@ -888,6 +888,8 @@ int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) {struct elevator_queue *e = q->elevator; +elv_fq_set_request_io_group (q, rq); +if (e->ops->elevator_set_req_fn)return e->ops->elevator_set_req_fn (q, rq, gfp_mask);
include/linux/blkdev.h +6 -1
@@ -238,7 +238,12 @@ struct request {#ifdef CONFIG_ELV_FAIR_QUEUING /* io queue request belongs to */ struct io_queue *ioq; -#endif + +#ifdef CONFIG_GROUP_IOSCHED +/* io group request belongs to */ +struct io_group *iog; +#endif /* GROUP_IOSCHED */ +#endif /* ELV_FAIR_QUEUING */ };static inline unsigned short req_get_ioprio (struct request *req)
include/linux/cgroup_subsys.h +7 -0
@@ -60,3 +60,10 @@ SUBSYS(net_cls)#endif /* */ + +#ifdef CONFIG_GROUP_IOSCHED +SUBSYS(io) +#endif + +/* */ +
include/linux/iocontext.h +5 -0
@@ -73,6 +73,11 @@ struct io_context {unsigned short ioprio;unsigned short ioprio_changed; +#ifdef CONFIG_GROUP_IOSCHED +/* If task changes the cgroup, elevator processes it asynchronously */ +unsigned short cgroup_changed; +#endif +/* * For request batching */
init/Kconfig +8 -0
@@ -538,6 +538,14 @@ config CGROUP_MEM_RES_CTLR_SWAP there will be no overhead from this. Even when you set this config=y, if boot option "noswapaccount" is set, swap will not be accounted. +config GROUP_IOSCHED + bool "Group IO Scheduler" + depends on CGROUPS && ELV_FAIR_QUEUING + default n + ---help--- + This feature lets IO scheduler recognize task groups and control + disk bandwidth allocation to such task groups. + endif # CGROUPS config MM_OWNER
Signature · 1 line
1.6.0.1
PATCH 5/10 cfq changes to use hierarchical fair queuing code in elevaotor layer
In reply to Vivek GoyalMake cfq hierarhical.
--- block/Kconfig.iosched | 8 ++++++++ block/cfq-iosched.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ init/Kconfig | 2 +- 3 files changed, 57 insertions(+), 1 deletions(-)
block/Kconfig.iosched +8 -0
@@ -54,6 +54,14 @@ config IOSCHED_CFQ working environment, suitable for desktop systems. This is the default I/O scheduler. +config IOSCHED_CFQ_HIER + bool "CFQ Hierarchical Scheduling support" + depends on IOSCHED_CFQ && CGROUPS + select GROUP_IOSCHED + default n + ---help--- + Enable hierarhical scheduling in cfq. + choice prompt "Default I/O scheduler" default DEFAULT_CFQ
block/cfq-iosched.c +48 -0
60 lines not on this page · raw message
init/Kconfig +1 -1
@@ -539,7 +539,7 @@ config CGROUP_MEM_RES_CTLR_SWAP if boot option "noswapaccount" is set, swap will not be accounted. config GROUP_IOSCHED - bool "Group IO Scheduler" + bool depends on CGROUPS && ELV_FAIR_QUEUING default n ---help---
Signature · 1 line
1.6.0.1
PATCH 6/10 Separate out queue and data
In reply to Vivek Goyalo So far noop, deadline and AS had one common structure called *_data which contained both the queue information where requests are queued and also common data used for scheduling. This patch breaks down this common structure in two parts, *_queue and *_data. This is along the lines of cfq where all the reuquests are queued in queue and common data and tunables are part of data.
o It does not change the functionality but this re-organization helps once noop, deadline and AS are changed to use hierarchical fair queuing.
o looks like queue_empty function is not required and we can check for q->nr_sorted in elevator layer to see if ioscheduler queues are empty or not.
--- block/as-iosched.c | 209 ++++++++++++++++++++++++++-------------------- block/deadline-iosched.c | 117 ++++++++++++++++---------- block/elevator.c | 111 +++++++++++++++++++++---- block/noop-iosched.c | 59 ++++++------- include/linux/elevator.h | 8 ++- 5 files changed, 319 insertions(+), 185 deletions(-)
block/as-iosched.c +118 -91
@@ -79,13 +79,7 @@ enum anticipation_status {* or timed out */ }; -struct as_data { -/* -* run time data -*/ - -struct request_queue *q;/* the "owner" queue */ - +struct as_queue {/* * requests (as_rq s) are present on both sort_list and fifo_list */
@@ -93,6 +87,14 @@ struct as_data {struct list_head fifo_list[2 ];struct request *next_rq[2 ];/* next in sort order */ +unsigned long last_check_fifo[2 ]; +int write_batch_count;/* max # of reqs in a write batch */ +int current_write_count;/* how many requests left this batch */ +int write_batch_idled;/* has the write batch gone idle? */ +}; + +struct as_data { +struct request_queue *q;/* the "owner" queue */ sector_t last_sector[2 ];/* last REQ_SYNC & REQ_ASYNC sectors */ unsigned long exit_prob;/* probability a task will exit while
@@ -104,23 +106,19 @@ struct as_data {unsigned long new_ttime_mean;u64 new_seek_total;/* mean seek on new proc */ sector_t new_seek_mean; -unsigned long current_batch_expires; -unsigned long last_check_fifo[2 ]; +int changed_batch;/* 1: waiting for old batch to end */ int new_batch;/* 1: waiting on first read complete */ -int batch_data_dir;/* current batch REQ_SYNC / REQ_ASYNC */ -int write_batch_count;/* max # of reqs in a write batch */ -int current_write_count;/* how many requests left this batch */ -int write_batch_idled;/* has the write batch gone idle? */ enum anticipation_status antic_status;unsigned long antic_start;/* jiffies: when it started */ struct timer_list antic_timer;/* anticipatory scheduling timer */ -struct work_struct antic_work;/* Deferred unplugging */ +struct work_struct antic_work;/* Deferred unplugging */ struct io_context *io_context;/* Identify the expected process */ int ioc_finished;/* IO associated with io_context is finished */ int nr_dispatched; +int batch_data_dir;/* current batch REQ_SYNC / REQ_ASYNC */ /* * settings that change how the i/o scheduler behaves
@@ -261,13 +259,14 @@ static void as_put_io_context(struct request *rq)/* * rb tree support functions */ -#define RQ_RB_ROOT (ad, rq) (&(ad)->sort_list[rq_is_sync((rq))]) +#define RQ_RB_ROOT (asq, rq) (&(asq)->sort_list[rq_is_sync((rq))])static void as_add_rq_rb (struct as_data *ad,struct request *rq) {struct request *alias; +struct as_queue *asq =elv_get_sched_queue (ad->q, rq); -while ((unlikely (alias =elv_rb_add (RQ_RB_ROOT (ad, rq), rq)))) { +while ((unlikely (alias =elv_rb_add (RQ_RB_ROOT (asq, rq), rq)))) {as_move_to_dispatch (ad, alias);as_antic_stop (ad); }
@@ -275,7 +274,9 @@ static void as_add_rq_rb(struct as_data *ad, struct request *rq)static inline void as_del_rq_rb (struct as_data *ad,struct request *rq) { -elv_rb_del (RQ_RB_ROOT (ad, rq), rq); +struct as_queue *asq =elv_get_sched_queue (ad->q, rq); + +elv_rb_del (RQ_RB_ROOT (asq, rq), rq); }/*
@@ -369,7 +370,7 @@ as_choose_req(struct as_data *ad, struct request *rq1, struct request *rq2)* what request to process next. Anticipation works on top of this. */ static struct request * -as_find_next_rq (struct as_data *ad,struct request *last) +as_find_next_rq (struct as_data *ad,struct as_queue *asq,struct request *last) {struct rb_node *rbnext =rb_next (&last->rb_node);struct rb_node *rbprev =rb_prev (&last->rb_node);
@@ -385,7 +386,7 @@ as_find_next_rq(struct as_data *ad, struct request *last)else {const int data_dir =rq_is_sync (last); - rbnext =rb_first (&ad->sort_list[data_dir]); + rbnext =rb_first (&asq->sort_list[data_dir]);if (rbnext && rbnext != &last->rb_node) next =rb_entry_rq (rbnext); }
@@ -790,9 +791,10 @@ static int as_can_anticipate(struct as_data *ad, struct request *rq)static void as_update_rq (struct as_data *ad,struct request *rq) {const int data_dir =rq_is_sync (rq); +struct as_queue *asq =elv_get_sched_queue (ad->q, rq);/* keep the next_rq cache up to date */ - ad->next_rq[data_dir] =as_choose_req (ad, rq, ad->next_rq[data_dir]); + asq->next_rq[data_dir] =as_choose_req (ad, rq, asq->next_rq[data_dir]);/* * have we been anticipating this request?
@@ -813,25 +815,26 @@ static void update_write_batch(struct as_data *ad) {unsigned long batch = ad->batch_expire[REQ_ASYNC ];long write_time; +struct as_queue *asq =elv_get_sched_queue (ad->q,NULL ); write_time = (jiffies - ad->current_batch_expires) + batch;if (write_time <0 ) write_time =0 ; -if (write_time > batch && !ad->write_batch_idled) { +if (write_time > batch && !asq->write_batch_idled) {if (write_time > batch *3 ) - ad->write_batch_count /=2 ; + asq->write_batch_count /=2 ;else - ad->write_batch_count--; - }else if (write_time < batch && ad->current_write_count ==0 ) { + asq->write_batch_count--; + }else if (write_time < batch && asq->current_write_count ==0 ) {if (batch > write_time *3 ) - ad->write_batch_count *=2 ; + asq->write_batch_count *=2 ;else - ad->write_batch_count++; + asq->write_batch_count++; } -if (ad->write_batch_count <1 ) - ad->write_batch_count =1 ; +if (asq->write_batch_count <1 ) + asq->write_batch_count =1 ; }/*
@@ -902,6 +905,7 @@ static void as_remove_queued_request(struct request_queue *q,const int data_dir =rq_is_sync (rq);struct as_data *ad = q->elevator->elevator_data;struct io_context *ioc; +struct as_queue *asq =elv_get_sched_queue (q, rq);WARN_ON (RQ_STATE (rq) !=AS_RQ_QUEUED );
@@ -915,8 +919,8 @@ static void as_remove_queued_request(struct request_queue *q,* Update the "next_rq" cache if we are about to remove its * entry */ -if (ad->next_rq[data_dir] == rq) - ad->next_rq[data_dir] =as_find_next_rq (ad, rq); +if (asq->next_rq[data_dir] == rq) + asq->next_rq[data_dir] =as_find_next_rq (ad, asq, rq);rq_fifo_clear (rq);as_del_rq_rb (ad, rq);
@@ -930,23 +934,23 @@ static void as_remove_queued_request(struct request_queue *q,* * See as_antic_expired comment. */ -static int as_fifo_expired (struct as_data *ad,int adir) +static int as_fifo_expired (struct as_data *ad,struct as_queue *asq,int adir) {struct request *rq;long delta_jif; - delta_jif = jiffies - ad->last_check_fifo[adir]; + delta_jif = jiffies - asq->last_check_fifo[adir];if (unlikely (delta_jif <0 )) delta_jif = -delta_jif;if (delta_jif < ad->fifo_expire[adir])return 0 ; - ad->last_check_fifo[adir] = jiffies; + asq->last_check_fifo[adir] = jiffies; -if (list_empty (&ad->fifo_list[adir])) +if (list_empty (&asq->fifo_list[adir]))return 0 ; - rq =rq_entry_fifo (ad->fifo_list[adir].next); + rq =rq_entry_fifo (asq->fifo_list[adir].next);return time_after (jiffies,rq_fifo_time (rq)); }
@@ -955,7 +959,7 @@ static int as_fifo_expired(struct as_data *ad, int adir)* as_batch_expired returns true if the current batch has expired. A batch * is a set of reads or a set of writes. */ -static inline int as_batch_expired (struct as_data *ad) +static inline int as_batch_expired (struct as_data *ad,struct as_queue *asq) {if (ad->changed_batch || ad->new_batch)return 0 ;
@@ -965,7 +969,7 @@ static inline int as_batch_expired(struct as_data *ad)return time_after (jiffies, ad->current_batch_expires);return time_after (jiffies, ad->current_batch_expires) - || ad->current_write_count ==0 ; + || asq->current_write_count ==0 ; }/*
@@ -974,6 +978,7 @@ static inline int as_batch_expired(struct as_data *ad)static void as_move_to_dispatch (struct as_data *ad,struct request *rq) {const int data_dir =rq_is_sync (rq); +struct as_queue *asq =elv_get_sched_queue (ad->q, rq);BUG_ON (RB_EMPTY_NODE (&rq->rb_node));
@@ -996,12 +1001,12 @@ static void as_move_to_dispatch(struct as_data *ad, struct request *rq) ad->io_context =NULL ; } -if (ad->current_write_count !=0 ) - ad->current_write_count--; +if (asq->current_write_count !=0 ) + asq->current_write_count--; } ad->ioc_finished =0 ; - ad->next_rq[data_dir] =as_find_next_rq (ad, rq); + asq->next_rq[data_dir] =as_find_next_rq (ad, asq, rq);/* * take it off the sort and fifo list, add to dispatch queue
@@ -1025,10 +1030,16 @@ static void as_move_to_dispatch(struct as_data *ad, struct request *rq)static int as_dispatch_request (struct request_queue *q,int force) {struct as_data *ad = q->elevator->elevator_data; -const int reads = !list_empty (&ad->fifo_list[REQ_SYNC ]); -const int writes = !list_empty (&ad->fifo_list[REQ_ASYNC ]); +struct as_queue *asq =elv_select_sched_queue (q, force); +int reads, writes;struct request *rq; +if (!asq) +return 0 ; + + reads = !list_empty (&asq->fifo_list[REQ_SYNC ]); + writes = !list_empty (&asq->fifo_list[REQ_ASYNC ]); +if (unlikely (force)) {/* * Forced dispatch, accounting is useless. Reset
@@ -1043,25 +1054,25 @@ static int as_dispatch_request(struct request_queue *q, int force) ad->changed_batch =0 ; ad->new_batch =0 ; -while (ad->next_rq[REQ_SYNC ]) { -as_move_to_dispatch (ad, ad->next_rq[REQ_SYNC ]); +while (asq->next_rq[REQ_SYNC ]) { +as_move_to_dispatch (ad, asq->next_rq[REQ_SYNC ]); dispatched++; } - ad->last_check_fifo[REQ_SYNC ] = jiffies; + asq->last_check_fifo[REQ_SYNC ] = jiffies; -while (ad->next_rq[REQ_ASYNC ]) { -as_move_to_dispatch (ad, ad->next_rq[REQ_ASYNC ]); +while (asq->next_rq[REQ_ASYNC ]) { +as_move_to_dispatch (ad, asq->next_rq[REQ_ASYNC ]); dispatched++; } - ad->last_check_fifo[REQ_ASYNC ] = jiffies; + asq->last_check_fifo[REQ_ASYNC ] = jiffies;return dispatched; }/* Signal that the write batch was uncontended, so we can't time it */ if (ad->batch_data_dir ==REQ_ASYNC && !reads) { -if (ad->current_write_count ==0 || !writes) - ad->write_batch_idled =1 ; +if (asq->current_write_count ==0 || !writes) + asq->write_batch_idled =1 ; } if (!(reads || writes)
@@ -1070,14 +1081,14 @@ static int as_dispatch_request(struct request_queue *q, int force) || ad->changed_batch)return 0 ; -if (!(reads && writes &&as_batch_expired (ad))) { +if (!(reads && writes &&as_batch_expired (ad, asq))) {/* * batch is still running or no reads or no writes */ - rq = ad->next_rq[ad->batch_data_dir]; + rq = asq->next_rq[ad->batch_data_dir];if (ad->batch_data_dir ==REQ_SYNC && ad->antic_expire) { -if (as_fifo_expired (ad,REQ_SYNC )) +if (as_fifo_expired (ad, asq,REQ_SYNC )) goto fifo_expired;if (as_can_anticipate (ad, rq)) {
@@ -1101,7 +1112,7 @@ static int as_dispatch_request(struct request_queue *q, int force)*/ if (reads) { -BUG_ON (RB_EMPTY_ROOT (&ad->sort_list[REQ_SYNC ])); +BUG_ON (RB_EMPTY_ROOT (&asq->sort_list[REQ_SYNC ]));if (writes && ad->batch_data_dir ==REQ_SYNC )/*
@@ -1114,8 +1125,8 @@ static int as_dispatch_request(struct request_queue *q, int force) ad->changed_batch =1 ; } ad->batch_data_dir =REQ_SYNC ; - rq =rq_entry_fifo (ad->fifo_list[REQ_SYNC ].next); - ad->last_check_fifo[ad->batch_data_dir] = jiffies; + rq =rq_entry_fifo (asq->fifo_list[REQ_SYNC ].next); + asq->last_check_fifo[ad->batch_data_dir] = jiffies; goto dispatch_request; }
@@ -1125,7 +1136,7 @@ static int as_dispatch_request(struct request_queue *q, int force)if (writes) { dispatch_writes: -BUG_ON (RB_EMPTY_ROOT (&ad->sort_list[REQ_ASYNC ])); +BUG_ON (RB_EMPTY_ROOT (&asq->sort_list[REQ_ASYNC ]));if (ad->batch_data_dir ==REQ_SYNC ) { ad->changed_batch =1 ;
@@ -1138,10 +1149,10 @@ dispatch_writes: ad->new_batch =0 ; } ad->batch_data_dir =REQ_ASYNC ; - ad->current_write_count = ad->write_batch_count; - ad->write_batch_idled =0 ; - rq =rq_entry_fifo (ad->fifo_list[REQ_ASYNC ].next); - ad->last_check_fifo[REQ_ASYNC ] = jiffies; + asq->current_write_count = asq->write_batch_count; + asq->write_batch_idled =0 ; + rq =rq_entry_fifo (asq->fifo_list[REQ_ASYNC ].next); + asq->last_check_fifo[REQ_ASYNC ] = jiffies; goto dispatch_request; }
@@ -1153,9 +1164,9 @@ dispatch_request:* If a request has expired, service it. */ -if (as_fifo_expired (ad, ad->batch_data_dir)) { +if (as_fifo_expired (ad, asq, ad->batch_data_dir)) { fifo_expired: - rq =rq_entry_fifo (ad->fifo_list[ad->batch_data_dir].next); + rq =rq_entry_fifo (asq->fifo_list[ad->batch_data_dir].next); }if (ad->changed_batch) {
@@ -1188,6 +1199,7 @@ static void as_add_request(struct request_queue *q, struct request *rq) {struct as_data *ad = q->elevator->elevator_data;int data_dir; +struct as_queue *asq =elv_get_sched_queue (q, rq);RQ_SET_STATE (rq,AS_RQ_NEW );
@@ -1206,7 +1218,7 @@ static void as_add_request(struct request_queue *q, struct request *rq)* set expire time and add to fifo list */ rq_set_fifo_time (rq, jiffies + ad->fifo_expire[data_dir]); -list_add_tail (&rq->queuelist, &ad->fifo_list[data_dir]); +list_add_tail (&rq->queuelist, &asq->fifo_list[data_dir]);as_update_rq (ad, rq);/* keep state machine up to date */ RQ_SET_STATE (rq,AS_RQ_QUEUED );
@@ -1228,31 +1240,20 @@ static void as_deactivate_request(struct request_queue *q, struct request *rq)atomic_inc (&RQ_IOC (rq)->aic->nr_dispatched); } -/* -* as_queue_empty tells us if there are requests left in the device. It may -* not be the case that a driver can get the next request even if the queue -* is not empty - it is used in the block layer to check for plugging and -* merging opportunities -*/ -static int as_queue_empty (struct request_queue *q) -{ -struct as_data *ad = q->elevator->elevator_data; - -return list_empty (&ad->fifo_list[REQ_ASYNC ]) - &&list_empty (&ad->fifo_list[REQ_SYNC ]); -} -static int as_merge (struct request_queue *q,struct request **req,struct bio *bio) { -struct as_data *ad = q->elevator->elevator_data;sector_t rb_key = bio->bi_sector +bio_sectors (bio);struct request *__rq; +struct as_queue *asq =elv_get_sched_queue_current (q); + +if (!asq) +return ELEVATOR_NO_MERGE ;/* * check for front merge */ - __rq =elv_rb_find (&ad->sort_list[bio_data_dir (bio)], rb_key); + __rq =elv_rb_find (&asq->sort_list[bio_data_dir (bio)], rb_key);if (__rq &&elv_rq_merge_ok (__rq, bio)) { *req = __rq;return ELEVATOR_FRONT_MERGE ;
@@ -1339,6 +1340,41 @@ static int as_may_queue(struct request_queue *q, int rw)return ret; } +/* Called with queue lock held */ +static void *as_alloc_as_queue (struct request_queue *q, +struct elevator_queue *eq,gfp_t gfp_mask) +{ +struct as_queue *asq; +struct as_data *ad = eq->elevator_data; + + asq =kmalloc_node (sizeof (*asq), gfp_mask | __GFP_ZERO, q->node); +if (asq ==NULL ) + goto out; + +INIT_LIST_HEAD (&asq->fifo_list[REQ_SYNC ]); +INIT_LIST_HEAD (&asq->fifo_list[REQ_ASYNC ]); + asq->sort_list[REQ_SYNC ] =RB_ROOT ; + asq->sort_list[REQ_ASYNC ] =RB_ROOT ; +if (ad) + asq->write_batch_count = ad->batch_expire[REQ_ASYNC ] /10 ; +else + asq->write_batch_count = default_write_batch_expire /10 ; + +if (asq->write_batch_count <2 ) + asq->write_batch_count =2 ; +out: +return asq; +} + +static void as_free_as_queue (struct elevator_queue *e,void *sched_queue) +{ +struct as_queue *asq = sched_queue; + +BUG_ON (!list_empty (&asq->fifo_list[REQ_SYNC ])); +BUG_ON (!list_empty (&asq->fifo_list[REQ_ASYNC ])); +kfree (asq); +} +static void as_exit_queue (struct elevator_queue *e) {struct as_data *ad = e->elevator_data;
@@ -1346,9 +1382,6 @@ static void as_exit_queue(struct elevator_queue *e)del_timer_sync (&ad->antic_timer);cancel_work_sync (&ad->antic_work); -BUG_ON (!list_empty (&ad->fifo_list[REQ_SYNC ])); -BUG_ON (!list_empty (&ad->fifo_list[REQ_ASYNC ])); -put_io_context (ad->io_context);kfree (ad); }
@@ -1372,10 +1405,6 @@ static void *as_init_queue(struct request_queue *q)init_timer (&ad->antic_timer);INIT_WORK (&ad->antic_work, as_work_handler); -INIT_LIST_HEAD (&ad->fifo_list[REQ_SYNC ]); -INIT_LIST_HEAD (&ad->fifo_list[REQ_ASYNC ]); - ad->sort_list[REQ_SYNC ] =RB_ROOT ; - ad->sort_list[REQ_ASYNC ] =RB_ROOT ; ad->fifo_expire[REQ_SYNC ] = default_read_expire; ad->fifo_expire[REQ_ASYNC ] = default_write_expire; ad->antic_expire = default_antic_expire;
@@ -1383,9 +1412,6 @@ static void *as_init_queue(struct request_queue *q) ad->batch_expire[REQ_ASYNC ] = default_write_batch_expire; ad->current_batch_expires = jiffies + ad->batch_expire[REQ_SYNC ]; - ad->write_batch_count = ad->batch_expire[REQ_ASYNC ] /10 ; -if (ad->write_batch_count <2 ) - ad->write_batch_count =2 ;return ad; }
@@ -1482,7 +1508,6 @@ static struct elevator_type iosched_as = { .elevator_add_req_fn = as_add_request, .elevator_activate_req_fn = as_activate_request, .elevator_deactivate_req_fn = as_deactivate_request, - .elevator_queue_empty_fn = as_queue_empty, .elevator_completed_req_fn = as_completed_request, .elevator_former_req_fn = elv_rb_former_request, .elevator_latter_req_fn = elv_rb_latter_request,
@@ -1490,6 +1515,8 @@ static struct elevator_type iosched_as = { .elevator_init_fn = as_init_queue, .elevator_exit_fn = as_exit_queue, .trim = as_trim, + .elevator_alloc_sched_queue_fn = as_alloc_as_queue, + .elevator_free_sched_queue_fn = as_free_as_queue, }, .elevator_attrs = as_attrs,
block/deadline-iosched.c +71 -46
266 lines not on this page · raw message
block/elevator.c +96 -15
179 lines not on this page · raw message
block/noop-iosched.c +28 -31
111 lines not on this page · raw message
include/linux/elevator.h +6 -2
@@ -30,8 +30,9 @@ typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct requestypedef void *(elevator_init_fn ) (struct request_queue *);typedef void (elevator_exit_fn ) (struct elevator_queue *); -#ifdef CONFIG_ELV_FAIR_QUEUING +typedef void * (elevator_alloc_sched_queue_fn ) (struct request_queue *q,struct elevator_queue *eq,gfp_t );typedef void (elevator_free_sched_queue_fn ) (struct elevator_queue *,void *); +#ifdef CONFIG_ELV_FAIR_QUEUING typedef void (elevator_active_ioq_set_fn ) (struct request_queue *,void *);typedef void (elevator_active_ioq_reset_fn ) (struct request_queue *);typedef void (elevator_arm_slice_timer_fn ) (struct request_queue *,void *);
@@ -68,8 +69,9 @@ struct elevator_opselevator_exit_fn *elevator_exit_fn;void (*trim)(struct io_context *); -#ifdef CONFIG_ELV_FAIR_QUEUING +elevator_alloc_sched_queue_fn *elevator_alloc_sched_queue_fn;elevator_free_sched_queue_fn *elevator_free_sched_queue_fn; +#ifdef CONFIG_ELV_FAIR_QUEUING elevator_active_ioq_set_fn *elevator_active_ioq_set_fn;elevator_active_ioq_reset_fn *elevator_active_ioq_reset_fn;
@@ -109,6 +111,7 @@ struct elevator_queue {struct elevator_ops *ops;void *elevator_data; +void *sched_queue;struct kobject kobj;struct elevator_type *elevator_type;struct mutex sysfs_lock;
@@ -256,5 +259,6 @@ static inline int elv_iosched_fair_queuing_enabled(struct elevator_queue *e)#endif /* ELV_IOSCHED_FAIR_QUEUING */ extern void *elv_get_sched_queue (struct request_queue *q,struct request *rq);extern void *elv_select_sched_queue (struct request_queue *q,int force); +extern void *elv_get_sched_queue_current (struct request_queue *q);#endif /* CONFIG_BLOCK */ #endif
Signature · 1 line
1.6.0.1
PATCH 7/10 Prepare elevator layer for single queue schedulers
In reply to a message not in the archiveElevator layer now has support for hierarchical fair queuing. cfq has been migrated to make use of it and now it is time to do groundwork for noop, deadline and AS.
noop deadline and AS don't maintain separate queues for different processes. There is only one single queue. Effectively one can think that in hierarchical setup, there will be one queue per cgroup where requests from all the processes in the cgroup will be queued.
Generally io scheduler takes care of creating queues. Because there is only one queue here, we have modified common layer to take care of queue creation and some other functionality. This special casing helps in keeping the changes to noop, deadline and AS to the minimum.
--- block/elevator-fq.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++ block/elevator-fq.h | 67 ++++++++++++++++++++ block/elevator.c | 35 ++++++++++- include/linux/elevator.h | 14 ++++ 4 files changed, 268 insertions(+), 1 deletions(-)
block/elevator-fq.c +153 -0
@@ -857,6 +857,12 @@ void io_put_io_group_queues(struct elevator_queue *e, struct io_group *iog)/* Free up async idle queue */ elv_release_ioq (e, &iog->async_idle_queue); + +#ifdef CONFIG_GROUP_IOSCHED +/* Optimization for io schedulers having single ioq */ +if (elv_iosched_single_ioq (e)) +elv_release_ioq (e, &iog->ioq); +#endif }
@@ -1538,6 +1544,153 @@ void elv_fq_set_request_io_group(struct request_queue *q, rq->iog = iog; } +/* +* Find/Create the io queue the rq should go in. This is an optimization +* for the io schedulers (noop, deadline and AS) which maintain only single +* io queue per cgroup. In this case common layer can just maintain a +* pointer in group data structure and keeps track of it. +* +* For the io schdulers like cfq, which maintain multiple io queues per +* cgroup, and decide the io queue of request based on process, this +* function is not invoked. +*/ +int elv_fq_set_request_ioq (struct request_queue *q,struct request *rq, +gfp_t gfp_mask) +{ +struct elevator_queue *e = q->elevator; +unsigned long flags; +struct io_queue *ioq =NULL , *new_ioq =NULL ; +struct io_group *iog; +void *sched_q =NULL , *new_sched_q =NULL ; + +if (!elv_iosched_fair_queuing_enabled (e)) +return 0 ; + +might_sleep_if (gfp_mask & __GFP_WAIT); +spin_lock_irqsave (q->queue_lock, flags); + +/* Determine the io group request belongs to */ + iog = rq->iog; +BUG_ON (!iog); + +retry: +/* Get the iosched queue */ + ioq =io_group_ioq (iog); +if (!ioq) { +/* io queue and sched_queue needs to be allocated */ +BUG_ON (!e->ops->elevator_alloc_sched_queue_fn); + +if (new_sched_q) { + goto alloc_ioq; + }else if (gfp_mask & __GFP_WAIT) { +/* +* Inform the allocator of the fact that we will +* just repeat this allocation if it fails, to allow +* the allocator to do whatever it needs to attempt to +* free memory. +*/ +spin_unlock_irq (q->queue_lock); +/* Call io scheduer to create scheduler queue */ + new_sched_q = e->ops->elevator_alloc_sched_queue_fn (q, + e, gfp_mask | __GFP_NOFAIL + | __GFP_ZERO); +spin_lock_irq (q->queue_lock); + goto retry; + }else { + sched_q = e->ops->elevator_alloc_sched_queue_fn (q, e, + gfp_mask | __GFP_ZERO); +if (!sched_q) + goto queue_fail; + } + +alloc_ioq: +if (new_ioq) { + ioq = new_ioq; + new_ioq =NULL ; + sched_q = new_sched_q; + new_sched_q =NULL ; + }else if (gfp_mask & __GFP_WAIT) { +/* +* Inform the allocator of the fact that we will +* just repeat this allocation if it fails, to allow +* the allocator to do whatever it needs to attempt to +* free memory. +*/ +spin_unlock_irq (q->queue_lock); + new_ioq =elv_alloc_ioq (q, gfp_mask | __GFP_NOFAIL + | __GFP_ZERO); +spin_lock_irq (q->queue_lock); + goto retry; + }else { + ioq =elv_alloc_ioq (q, gfp_mask | __GFP_ZERO); +if (!ioq) { + e->ops->elevator_free_sched_queue_fn (e, + sched_q); + sched_q =NULL ; + goto queue_fail; + } + } + +elv_init_ioq (e, ioq, sched_q,IOPRIO_CLASS_BE ,4 ,1 ); +io_group_set_ioq (iog, ioq); +elv_mark_ioq_sync (ioq); + } + +if (new_sched_q) + e->ops->elevator_free_sched_queue_fn (q->elevator, sched_q); + +if (new_ioq) +elv_free_ioq (new_ioq); + +/* Request reference */ +elv_get_ioq (ioq); + rq->ioq = ioq; +spin_unlock_irqrestore (q->queue_lock, flags); +return 0 ; + +queue_fail: +WARN_ON ((gfp_mask & __GFP_WAIT) && !ioq); +elv_schedule_dispatch (q); +spin_unlock_irqrestore (q->queue_lock, flags); +return 1 ; +} + +/* +* Find out the io queue of current task. Optimization for single ioq +* per io group io schedulers. +*/ +struct io_queue *elv_lookup_ioq_current (struct request_queue *q) +{ +struct io_group *iog; + +/* Determine the io group and io queue of the bio submitting task */ + iog =io_lookup_io_group_current (q); +if (!iog) { +/* May be task belongs to a cgroup for which io group has +* not been setup yet. */ +return NULL ; + } +return io_group_ioq (iog); +} + +/* +* This request has been serviced. Clean up ioq info and drop the reference. +* Again this is called only for single queue per cgroup schedulers (noop, +* deadline, AS). +*/ +void elv_fq_unset_request_ioq (struct request_queue *q,struct request *rq) +{ +struct io_queue *ioq = rq->ioq; + +if (!elv_iosched_fair_queuing_enabled (q->elevator)) +return ; + +if (ioq) { + rq->ioq =NULL ; +elv_put_ioq (ioq); + } +} +#else /* GROUP_IOSCHED */ void bfq_init_entity (struct io_entity *entity,struct io_group *iog) {
block/elevator-fq.h +67 -0
90 lines not on this page · raw message
block/elevator.c +34 -1
@@ -207,6 +207,14 @@ static void *elevator_alloc_sched_queue(struct request_queue *q, {void *sched_queue =NULL ; +/* +* If fair queuing is enabled, then queue allocation takes place +* during set_request() functions when request actually comes +* in. +*/ +if (elv_iosched_fair_queuing_enabled (eq)) +return NULL ; +if (eq->ops->elevator_alloc_sched_queue_fn) { sched_queue = eq->ops->elevator_alloc_sched_queue_fn (q, eq,GFP_KERNEL );
@@ -936,6 +944,13 @@ int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)elv_fq_set_request_io_group (q, rq); +/* +* Optimization for noop, deadline and AS which maintain only single +* ioq per io group +*/ +if (elv_iosched_single_ioq (e)) +return elv_fq_set_request_ioq (q, rq, gfp_mask); +if (e->ops->elevator_set_req_fn)return e->ops->elevator_set_req_fn (q, rq, gfp_mask);
@@ -947,6 +962,15 @@ void elv_put_request(struct request_queue *q, struct request *rq) {struct elevator_queue *e = q->elevator; +/* +* Optimization for noop, deadline and AS which maintain only single +* ioq per io group +*/ +if (elv_iosched_single_ioq (e)) { +elv_fq_unset_request_ioq (q, rq); +return ; + } +if (e->ops->elevator_put_req_fn) e->ops->elevator_put_req_fn (rq); }
@@ -1329,9 +1353,18 @@ EXPORT_SYMBOL(elv_select_sched_queue);/* * Get the io scheduler queue pointer for current task. +* +* If fair queuing is enabled, determine the io group of task and retrieve +* the ioq pointer from that. This is used by only single queue ioschedulers +* for retrieving the queue associated with the group to decide whether the +* new bio can do a front merge or not. */ void *elv_get_sched_queue_current (struct request_queue *q) { -return q->elevator->sched_queue; +/* Fair queuing is not enabled. There is only one queue. */ +if (!elv_iosched_fair_queuing_enabled (q->elevator)) +return q->elevator->sched_queue; + +return ioq_sched_queue (elv_lookup_ioq_current (q)); }EXPORT_SYMBOL (elv_get_sched_queue_current);
include/linux/elevator.h +14 -0
@@ -245,17 +245,31 @@ enum {/* iosched wants to use fq logic of elevator layer */ #define ELV_IOSCHED_NEED_FQ 1 +/* iosched maintains only single ioq per group.*/ +#define ELV_IOSCHED_SINGLE_IOQ 2 +static inline int elv_iosched_fair_queuing_enabled (struct elevator_queue *e) {return (e->elevator_type->elevator_features) &ELV_IOSCHED_NEED_FQ ; } +static inline int elv_iosched_single_ioq (struct elevator_queue *e) +{ +return (e->elevator_type->elevator_features) &ELV_IOSCHED_SINGLE_IOQ ; +} +#else /* ELV_IOSCHED_FAIR_QUEUING */ static inline int elv_iosched_fair_queuing_enabled (struct elevator_queue *e) {return 0 ; } + +static inline int elv_iosched_single_ioq (struct elevator_queue *e) +{ +return 0 ; +} +#endif /* ELV_IOSCHED_FAIR_QUEUING */ extern void *elv_get_sched_queue (struct request_queue *q,struct request *rq);extern void *elv_select_sched_queue (struct request_queue *q,int force);
Signature · 1 line
1.6.0.1
PATCH 8/10 noop changes for hierarchical fair queuing
In reply to Vivek GoyalThis patch changes noop to use queue scheduling code from elevator layer. One can go back to old noop by deselecting CONFIG_IOSCHED_NOOP_HIER.
--- block/Kconfig.iosched | 11 +++++++++++ block/noop-iosched.c | 3 +++ 2 files changed, 14 insertions(+), 0 deletions(-)
block/Kconfig.iosched +11 -0
@@ -25,6 +25,17 @@ config IOSCHED_NOOP that do their own scheduling and require only minimal assistance from the kernel. +config IOSCHED_NOOP_HIER + bool "Noop Hierarchical Scheduling support" + depends on IOSCHED_NOOP && CGROUPS + select ELV_FAIR_QUEUING + select GROUP_IOSCHED + default n + ---help--- + Enable hierarhical scheduling in noop. In this mode noop keeps + one IO queue per cgroup instead of a global queue. Elevator + fair queuing logic ensures fairness among various queues. + config IOSCHED_AS tristate "Anticipatory I/O scheduler" default y
block/noop-iosched.c +3 -0
@@ -92,6 +92,9 @@ static struct elevator_type elevator_noop = { .elevator_alloc_sched_queue_fn = noop_alloc_noop_queue, .elevator_free_sched_queue_fn = noop_free_noop_queue, }, +#ifdef CONFIG_IOSCHED_NOOP_HIER + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, +#endif .elevator_name = "noop", .elevator_owner = THIS_MODULE, };
Signature · 1 line
1.6.0.1
PATCH 9/10 deadline changes for hierarchical fair queuing
In reply to Vivek GoyalThis patch changes deadline to use queue scheduling code from elevator layer. One can go back to old deadline by selecting CONFIG_IOSCHED_DEADLINE_HIER.
--- block/Kconfig.iosched | 11 +++++++++++ block/deadline-iosched.c | 3 +++ 2 files changed, 14 insertions(+), 0 deletions(-)
block/Kconfig.iosched +11 -0
@@ -55,6 +55,17 @@ config IOSCHED_DEADLINE a disk at any one time, its behaviour is almost identical to the anticipatory I/O scheduler and so is a good choice. +config IOSCHED_DEADLINE_HIER + bool "Deadline Hierarchical Scheduling support" + depends on IOSCHED_DEADLINE && CGROUPS + select ELV_FAIR_QUEUING + select GROUP_IOSCHED + default n + ---help--- + Enable hierarhical scheduling in deadline. In this mode deadline keeps + one IO queue per cgroup instead of a global queue. Elevator + fair queuing logic ensures fairness among various queues. + config IOSCHED_CFQ tristate "CFQ I/O scheduler" select ELV_FAIR_QUEUING
block/deadline-iosched.c +3 -0
@@ -477,6 +477,9 @@ static struct elevator_type iosched_deadline = { .elevator_alloc_sched_queue_fn = deadline_alloc_deadline_queue, .elevator_free_sched_queue_fn = deadline_free_deadline_queue, }, +#ifdef CONFIG_IOSCHED_DEADLINE_HIER + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, +#endif .elevator_attrs = deadline_attrs, .elevator_name = "deadline", .elevator_owner = THIS_MODULE,
Signature · 1 line
1.6.0.1
PATCH 10/10 anticipatory changes for hierarchical fair queuing
In reply to Vivek GoyalThis patch changes anticipatory scheduler to use queue scheduling code from elevator layer. One can go back to old as by deselecting CONFIG_IOSCHED_AS_HIER.
TODO/Issues
===========
- AS anticipation logic does not seem to be sufficient to provide BW difference if two "dd" are going in two different cgroups. Needs to be looked into.
- AS write batch number of request adjustment happens upon every W->R batch direction switch. This automatic adjustment depends on how much time a read is taking after a W->R switch.
This does not gel very well when hierarhical scheduling is enabled and every io group can have its separate read/write batch. Now if io group switching takes place it creates issues.
Currently I have disabled write batch length adjustment in hierarchical mode.
- Currently performance seems to be very bad in hierarhical mode. Needs to be looked into.
- I think the whole idea of common layer doing time slice switching between queues and then queue in turn running timed batches is not very good. May be AS can maintain two queues (one for READS and other for WRITES) and let common layer do the time slice switching between these two queues.
--- block/Kconfig.iosched | 12 +++ block/as-iosched.c | 176 +++++++++++++++++++++++++++++++++++++++++++++- block/elevator-fq.c | 77 ++++++++++++++++---- include/linux/elevator.h | 16 ++++ 4 files changed, 265 insertions(+), 16 deletions(-)
block/Kconfig.iosched +12 -0
@@ -45,6 +45,18 @@ config IOSCHED_AS deadline I/O scheduler, it can also be slower in some cases especially some database loads. +config IOSCHED_AS_HIER + bool "Anticipatory Hierarchical Scheduling support" + depends on IOSCHED_AS && CGROUPS + select ELV_FAIR_QUEUING + select GROUP_IOSCHED + default n + ---help--- + Enable hierarhical scheduling in anticipatory. In this mode + anticipatory keeps one IO queue per cgroup instead of a global + queue. Elevator fair queuing logic ensures fairness among various + queues. + config IOSCHED_DEADLINE tristate "Deadline I/O scheduler" default y
block/as-iosched.c +175 -1
214 lines not on this page · raw message
block/elevator-fq.c +62 -15
125 lines not on this page · raw message
include/linux/elevator.h +16 -0
@@ -40,6 +40,7 @@ typedef int (elevator_should_preempt_fn) (struct request_queue*, void*, struct request*);typedef int (elevator_update_idle_window_fn ) (struct elevator_queue *,void *,struct request *); +typedef int (elevator_expire_ioq_fn ) (struct request_queue *,void *,int ,int );#endif struct elevator_ops
@@ -78,6 +79,7 @@ struct elevator_opselevator_arm_slice_timer_fn *elevator_arm_slice_timer_fn;elevator_should_preempt_fn *elevator_should_preempt_fn;elevator_update_idle_window_fn *elevator_update_idle_window_fn; +elevator_expire_ioq_fn *elevator_expire_ioq_fn;#endif };
@@ -248,6 +250,9 @@ enum {/* iosched maintains only single ioq per group.*/ #define ELV_IOSCHED_SINGLE_IOQ 2 +/* iosched does not need anticipation/idling logic support from common layer */ +#define ELV_IOSCHED_DONT_IDLE 4 +static inline int elv_iosched_fair_queuing_enabled (struct elevator_queue *e) {return (e->elevator_type->elevator_features) &ELV_IOSCHED_NEED_FQ ;
@@ -258,6 +263,12 @@ static inline int elv_iosched_single_ioq(struct elevator_queue *e) return (e->elevator_type->elevator_features) & ELV_IOSCHED_SINGLE_IOQ; } +/* returns 1 if elevator layer should enable its idling logic, 0 otherwise */ +static inline int elv_gen_idling_enabled (struct elevator_queue *e) +{ +return !((e->elevator_type->elevator_features) &ELV_IOSCHED_DONT_IDLE ); +} +#else /* ELV_IOSCHED_FAIR_QUEUING */ static inline int elv_iosched_fair_queuing_enabled (struct elevator_queue *e)
@@ -270,6 +281,11 @@ static inline int elv_iosched_single_ioq(struct elevator_queue *e) return 0; } +static inline int elv_gen_idling_enabled (struct elevator_queue *e) +{ +return 0 ; +} +#endif /* ELV_IOSCHED_FAIR_QUEUING */ extern void *elv_get_sched_queue (struct request_queue *q,struct request *rq);extern void *elv_select_sched_queue (struct request_queue *q,int force);
Signature · 1 line
1.6.0.1
PATCH 7/10 Prepare elevator layer for single queue schedulers
In reply to Vivek GoyalElevator layer now has support for hierarchical fair queuing. cfq has been migrated to make use of it and now it is time to do groundwork for noop, deadline and AS.
noop deadline and AS don't maintain separate queues for different processes. There is only one single queue. Effectively one can think that in hierarchical setup, there will be one queue per cgroup where requests from all the processes in the cgroup will be queued.
Generally io scheduler takes care of creating queues. Because there is only one queue here, we have modified common layer to take care of queue creation and some other functionality. This special casing helps in keeping the changes to noop, deadline and AS to the minimum.
--- block/elevator-fq.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++ block/elevator-fq.h | 67 ++++++++++++++++++++ block/elevator.c | 35 ++++++++++- include/linux/elevator.h | 14 ++++ 4 files changed, 268 insertions(+), 1 deletions(-)
block/elevator-fq.c +153 -0
@@ -857,6 +857,12 @@ void io_put_io_group_queues(struct elevator_queue *e, struct io_group *iog)/* Free up async idle queue */ elv_release_ioq (e, &iog->async_idle_queue); + +#ifdef CONFIG_GROUP_IOSCHED +/* Optimization for io schedulers having single ioq */ +if (elv_iosched_single_ioq (e)) +elv_release_ioq (e, &iog->ioq); +#endif }
@@ -1538,6 +1544,153 @@ void elv_fq_set_request_io_group(struct request_queue *q, rq->iog = iog; } +/* +* Find/Create the io queue the rq should go in. This is an optimization +* for the io schedulers (noop, deadline and AS) which maintain only single +* io queue per cgroup. In this case common layer can just maintain a +* pointer in group data structure and keeps track of it. +* +* For the io schdulers like cfq, which maintain multiple io queues per +* cgroup, and decide the io queue of request based on process, this +* function is not invoked. +*/ +int elv_fq_set_request_ioq (struct request_queue *q,struct request *rq, +gfp_t gfp_mask) +{ +struct elevator_queue *e = q->elevator; +unsigned long flags; +struct io_queue *ioq =NULL , *new_ioq =NULL ; +struct io_group *iog; +void *sched_q =NULL , *new_sched_q =NULL ; + +if (!elv_iosched_fair_queuing_enabled (e)) +return 0 ; + +might_sleep_if (gfp_mask & __GFP_WAIT); +spin_lock_irqsave (q->queue_lock, flags); + +/* Determine the io group request belongs to */ + iog = rq->iog; +BUG_ON (!iog); + +retry: +/* Get the iosched queue */ + ioq =io_group_ioq (iog); +if (!ioq) { +/* io queue and sched_queue needs to be allocated */ +BUG_ON (!e->ops->elevator_alloc_sched_queue_fn); + +if (new_sched_q) { + goto alloc_ioq; + }else if (gfp_mask & __GFP_WAIT) { +/* +* Inform the allocator of the fact that we will +* just repeat this allocation if it fails, to allow +* the allocator to do whatever it needs to attempt to +* free memory. +*/ +spin_unlock_irq (q->queue_lock); +/* Call io scheduer to create scheduler queue */ + new_sched_q = e->ops->elevator_alloc_sched_queue_fn (q, + e, gfp_mask | __GFP_NOFAIL + | __GFP_ZERO); +spin_lock_irq (q->queue_lock); + goto retry; + }else { + sched_q = e->ops->elevator_alloc_sched_queue_fn (q, e, + gfp_mask | __GFP_ZERO); +if (!sched_q) + goto queue_fail; + } + +alloc_ioq: +if (new_ioq) { + ioq = new_ioq; + new_ioq =NULL ; + sched_q = new_sched_q; + new_sched_q =NULL ; + }else if (gfp_mask & __GFP_WAIT) { +/* +* Inform the allocator of the fact that we will +* just repeat this allocation if it fails, to allow +* the allocator to do whatever it needs to attempt to +* free memory. +*/ +spin_unlock_irq (q->queue_lock); + new_ioq =elv_alloc_ioq (q, gfp_mask | __GFP_NOFAIL + | __GFP_ZERO); +spin_lock_irq (q->queue_lock); + goto retry; + }else { + ioq =elv_alloc_ioq (q, gfp_mask | __GFP_ZERO); +if (!ioq) { + e->ops->elevator_free_sched_queue_fn (e, + sched_q); + sched_q =NULL ; + goto queue_fail; + } + } + +elv_init_ioq (e, ioq, sched_q,IOPRIO_CLASS_BE ,4 ,1 ); +io_group_set_ioq (iog, ioq); +elv_mark_ioq_sync (ioq); + } + +if (new_sched_q) + e->ops->elevator_free_sched_queue_fn (q->elevator, sched_q); + +if (new_ioq) +elv_free_ioq (new_ioq); + +/* Request reference */ +elv_get_ioq (ioq); + rq->ioq = ioq; +spin_unlock_irqrestore (q->queue_lock, flags); +return 0 ; + +queue_fail: +WARN_ON ((gfp_mask & __GFP_WAIT) && !ioq); +elv_schedule_dispatch (q); +spin_unlock_irqrestore (q->queue_lock, flags); +return 1 ; +} + +/* +* Find out the io queue of current task. Optimization for single ioq +* per io group io schedulers. +*/ +struct io_queue *elv_lookup_ioq_current (struct request_queue *q) +{ +struct io_group *iog; + +/* Determine the io group and io queue of the bio submitting task */ + iog =io_lookup_io_group_current (q); +if (!iog) { +/* May be task belongs to a cgroup for which io group has +* not been setup yet. */ +return NULL ; + } +return io_group_ioq (iog); +} + +/* +* This request has been serviced. Clean up ioq info and drop the reference. +* Again this is called only for single queue per cgroup schedulers (noop, +* deadline, AS). +*/ +void elv_fq_unset_request_ioq (struct request_queue *q,struct request *rq) +{ +struct io_queue *ioq = rq->ioq; + +if (!elv_iosched_fair_queuing_enabled (q->elevator)) +return ; + +if (ioq) { + rq->ioq =NULL ; +elv_put_ioq (ioq); + } +} +#else /* GROUP_IOSCHED */ void bfq_init_entity (struct io_entity *entity,struct io_group *iog) {
block/elevator-fq.h +67 -0
90 lines not on this page · raw message
block/elevator.c +34 -1
@@ -207,6 +207,14 @@ static void *elevator_alloc_sched_queue(struct request_queue *q, {void *sched_queue =NULL ; +/* +* If fair queuing is enabled, then queue allocation takes place +* during set_request() functions when request actually comes +* in. +*/ +if (elv_iosched_fair_queuing_enabled (eq)) +return NULL ; +if (eq->ops->elevator_alloc_sched_queue_fn) { sched_queue = eq->ops->elevator_alloc_sched_queue_fn (q, eq,GFP_KERNEL );
@@ -936,6 +944,13 @@ int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)elv_fq_set_request_io_group (q, rq); +/* +* Optimization for noop, deadline and AS which maintain only single +* ioq per io group +*/ +if (elv_iosched_single_ioq (e)) +return elv_fq_set_request_ioq (q, rq, gfp_mask); +if (e->ops->elevator_set_req_fn)return e->ops->elevator_set_req_fn (q, rq, gfp_mask);
@@ -947,6 +962,15 @@ void elv_put_request(struct request_queue *q, struct request *rq) {struct elevator_queue *e = q->elevator; +/* +* Optimization for noop, deadline and AS which maintain only single +* ioq per io group +*/ +if (elv_iosched_single_ioq (e)) { +elv_fq_unset_request_ioq (q, rq); +return ; + } +if (e->ops->elevator_put_req_fn) e->ops->elevator_put_req_fn (rq); }
@@ -1329,9 +1353,18 @@ EXPORT_SYMBOL(elv_select_sched_queue);/* * Get the io scheduler queue pointer for current task. +* +* If fair queuing is enabled, determine the io group of task and retrieve +* the ioq pointer from that. This is used by only single queue ioschedulers +* for retrieving the queue associated with the group to decide whether the +* new bio can do a front merge or not. */ void *elv_get_sched_queue_current (struct request_queue *q) { -return q->elevator->sched_queue; +/* Fair queuing is not enabled. There is only one queue. */ +if (!elv_iosched_fair_queuing_enabled (q->elevator)) +return q->elevator->sched_queue; + +return ioq_sched_queue (elv_lookup_ioq_current (q)); }EXPORT_SYMBOL (elv_get_sched_queue_current);
include/linux/elevator.h +14 -0
@@ -245,17 +245,31 @@ enum {/* iosched wants to use fq logic of elevator layer */ #define ELV_IOSCHED_NEED_FQ 1 +/* iosched maintains only single ioq per group.*/ +#define ELV_IOSCHED_SINGLE_IOQ 2 +static inline int elv_iosched_fair_queuing_enabled (struct elevator_queue *e) {return (e->elevator_type->elevator_features) &ELV_IOSCHED_NEED_FQ ; } +static inline int elv_iosched_single_ioq (struct elevator_queue *e) +{ +return (e->elevator_type->elevator_features) &ELV_IOSCHED_SINGLE_IOQ ; +} +#else /* ELV_IOSCHED_FAIR_QUEUING */ static inline int elv_iosched_fair_queuing_enabled (struct elevator_queue *e) {return 0 ; } + +static inline int elv_iosched_single_ioq (struct elevator_queue *e) +{ +return 0 ; +} +#endif /* ELV_IOSCHED_FAIR_QUEUING */ extern void *elv_get_sched_queue (struct request_queue *q,struct request *rq);extern void *elv_select_sched_queue (struct request_queue *q,int force);
Signature · 1 line
1.6.0.1
PATCH 3/10 Modify cfq to make use of flat elevator fair queuing
In reply to Vivek GoyalThis patch changes cfq to use fair queuing code from elevator layer.
o must_dispatch logic sounds like a dead code. Nobody seems to be making use of that flag. Retaining it for the time being.
--- block/Kconfig.iosched | 3 +- block/cfq-iosched.c | 1082 +++++++++++-------------------------------------- 2 files changed, 232 insertions(+), 853 deletions(-)
block/Kconfig.iosched +2 -1
@@ -3,7 +3,7 @@ if BLOCK menu "IO Schedulers" config ELV_FAIR_QUEUING - bool "Elevator Fair Queuing Support" + bool default n ---help--- Traditionally only cfq had notion of multiple queues and it did
@@ -46,6 +46,7 @@ config IOSCHED_DEADLINE config IOSCHED_CFQ tristate "CFQ I/O scheduler" + select ELV_FAIR_QUEUING default y ---help--- The CFQ I/O scheduler tries to distribute bandwidth equally
block/cfq-iosched.c +230 -852
1,757 lines not on this page · raw message
Signature · 1 line
1.6.0.1
PATCH 2/10 Common flat fair queuing code in elevaotor layer
In reply to Vivek GoyalThis is common fair queuing code in elevator layer. This is controlled by config option CONFIG_ELV_FAIR_QUEUING. This patch initially only introduces flat fair queuing support where there is only one group, "root group" and all the tasks belong to root group.
This elevator layer changes are backward compatible. That means any ioscheduler using old interfaces will continue to work.
--- block/Kconfig.iosched | 13 + block/Makefile | 1 + block/blk-sysfs.c | 10 + block/elevator-fq.c | 1882 ++++++++++++++++++++++++++++++++++++++++++++++ block/elevator-fq.h | 479 ++++++++++++ block/elevator.c | 46 +- include/linux/blkdev.h | 5 + include/linux/elevator.h | 48 ++ 8 files changed, 2473 insertions(+), 11 deletions(-) create mode 100644 block/elevator-fq.c create mode 100644 block/elevator-fq.h
block/Kconfig.iosched +13 -0
@@ -2,6 +2,19 @@ if BLOCK menu "IO Schedulers" +config ELV_FAIR_QUEUING + bool "Elevator Fair Queuing Support" + default n + ---help--- + Traditionally only cfq had notion of multiple queues and it did + fair queuing at its own. With the cgroups and need of controlling + IO, now even the simple io schedulers like noop, deadline, as will + have one queue per cgroup and will need hierarchical fair queuing. + Instead of every io scheduler implementing its own fair queuing + logic, this option enables fair queuing in elevator layer so that + other ioschedulers can make use of it. + If unsure, say N. + config IOSCHED_NOOP bool default y
block/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o obj-$(CONFIG_BLK_DEV_INTEGRITY) += blk-integrity.o +obj-$(CONFIG_ELV_FAIR_QUEUING) += elevator-fq.o
block/blk-sysfs.c +10 -0
@@ -276,6 +276,13 @@ static struct queue_sysfs_entry queue_iostats_entry = { .store = queue_iostats_store, }; +#ifdef CONFIG_ELV_FAIR_QUEUING +static struct queue_sysfs_entry queue_slice_idle_entry = { + .attr = {.name ="slice_idle" , .mode =S_IRUGO |S_IWUSR }, + .show = elv_slice_idle_show, + .store = elv_slice_idle_store, +}; +#endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr, &queue_ra_entry.attr,
@@ -287,6 +294,9 @@ static struct attribute *default_attrs[] = { &queue_nomerges_entry.attr, &queue_rq_affinity_entry.attr, &queue_iostats_entry.attr, +#ifdef CONFIG_ELV_FAIR_QUEUING + &queue_slice_idle_entry.attr, +#endif NULL, };
block/elevator-fq.c new file +1882 -0
1,882 lines not on this page · raw message
block/elevator-fq.h new file +479 -0
479 lines not on this page · raw message
block/elevator.c +35 -11
116 lines not on this page · raw message
include/linux/blkdev.h +5 -0
@@ -234,6 +234,11 @@ struct request {/* for bidi */ struct request *next_rq; + +#ifdef CONFIG_ELV_FAIR_QUEUING +/* io queue request belongs to */ +struct io_queue *ioq; +#endif };static inline unsigned short req_get_ioprio (struct request *req)
include/linux/elevator.h +48 -0
83 lines not on this page · raw message
Signature · 1 line
1.6.0.1
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.
Thank you,
Takuya Yoshikawa
Quoted 49 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Thanks
Vivek
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.
Thank you,
Takuya Yoshikawa
Quoted 49 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Thanks
Vivek
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Hi Vivek,
It would be very appreciated if the patches can be based on 2.6.28.
Thanks a lot.
Anqin
Quoted 66 lines · Takuya Yoshikawa
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.Thank you,
Takuya YoshikawaQuoted 42 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Quoted 7 lines
Thanks
Vivek
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Hi Vivek,
It would be very appreciated if the patches can be based on 2.6.28.
Thanks a lot.
Anqin
Quoted 66 lines · Takuya Yoshikawa
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.Thank you,
Takuya YoshikawaQuoted 42 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Quoted 7 lines
Thanks
Vivek
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers
(Please don't top-post...)
Quoted 4 lines · anqin
Hi Vivek,
It would be very appreciated if the patches can be based on 2.6.28.
Why? When this is ready to be merged, then it should be based on Jens' block-tree, or akpm's mm tree. And this version currently is based on 2.6.29-rc4, so if you want to try it out, just prepare a 2.6.29-rc4 kernel tree.
Quoted 14 lines
Thanks a lot.
Anqin
Quoted 8 lines · Takuya Yoshikawa
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.Thank you,
Takuya Yoshikawa
(Please don't top-post...)
Quoted 4 lines · anqin
Hi Vivek,
It would be very appreciated if the patches can be based on 2.6.28.
Why? When this is ready to be merged, then it should be based on Jens' block-tree, or akpm's mm tree. And this version currently is based on 2.6.29-rc4, so if you want to try it out, just prepare a 2.6.29-rc4 kernel tree.
Quoted 14 lines
Thanks a lot.
Anqin
Quoted 8 lines · Takuya Yoshikawa
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.Thank you,
Takuya Yoshikawa
Quoted 4 lines
Why? When this is ready to be merged, then it should be based on Jens' block-tree, or akpm's mm tree. And this version currently is based on 2.6.29-rc4, so if you want to try it out, just prepare a 2.6.29-rc4 kernel tree.
I have checked the LKML and see these patches (on web pages) are based on 2.6.27. It seemed too old.
You mean that the codes have new patch files in 2.6.29-rc4?
Quoted 4 lines
Why? When this is ready to be merged, then it should be based on Jens' block-tree, or akpm's mm tree. And this version currently is based on 2.6.29-rc4, so if you want to try it out, just prepare a 2.6.29-rc4 kernel tree.
I have checked the LKML and see these patches (on web pages) are based on 2.6.27. It seemed too old.
You mean that the codes have new patch files in 2.6.29-rc4?
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalDocumentation/block/io-controller.txt line 114
Quoted 4 lines · On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal…
Documentation/block/io-controller.txt new file +4
-0+Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.
You handled this problem pretty neatly!
It's always been a BIG problem for all the io-controlling schemes, and most of them seem to have "handled" it in the above way :(
But for many workloads, writeback is the majority of the IO and it has always been the form of IO which has caused us the worst contention and latency problems. So I don't think that we can proceed with _anything_ until we at least have a convincing plan here.
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
So my question is: what is the definitive list of proposed-io-controller-implementations and how do I cunningly get all you guys to check each others homework? :)
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalDon't forget to update the 00-INDEX file when you add a new doc.^!^
Quoted 235 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +221
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/s
Signature · 2 lines
Regards Yang Hongyang
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 225 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +211
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +=================
Documentation/block/io-controller.txt line 221
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/s
Hi Vivek,
I would be interested in knowing if these are the results expected?
Signature · 2 lines
regards, Dhaval
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 225 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +211
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +=================
Documentation/block/io-controller.txt line 221
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/s
Hi Vivek,
I would be interested in knowing if these are the results expected?
Signature · 2 lines
regards, Dhaval
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveHi Andrew,
Quoted 6 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I'm developing dm-ioband, which is an another IO controller, and I would like to hear your comments about dm-ioband if you have.
dm-ioband web page:
http://people.valinux.co.jp/~ryov/dm-ioband/
Quoted 3 lines
So my question is: what is the definitive list of proposed-io-controller-implementations and how do I cunningly get all you guys to check each others homework? :)
Dm-ioband is implemented as a device-mapper driver, so I'm proposing dm-ioband to dm-devel and I hope device-mapper staffs take care of it.
Thanks,
Ryo Tsuruta
Re: [PATCH 01/10] Documentation
In reply to Andrew MortonHi Andrew,
Quoted 6 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I'm developing dm-ioband, which is an another IO controller, and I would like to hear your comments about dm-ioband if you have.
dm-ioband web page:
http://people.valinux.co.jp/~ryov/dm-ioband/
Quoted 3 lines
So my question is: what is the definitive list of proposed-io-controller-implementations and how do I cunningly get all you guys to check each others homework? :)
Dm-ioband is implemented as a device-mapper driver, so I'm proposing dm-ioband to dm-devel and I hope device-mapper staffs take care of it.
Thanks,
Ryo Tsuruta
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 27 lines · Vivek Goyal
Documentation/block/io-controller.txt new file +27
-0+Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and changing IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierarchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for providing fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this
Documentation/block/io-controller.txt line 152
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical.
One worry I have is that these are compile time switches. Is there any way you can get the old AS/DEADLINE back when these are enabled but you're not actively using cgroups?
Quoted 6 lines · Takuya Yoshikawa
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.
Hi Takuya,
These apply on linus git tree (2.6.29-rc7).
Thanks
Vivek
Quoted 54 lines
Thank you,
Takuya YoshikawaQuoted 49 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Thanks
Vivek
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Quoted 4 lines · anqin
Hi Vivek,
It would be very appreciated if the patches can be based on 2.6.28.
Hi Anquin,
I think most of the people want to test new patches on latest kernels so I will keep it that way. You can backport it to previous kernels if you really need to. For me it will become very difficult to maintain two versions.
Is there any reason why you can't move to latest kernels?
Thanks
Vivek
Quoted 72 lines
Thanks a lot.
Anqin
Quoted 66 lines · Takuya Yoshikawa
Hi Vivek,
Could you tell me to which kernel I can apply your patches?
# latest mm? I would like to test your controller.Thank you,
Takuya YoshikawaQuoted 42 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Implementing IO controller will not cover the devices which don't use IO schedulers but it should cover the common case.
There were more discussions regarding 2 level vs 1 level IO control at following link.
https://lists.linux-foundation.org/pipermail/containers/2009-January/015402.html
So in the mean time we took the discussion off the list and spent time on making the 1 level control apporoach work where majority of the proportional weight control is shared by the four schedulers instead of each one having to replicate the code. We make use of BFQ code for fair queuing as posted by Paolo and Fabio here.
http://lkml.org/lkml/2008/11/11/148
Details about design and howto have been put in documentation patch.
I have done very basic testing of running 2 or 3 "dd" threads in different cgroups. Wanted to get the patchset out for feedback/review before we dive into more bug fixing, benchmarking, optimizations etc.
Your feedback/comments are welcome.
Patch series contains 10 patches. It should be compilable and bootable after every patch. Intial 2 patches implement flat fair queuing (no cgroup support) and make cfq to use that. Later patches introduce hierarchical fair queuing support in elevator layer and modify other IO schdulers to use that.
Quoted 7 lines
Thanks
Vivek
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 2 lines · Yang Hongyang
Don't forget to update the 00-INDEX file when you add a new doc.^!^
Thanks. Will do it.
Vivek
Quoted 241 lines
Quoted 235 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +221
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sSignature · 2 lines
Regards Yang Hongyang
Re: [PATCH 01/10] Documentation
In reply to Yang HongyangQuoted 2 lines · Yang Hongyang
Don't forget to update the 00-INDEX file when you add a new doc.^!^
Thanks. Will do it.
Vivek
Quoted 241 lines
Quoted 235 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +221
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sSignature · 2 lines
Regards Yang Hongyang
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 239 lines · Dhaval Giani
Quoted 225 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +211
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +=================Documentation/block/io-controller.txt line 221
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sHi Vivek,
Quoted 2 lines
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "total_serivce" received by each queue.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Dhaval GianiQuoted 239 lines · Dhaval Giani
Quoted 225 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +211
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight. + +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. + +Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing + the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. + +- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue. + + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). + +A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group. + +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought. +- Use of bio-cgroup patches. +- Use of Nauman's per cgroup request descriptor patches. + +HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio + +- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +=================Documentation/block/io-controller.txt line 221
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sHi Vivek,
Quoted 2 lines
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "total_serivce" received by each queue.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Peter ZijlstraQuoted 34 lines · Peter Zijlstra
Quoted 33 lines · Vivek Goyal
Documentation/block/io-controller.txt new file +33
-0+Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and changing IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierarchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for providing fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. +
Quoted 8 lines
Documentation/block/io-controller.txt line 152
Quoted 4 lines
Documentation/block/io-controller.txt new file +4
-0+CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical.One worry I have is that these are compile time switches. Is there any way you can get the old AS/DEADLINE back when these are enabled but you're not actively using cgroups?
Hi Peter,
In principle, if one is not using cgroups, there is only one io queue in the root group and most likely we should achieve the same behavior as old schedulers. Just that some extra code gets into execution at runtime.
I have not got a chance yet to do some numbers but I think this path can be optimized enough that at run time effectively we don't see any significant performance penalty and behavior of schedulers is almost same as old ones.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Peter ZijlstraQuoted 34 lines · Peter Zijlstra
Quoted 33 lines · Vivek Goyal
Documentation/block/io-controller.txt new file +33
-0+Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and changing IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierarchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for providing fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. +
Quoted 8 lines
Documentation/block/io-controller.txt line 152
Quoted 4 lines
Documentation/block/io-controller.txt new file +4
-0+CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical.One worry I have is that these are compile time switches. Is there any way you can get the old AS/DEADLINE back when these are enabled but you're not actively using cgroups?
Hi Peter,
In principle, if one is not using cgroups, there is only one io queue in the root group and most likely we should achieve the same behavior as old schedulers. Just that some extra code gets into execution at runtime.
I have not got a chance yet to do some numbers but I think this path can be optimized enough that at run time effectively we don't see any significant performance penalty and behavior of schedulers is almost same as old ones.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 4 lines
From: Vivek Goyal <[email protected]>
Date: Thu, Mar 12, 2009 10:04:50AM -0400On Thu, Mar 12, 2009 at 03:30:54PM +0530, Dhaval Giani wrote:
...
Quoted 33 lines
Quoted 15 lines
Documentation/block/io-controller.txt line 221
Quoted 12 lines
Documentation/block/io-controller.txt new file +12
-0+Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sHi Vivek,
Quoted 2 lines
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 8 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.
There is also another issue to consider; to achieve a proper weighted distribution of ``service time'' (assuming that service time can be attributed accurately) over any time window, we need also that the tasks actually compete for disk service during this window.
For example, in the case above with three tasks, the highest weight task terminates earlier than the other ones, so we have two time frames:
during the first one disk time is divided among all the three tasks according to their weights, then the highest weight one terminates, and disk time is divided (equally) among the remaining ones.
Quoted 9 lines · anqin
Quoted 4 lines
Why? When this is ready to be merged, then it should be based on Jens' block-tree, or akpm's mm tree. And this version currently is based on 2.6.29-rc4, so if you want to try it out, just prepare a 2.6.29-rc4 kernel tree.
I have checked the LKML and see these patches (on web pages) are based on 2.6.27. It seemed too old.
You mean that the codes have new patch files in 2.6.29-rc4?
I guess my mistake that I did not specify the kernel version in my mail.
These patches should apply on top of 2.6.29-rc7.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 52 lines · Fabio Checconi
Quoted 4 lines
From: Vivek Goyal <[email protected]>
Date: Thu, Mar 12, 2009 10:04:50AM -0400On Thu, Mar 12, 2009 at 03:30:54PM +0530, Dhaval Giani wrote:
...
Quoted 33 lines
Quoted 15 lines
Documentation/block/io-controller.txt line 221
Quoted 12 lines
Documentation/block/io-controller.txt new file +12
-0+Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sHi Vivek,
Quoted 2 lines
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 8 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.There is also another issue to consider; to achieve a proper weighted distribution of ``service time'' (assuming that service time can be attributed accurately) over any time window, we need also that the tasks actually compete for disk service during this window.
Quoted 5 lines
For example, in the case above with three tasks, the highest weight task terminates earlier than the other ones, so we have two time frames:
during the first one disk time is divided among all the three tasks according to their weights, then the highest weight one terminates, and disk time is divided (equally) among the remaining ones.
True. But we can do one thing. I am printing total_service every time a queue expires(elv_ioq_served()). So when first task exits, at that point of time, we can see how much service each competing queue has received till that point and it should be proportionate to queue's weight.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Fabio ChecconiQuoted 52 lines · Fabio Checconi
Quoted 4 lines
From: Vivek Goyal <[email protected]>
Date: Thu, Mar 12, 2009 10:04:50AM -0400On Thu, Mar 12, 2009 at 03:30:54PM +0530, Dhaval Giani wrote:
...
Quoted 33 lines
Quoted 15 lines
Documentation/block/io-controller.txt line 221
Quoted 12 lines
Documentation/block/io-controller.txt new file +12
-0+Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sHi Vivek,
Quoted 2 lines
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 8 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.There is also another issue to consider; to achieve a proper weighted distribution of ``service time'' (assuming that service time can be attributed accurately) over any time window, we need also that the tasks actually compete for disk service during this window.
Quoted 5 lines
For example, in the case above with three tasks, the highest weight task terminates earlier than the other ones, so we have two time frames:
during the first one disk time is divided among all the three tasks according to their weights, then the highest weight one terminates, and disk time is divided (equally) among the remaining ones.
True. But we can do one thing. I am printing total_service every time a queue expires(elv_ioq_served()). So when first task exits, at that point of time, we can see how much service each competing queue has received till that point and it should be proportionate to queue's weight.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 9 lines · Andrew Morton
Documentation/block/io-controller.txt line 114
Quoted 4 lines · On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal…
Documentation/block/io-controller.txt new file +4
-0+Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.You handled this problem pretty neatly!
Quoted 8 lines
It's always been a BIG problem for all the io-controlling schemes, and most of them seem to have "handled" it in the above way :(
But for many workloads, writeback is the majority of the IO and it has always been the form of IO which has caused us the worst contention and latency problems. So I don't think that we can proceed with _anything_ until we at least have a convincing plan here.
Hi Andrew,
Nauman is already maintaining the bio-cgroup patches (originally from valinux folks) on top of this patchset for attributing write requests to correct cgroup. We did not include those in initial posting thinking that patchest will bloat further.
We can pull in bio-cgroup patches also in this series to attribute writes to right cgroup.
Quoted 8 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
- Above problems will comound when one goes for deeper hierarhical configurations.
I think for renewable resources like disk time, it might be a good idea to do a proportional weight controller to ensure fairness at the same time achive best throughput possible.
Andrea, please correct me if I have misunderstood the things.
Quoted 3 lines
So my question is: what is the definitive list of proposed-io-controller-implementations and how do I cunningly get all you guys to check each others homework? :)
I will try to summarize some of the proposals I am aware of.
- Elevator/IO scheduler modification based IO controllers
- This proposal
- cfq io scheduler based control (Satoshi Uchida, NEC)
- One more cfq based io control (vasily, OpenVZ)
- AS io scheduler based control (Naveen Gupta, Google)
- Io-throttling (Andrea Righi)
- Max Bandwidth Controller
- dm-ioband (valinux)
- Proportional weight IO controller.
- Generic IO controller (Vivek Goyal, RedHat)
- My initial attempt to do proportional division of amount of bio per cgroup at request queue level. This was inspired from dm-ioband.
I think this proposal should hopefully meet the requirements as envisoned by other elevator based IO controller solutions.
dm-ioband
---------
I have briefly looked at dm-ioband also and following were some of the concerns I had raised in the past.
- Need of a dm device for every device we want to control
- This requirement looks odd. It forces everybody to use dm-tools and if there are lots of disks in the system, configuation is pain.
- It does not support hiearhical grouping.
- Possibly can break the assumptions of underlying IO schedulers.
- There is no notion of task classes. So tasks of all the classes are at same level from resource contention point of view. The only thing which differentiates them is cgroup weight. Which does not answer the question that an RT task or RT cgroup should starve the peer cgroup if need be as RT cgroup should get priority access.
- Because of FIFO release of buffered bios, it is possible that task of lower priority gets more IO done than the task of higher priority.
- Buffering at multiple levels and FIFO dispatch can have more interesting hard to solve issues.
- Assume there is sequential reader and an aggressive writer in the cgroup. It might happen that writer pushed lot of write requests in the FIFO queue first and then a read request from reader comes. Now it might happen that cfq does not see this read request for a long time (if cgroup weight is less) and this writer will starve the reader in this cgroup.
Even cfq anticipation logic will not help here because when that first read request actually gets to cfq, cfq might choose to idle for more read requests to come, but the agreesive writer might have again flooded the FIFO queue in the group and cfq will not see subsequent read request for a long time and will unnecessarily idle for read.
- Task grouping logic
- We already have the notion of cgroup where tasks can be grouped in hierarhical manner. dm-ioband does not make full use of that and comes up with own mechansim of grouping tasks (apart from cgroup). And there are odd ways of specifying cgroup id while configuring the dm-ioband device.
IMHO, once somebody has created the cgroup hieararchy, any IO controller logic should be able to internally read that hiearchy and provide control. There should not be need of any other configuration utity on top of cgroup.
My RFC patches had tried to get rid of this external configuration requirement.
- Task and Groups can not be treated at same level.
- Because at any second level solution we are controlling bio per cgroup and don't have any notion of which task queue bio belongs to, one can not treat task and group at same level.
What I meant is following.
root
/ | \
1 2 A
/ \
3 4
In dm-ioband approach, at top level tasks 1 and 2 will get 50% of BW together and group A will get 50%. Ideally along the lines of cpu controller, I would expect it to be 33% each for task 1 task 2 and group A.
This can create interesting scenarios where assumg task1 is an RT class task. Now one would expect task 1 get all the BW possible starving task 2 and group A, but that will not be the case and task1 will get 50% of BW.
Not that it is critically important but it would probably be nice if we can maitain same semantics as cpu controller. In elevator layer solution we can do it at least for CFQ scheduler as it maintains separate io queue per io context.
This is in general an issue for any 2nd level IO controller which only accounts for io groups and not for io queues per process.
- We will end copying a lot of code/logic from cfq
- To address many of the concerns like multi class scheduler we will end up duplicating code of IO scheduler. Why can't we have a one point hierarchical IO scheduling (This patchset).
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Andrew MortonQuoted 9 lines · Andrew Morton
Documentation/block/io-controller.txt line 114
Quoted 4 lines · On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
Documentation/block/io-controller.txt new file +4
-0+Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.You handled this problem pretty neatly!
Quoted 8 lines
It's always been a BIG problem for all the io-controlling schemes, and most of them seem to have "handled" it in the above way :(
But for many workloads, writeback is the majority of the IO and it has always been the form of IO which has caused us the worst contention and latency problems. So I don't think that we can proceed with _anything_ until we at least have a convincing plan here.
Hi Andrew,
Nauman is already maintaining the bio-cgroup patches (originally from valinux folks) on top of this patchset for attributing write requests to correct cgroup. We did not include those in initial posting thinking that patchest will bloat further.
We can pull in bio-cgroup patches also in this series to attribute writes to right cgroup.
Quoted 8 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
- Above problems will comound when one goes for deeper hierarhical configurations.
I think for renewable resources like disk time, it might be a good idea to do a proportional weight controller to ensure fairness at the same time achive best throughput possible.
Andrea, please correct me if I have misunderstood the things.
Quoted 3 lines
So my question is: what is the definitive list of proposed-io-controller-implementations and how do I cunningly get all you guys to check each others homework? :)
I will try to summarize some of the proposals I am aware of.
- Elevator/IO scheduler modification based IO controllers
- This proposal
- cfq io scheduler based control (Satoshi Uchida, NEC)
- One more cfq based io control (vasily, OpenVZ)
- AS io scheduler based control (Naveen Gupta, Google)
- Io-throttling (Andrea Righi)
- Max Bandwidth Controller
- dm-ioband (valinux)
- Proportional weight IO controller.
- Generic IO controller (Vivek Goyal, RedHat)
- My initial attempt to do proportional division of amount of bio per cgroup at request queue level. This was inspired from dm-ioband.
I think this proposal should hopefully meet the requirements as envisoned by other elevator based IO controller solutions.
dm-ioband
---------
I have briefly looked at dm-ioband also and following were some of the concerns I had raised in the past.
- Need of a dm device for every device we want to control
- This requirement looks odd. It forces everybody to use dm-tools and if there are lots of disks in the system, configuation is pain.
- It does not support hiearhical grouping.
- Possibly can break the assumptions of underlying IO schedulers.
- There is no notion of task classes. So tasks of all the classes are at same level from resource contention point of view. The only thing which differentiates them is cgroup weight. Which does not answer the question that an RT task or RT cgroup should starve the peer cgroup if need be as RT cgroup should get priority access.
- Because of FIFO release of buffered bios, it is possible that task of lower priority gets more IO done than the task of higher priority.
- Buffering at multiple levels and FIFO dispatch can have more interesting hard to solve issues.
- Assume there is sequential reader and an aggressive writer in the cgroup. It might happen that writer pushed lot of write requests in the FIFO queue first and then a read request from reader comes. Now it might happen that cfq does not see this read request for a long time (if cgroup weight is less) and this writer will starve the reader in this cgroup.
Even cfq anticipation logic will not help here because when that first read request actually gets to cfq, cfq might choose to idle for more read requests to come, but the agreesive writer might have again flooded the FIFO queue in the group and cfq will not see subsequent read request for a long time and will unnecessarily idle for read.
- Task grouping logic
- We already have the notion of cgroup where tasks can be grouped in hierarhical manner. dm-ioband does not make full use of that and comes up with own mechansim of grouping tasks (apart from cgroup). And there are odd ways of specifying cgroup id while configuring the dm-ioband device.
IMHO, once somebody has created the cgroup hieararchy, any IO controller logic should be able to internally read that hiearchy and provide control. There should not be need of any other configuration utity on top of cgroup.
My RFC patches had tried to get rid of this external configuration requirement.
- Task and Groups can not be treated at same level.
- Because at any second level solution we are controlling bio per cgroup and don't have any notion of which task queue bio belongs to, one can not treat task and group at same level.
What I meant is following.
root
/ | \
1 2 A
/ \
3 4
In dm-ioband approach, at top level tasks 1 and 2 will get 50% of BW together and group A will get 50%. Ideally along the lines of cpu controller, I would expect it to be 33% each for task 1 task 2 and group A.
This can create interesting scenarios where assumg task1 is an RT class task. Now one would expect task 1 get all the BW possible starving task 2 and group A, but that will not be the case and task1 will get 50% of BW.
Not that it is critically important but it would probably be nice if we can maitain same semantics as cpu controller. In elevator layer solution we can do it at least for CFQ scheduler as it maintains separate io queue per io context.
This is in general an issue for any 2nd level IO controller which only accounts for io groups and not for io queues per process.
- We will end copying a lot of code/logic from cfq
- To address many of the concerns like multi class scheduler we will end up duplicating code of IO scheduler. Why can't we have a one point hierarchical IO scheduling (This patchset).
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveHi Vivek,
Quoted 10 lines
dm-ioband
---------
I have briefly looked at dm-ioband also and following were some of the concerns I had raised in the past.- Need of a dm device for every device we want to control
- This requirement looks odd. It forces everybody to use dm-tools and if there are lots of disks in the system, configuation is pain.
I don't think it's a pain. Could it be easily done by writing a small script?
Quoted 1 line
- It does not support hiearhical grouping.
I can implement hierarchical grouping to dm-ioband if it's really necessary, but at this point, I don't think it's really necessary and I want to keep the code simple.
Quoted 24 lines
- Possibly can break the assumptions of underlying IO schedulers.
- There is no notion of task classes. So tasks of all the classes are at same level from resource contention point of view. The only thing which differentiates them is cgroup weight. Which does not answer the question that an RT task or RT cgroup should starve the peer cgroup if need be as RT cgroup should get priority access.
- Because of FIFO release of buffered bios, it is possible that task of lower priority gets more IO done than the task of higher priority.
- Buffering at multiple levels and FIFO dispatch can have more interesting hard to solve issues.
- Assume there is sequential reader and an aggressive writer in the cgroup. It might happen that writer pushed lot of write requests in the FIFO queue first and then a read request from reader comes. Now it might happen that cfq does not see this read request for a long time (if cgroup weight is less) and this writer will starve the reader in this cgroup.
Quoted 6 lines
Even cfq anticipation logic will not help here because when that first read request actually gets to cfq, cfq might choose to idle for more read requests to come, but the agreesive writer might have again flooded the FIFO queue in the group and cfq will not see subsequent read request for a long time and will unnecessarily idle for read.
I think it's just a matter of which you prioritize, bandwidth or io-class. What do you do when the RT task issues a lot of I/O?
Quoted 7 lines
- Task grouping logic
- We already have the notion of cgroup where tasks can be grouped in hierarhical manner. dm-ioband does not make full use of that and comes up with own mechansim of grouping tasks (apart from cgroup). And there are odd ways of specifying cgroup id while configuring the dm-ioband device.
Quoted 7 lines
IMHO, once somebody has created the cgroup hieararchy, any IO controller logic should be able to internally read that hiearchy and provide control. There should not be need of any other configuration utity on top of cgroup.
My RFC patches had tried to get rid of this external configuration requirement.
The reason is that it makes bio-cgroup easy to use for dm-ioband. But It's not a final design of the interface between dm-ioband and cgroup.
Quoted 24 lines
- Task and Groups can not be treated at same level.
- Because at any second level solution we are controlling bio per cgroup and don't have any notion of which task queue bio belongs to, one can not treat task and group at same level.
What I meant is following.
root
/ | \
1 2 A
/ \
3 4In dm-ioband approach, at top level tasks 1 and 2 will get 50% of BW together and group A will get 50%. Ideally along the lines of cpu controller, I would expect it to be 33% each for task 1 task 2 and group A.
This can create interesting scenarios where assumg task1 is an RT class task. Now one would expect task 1 get all the BW possible starving task 2 and group A, but that will not be the case and task1 will get 50% of BW.
Quoted 4 lines
Not that it is critically important but it would probably be nice if we can maitain same semantics as cpu controller. In elevator layer solution we can do it at least for CFQ scheduler as it maintains separate io queue per io context.
I will consider following the CPU controller's manner when dm-ioband supports hierarchical grouping.
Quoted 10 lines
This is in general an issue for any 2nd level IO controller which only accounts for io groups and not for io queues per process.
- We will end copying a lot of code/logic from cfq
- To address many of the concerns like multi class scheduler we will end up duplicating code of IO scheduler. Why can't we have a one point hierarchical IO scheduling (This patchset).
Thanks
Vivek
Thanks,
Ryo Tsuruta
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalHi Vivek,
Quoted 10 lines
dm-ioband
---------
I have briefly looked at dm-ioband also and following were some of the concerns I had raised in the past.- Need of a dm device for every device we want to control
- This requirement looks odd. It forces everybody to use dm-tools and if there are lots of disks in the system, configuation is pain.
I don't think it's a pain. Could it be easily done by writing a small script?
Quoted 1 line
- It does not support hiearhical grouping.
I can implement hierarchical grouping to dm-ioband if it's really necessary, but at this point, I don't think it's really necessary and I want to keep the code simple.
Quoted 24 lines
- Possibly can break the assumptions of underlying IO schedulers.
- There is no notion of task classes. So tasks of all the classes are at same level from resource contention point of view. The only thing which differentiates them is cgroup weight. Which does not answer the question that an RT task or RT cgroup should starve the peer cgroup if need be as RT cgroup should get priority access.
- Because of FIFO release of buffered bios, it is possible that task of lower priority gets more IO done than the task of higher priority.
- Buffering at multiple levels and FIFO dispatch can have more interesting hard to solve issues.
- Assume there is sequential reader and an aggressive writer in the cgroup. It might happen that writer pushed lot of write requests in the FIFO queue first and then a read request from reader comes. Now it might happen that cfq does not see this read request for a long time (if cgroup weight is less) and this writer will starve the reader in this cgroup.
Quoted 6 lines
Even cfq anticipation logic will not help here because when that first read request actually gets to cfq, cfq might choose to idle for more read requests to come, but the agreesive writer might have again flooded the FIFO queue in the group and cfq will not see subsequent read request for a long time and will unnecessarily idle for read.
I think it's just a matter of which you prioritize, bandwidth or io-class. What do you do when the RT task issues a lot of I/O?
Quoted 7 lines
- Task grouping logic
- We already have the notion of cgroup where tasks can be grouped in hierarhical manner. dm-ioband does not make full use of that and comes up with own mechansim of grouping tasks (apart from cgroup). And there are odd ways of specifying cgroup id while configuring the dm-ioband device.
Quoted 7 lines
IMHO, once somebody has created the cgroup hieararchy, any IO controller logic should be able to internally read that hiearchy and provide control. There should not be need of any other configuration utity on top of cgroup.
My RFC patches had tried to get rid of this external configuration requirement.
The reason is that it makes bio-cgroup easy to use for dm-ioband. But It's not a final design of the interface between dm-ioband and cgroup.
Quoted 24 lines
- Task and Groups can not be treated at same level.
- Because at any second level solution we are controlling bio per cgroup and don't have any notion of which task queue bio belongs to, one can not treat task and group at same level.
What I meant is following.
root
/ | \
1 2 A
/ \
3 4In dm-ioband approach, at top level tasks 1 and 2 will get 50% of BW together and group A will get 50%. Ideally along the lines of cpu controller, I would expect it to be 33% each for task 1 task 2 and group A.
This can create interesting scenarios where assumg task1 is an RT class task. Now one would expect task 1 get all the BW possible starving task 2 and group A, but that will not be the case and task1 will get 50% of BW.
Quoted 4 lines
Not that it is critically important but it would probably be nice if we can maitain same semantics as cpu controller. In elevator layer solution we can do it at least for CFQ scheduler as it maintains separate io queue per io context.
I will consider following the CPU controller's manner when dm-ioband supports hierarchical grouping.
Quoted 10 lines
This is in general an issue for any 2nd level IO controller which only accounts for io groups and not for io queues per process.
- We will end copying a lot of code/logic from cfq
- To address many of the concerns like multi class scheduler we will end up duplicating code of IO scheduler. Why can't we have a one point hierarchical IO scheduling (This patchset).
Thanks
Vivek
Thanks,
Ryo Tsuruta
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 7 lines · Ryo Tsuruta
Hi Vivek,
Quoted 5 lines
dm-ioband
---------
I have briefly looked at dm-ioband also and following were some of the concerns I had raised in the past.
Quoted 9 lines
Quoted 5 lines
- Need of a dm device for every device we want to control
- This requirement looks odd. It forces everybody to use dm-tools and if there are lots of disks in the system, configuation is pain.
I don't think it's a pain. Could it be easily done by writing a small script?
I think it is an extra hassle which can be avoided. Following are some of the thoughts about configuration and issues. Looking at these, IMHO, it is not simple to configure dm-ioband.
- So if there are 100 disks in a system, and lets say 5 partitions on each disk, then script needs to create a dm-ioband device for every partition. So I will end up creating 500 dm-ioband devices. This is not taking into picture the dm-ioband devices people might end up creating on intermediate logical nodes.
- Need of dm tools to create devices and create groups.
- I am look at dm-ioband help on web and thinking are these commands really simple and hassle free for a user who does not use dm in his setup.
For two dm-ioband device creations on two partitions.
# echo "0 $(blockdev --getsize /dev/sda1) ioband /dev/sda1 1 0 0 none" \
"weight 0 :40" | dmsetup create ioband1
# echo "0 $(blockdev --getsize /dev/sda2) ioband /dev/sda2 1 0 0 none" \
"weight 0 :10" | dmsetup create ioband2 - Following are the commands just to create two groups on a single io-band device.
# dmsetup message ioband1 0 type user # dmsetup message ioband1 0 attach 1000 # dmsetup message ioband1 0 attach 2000 # dmsetup message ioband1 0 weight 1000:30 # dmsetup message ioband1 0 weight 2000:20
Now think of a decent size group hierarchy (say 50 groups) on 500 ioband device system. So that would be 50*500 = 25000 group creation commands.
- So if an admin wants to group applications using cgroup, first he needs to create cgroup hierarchy. Then he needs to take all the cgroup ids and provide these to this dm-ioband device with the help of dmsetup command.
dmsetup message ioband1 0 attach <cgroup id>
cgroup has already provided us nice grouping facility in hierarchical manner. This extra step is cumbersome and completely unnecessary.
- These configuration commands will become even much more complicated once you start supporting hierachical setup. All the hierarchy information shall have to passed in the command itself in one way or other once a group is being created.
- You will be limited in terms of functionlity. I am assuming these group creation operations will be limited to "root" user. A very common requiremnt we are seeming now a days is that admin will create a top level cgroup and then let user create/manage more groups with-in top level group.
For example.
root / | \ u1 u2 others
Here u1 and u2 are two different users on the system. Here admin can create top level cgroups for users and assign users weight from IO point of view. Now individual users should be able to create groups of their own and manage their tasks. Cgroup infrastructure allows all this.
In the above setup it will become very very hard to let user also create its own groups in top level group. You shall have to keep all the information which filesystem keeps in terms of file permissions etc.
So IMHO, configuration of dm-ioband devices and groups is complicated and it can be simplified a lot. Secondly, it does not seem to be a good idea to not make use of cgroup infrastrucuture and come up own ways of grouping things.
Quoted 6 lines
Quoted 1 line
- It does not support hiearhical grouping.
I can implement hierarchical grouping to dm-ioband if it's really necessary, but at this point, I don't think it's really necessary and I want to keep the code simple.
We do need hierarchical support.
In fact later in the mail you have specified that you will consider treating task and groups at same level. The moment you do that, one flat hiearchy will mean a single "root" group only and no groups with-in that. Until and unless you implement hiearchical support you can't create even single level of groups with-in "root".
Secondly, i think dm-ioband will become very complex (especially in terms of managing configuration), the moment hiearchical support is introduced. So it would be a good idea to implement the hiearchical support now and get to know the full complexity of the system.
Quoted 31 lines
Quoted 24 lines
- Possibly can break the assumptions of underlying IO schedulers.
- There is no notion of task classes. So tasks of all the classes are at same level from resource contention point of view. The only thing which differentiates them is cgroup weight. Which does not answer the question that an RT task or RT cgroup should starve the peer cgroup if need be as RT cgroup should get priority access.
- Because of FIFO release of buffered bios, it is possible that task of lower priority gets more IO done than the task of higher priority.
- Buffering at multiple levels and FIFO dispatch can have more interesting hard to solve issues.
- Assume there is sequential reader and an aggressive writer in the cgroup. It might happen that writer pushed lot of write requests in the FIFO queue first and then a read request from reader comes. Now it might happen that cfq does not see this read request for a long time (if cgroup weight is less) and this writer will starve the reader in this cgroup.
Quoted 6 lines
Even cfq anticipation logic will not help here because when that first read request actually gets to cfq, cfq might choose to idle for more read requests to come, but the agreesive writer might have again flooded the FIFO queue in the group and cfq will not see subsequent read request for a long time and will unnecessarily idle for read.
Quoted 3 lines
I think it's just a matter of which you prioritize, bandwidth or io-class. What do you do when the RT task issues a lot of I/O?
This is a multi-class scheduler. We first prioritize class and then handle tasks with-in class. So RT class will always get to dispatch first and can starve Best effort class tasks if it is issueing lots of IO.
You just don't have any notion of RT groups. So if admin wants to make sure that and RT tasks always gets the disk access first, there is no way to ensure that. The best thing in this setup one can do is assign higher weight to RT task group. This group will still be doing proportional weight scheduling with Best effort class groups or Idle task groups. That's not multi-class scheduling is.
So in your patches there is no differentiation between classes. A best effort task is competing equally hard as RT task. For example.
root / \ RT task Group (best effort class) / \ T1 T2
Here T1 and T2 are best effort class tasks and they are sharing disk bandwidth with RT task. Instead, RT task should get exclusive access to disk.
Secondly, two of the above issues I have mentioned are for tasks with-in same class and how FIFO dispatch will create the problems. These are problems with any second level controller. These will be really hard to solve the issues and will force us to copy more code from cfq and other subsystems.
Quoted 12 lines
Quoted 12 lines
- Task grouping logic
- We already have the notion of cgroup where tasks can be grouped in hierarhical manner. dm-ioband does not make full use of that and comes up with own mechansim of grouping tasks (apart from cgroup). And there are odd ways of specifying cgroup id while configuring the dm-ioband device.IMHO, once somebody has created the cgroup hieararchy, any IO controller logic should be able to internally read that hiearchy and provide control. There should not be need of any other configuration utity on top of cgroup.
Quoted 6 lines
Quoted 2 lines
My RFC patches had tried to get rid of this external configuration requirement.
The reason is that it makes bio-cgroup easy to use for dm-ioband. But It's not a final design of the interface between dm-ioband and cgroup.
It makes it easy for dm-ioband implementation but harder for the user.
What is the alternate interface?
Quoted 25 lines
Quoted 25 lines
- Task and Groups can not be treated at same level.
- Because at any second level solution we are controlling bio per cgroup and don't have any notion of which task queue bio belongs to, one can not treat task and group at same level.
What I meant is following.
root
/ | \
1 2 A
/ \
3 4In dm-ioband approach, at top level tasks 1 and 2 will get 50% of BW together and group A will get 50%. Ideally along the lines of cpu controller, I would expect it to be 33% each for task 1 task 2 and group A.
This can create interesting scenarios where assumg task1 is an RT class task. Now one would expect task 1 get all the BW possible starving task 2 and group A, but that will not be the case and task1 will get 50% of BW.
Quoted 7 lines
Quoted 4 lines
Not that it is critically important but it would probably be nice if we can maitain same semantics as cpu controller. In elevator layer solution we can do it at least for CFQ scheduler as it maintains separate io queue per io context.
I will consider following the CPU controller's manner when dm-ioband supports hierarchical grouping.
But this is an issue even now. If you want to consider task and group at the same level, then you will end up creating separate queues for all the tasks (and not only queues for groups). This will essentially become CFQ.
Quoted 9 lines
Quoted 9 lines
This is in general an issue for any 2nd level IO controller which only accounts for io groups and not for io queues per process.
- We will end copying a lot of code/logic from cfq
- To address many of the concerns like multi class scheduler we will end up duplicating code of IO scheduler. Why can't we have a one point hierarchical IO scheduling (This patchset).
More details about this point.
- To make dm-ioband support multiclass task/groups, we will end up inheriting logic from cfq/bfq.
- To treat task and group at same level we will end up creating separate queues for each task and then import lots of cfq/bfq logic for managing those queues.
- The moment we move to hiearchical support, you will end up creating equivalent logic of our patches.
The point is, why to do all this? CFQ has already solved the problem of multi class IO scheduler and providing service differentiation between tasks of different priority. With cgroup stuff, we need to just extend existing CFQ logic so that it supports hiearchical scheduling and we will have a good IO controller in place.
Can you please point out specifically why do you think extending CFQ logic to support hiearchical scheduling and sharing code with other IO schedulers is not a good idea to implement hiearchical IO control?
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Ryo TsurutaQuoted 7 lines · Ryo Tsuruta
Hi Vivek,
Quoted 5 lines
dm-ioband
---------
I have briefly looked at dm-ioband also and following were some of the concerns I had raised in the past.
Quoted 9 lines
Quoted 5 lines
- Need of a dm device for every device we want to control
- This requirement looks odd. It forces everybody to use dm-tools and if there are lots of disks in the system, configuation is pain.
I don't think it's a pain. Could it be easily done by writing a small script?
I think it is an extra hassle which can be avoided. Following are some of the thoughts about configuration and issues. Looking at these, IMHO, it is not simple to configure dm-ioband.
- So if there are 100 disks in a system, and lets say 5 partitions on each disk, then script needs to create a dm-ioband device for every partition. So I will end up creating 500 dm-ioband devices. This is not taking into picture the dm-ioband devices people might end up creating on intermediate logical nodes.
- Need of dm tools to create devices and create groups.
- I am look at dm-ioband help on web and thinking are these commands really simple and hassle free for a user who does not use dm in his setup.
For two dm-ioband device creations on two partitions.
# echo "0 $(blockdev --getsize /dev/sda1) ioband /dev/sda1 1 0 0 none" \
"weight 0 :40" | dmsetup create ioband1
# echo "0 $(blockdev --getsize /dev/sda2) ioband /dev/sda2 1 0 0 none" \
"weight 0 :10" | dmsetup create ioband2 - Following are the commands just to create two groups on a single io-band device.
# dmsetup message ioband1 0 type user # dmsetup message ioband1 0 attach 1000 # dmsetup message ioband1 0 attach 2000 # dmsetup message ioband1 0 weight 1000:30 # dmsetup message ioband1 0 weight 2000:20
Now think of a decent size group hierarchy (say 50 groups) on 500 ioband device system. So that would be 50*500 = 25000 group creation commands.
- So if an admin wants to group applications using cgroup, first he needs to create cgroup hierarchy. Then he needs to take all the cgroup ids and provide these to this dm-ioband device with the help of dmsetup command.
dmsetup message ioband1 0 attach <cgroup id>
cgroup has already provided us nice grouping facility in hierarchical manner. This extra step is cumbersome and completely unnecessary.
- These configuration commands will become even much more complicated once you start supporting hierachical setup. All the hierarchy information shall have to passed in the command itself in one way or other once a group is being created.
- You will be limited in terms of functionlity. I am assuming these group creation operations will be limited to "root" user. A very common requiremnt we are seeming now a days is that admin will create a top level cgroup and then let user create/manage more groups with-in top level group.
For example.
root / | \ u1 u2 others
Here u1 and u2 are two different users on the system. Here admin can create top level cgroups for users and assign users weight from IO point of view. Now individual users should be able to create groups of their own and manage their tasks. Cgroup infrastructure allows all this.
In the above setup it will become very very hard to let user also create its own groups in top level group. You shall have to keep all the information which filesystem keeps in terms of file permissions etc.
So IMHO, configuration of dm-ioband devices and groups is complicated and it can be simplified a lot. Secondly, it does not seem to be a good idea to not make use of cgroup infrastrucuture and come up own ways of grouping things.
Quoted 6 lines
Quoted 1 line
- It does not support hiearhical grouping.
I can implement hierarchical grouping to dm-ioband if it's really necessary, but at this point, I don't think it's really necessary and I want to keep the code simple.
We do need hierarchical support.
In fact later in the mail you have specified that you will consider treating task and groups at same level. The moment you do that, one flat hiearchy will mean a single "root" group only and no groups with-in that. Until and unless you implement hiearchical support you can't create even single level of groups with-in "root".
Secondly, i think dm-ioband will become very complex (especially in terms of managing configuration), the moment hiearchical support is introduced. So it would be a good idea to implement the hiearchical support now and get to know the full complexity of the system.
Quoted 31 lines
Quoted 24 lines
- Possibly can break the assumptions of underlying IO schedulers.
- There is no notion of task classes. So tasks of all the classes are at same level from resource contention point of view. The only thing which differentiates them is cgroup weight. Which does not answer the question that an RT task or RT cgroup should starve the peer cgroup if need be as RT cgroup should get priority access.
- Because of FIFO release of buffered bios, it is possible that task of lower priority gets more IO done than the task of higher priority.
- Buffering at multiple levels and FIFO dispatch can have more interesting hard to solve issues.
- Assume there is sequential reader and an aggressive writer in the cgroup. It might happen that writer pushed lot of write requests in the FIFO queue first and then a read request from reader comes. Now it might happen that cfq does not see this read request for a long time (if cgroup weight is less) and this writer will starve the reader in this cgroup.
Quoted 6 lines
Even cfq anticipation logic will not help here because when that first read request actually gets to cfq, cfq might choose to idle for more read requests to come, but the agreesive writer might have again flooded the FIFO queue in the group and cfq will not see subsequent read request for a long time and will unnecessarily idle for read.
Quoted 3 lines
I think it's just a matter of which you prioritize, bandwidth or io-class. What do you do when the RT task issues a lot of I/O?
This is a multi-class scheduler. We first prioritize class and then handle tasks with-in class. So RT class will always get to dispatch first and can starve Best effort class tasks if it is issueing lots of IO.
You just don't have any notion of RT groups. So if admin wants to make sure that and RT tasks always gets the disk access first, there is no way to ensure that. The best thing in this setup one can do is assign higher weight to RT task group. This group will still be doing proportional weight scheduling with Best effort class groups or Idle task groups. That's not multi-class scheduling is.
So in your patches there is no differentiation between classes. A best effort task is competing equally hard as RT task. For example.
root / \ RT task Group (best effort class) / \ T1 T2
Here T1 and T2 are best effort class tasks and they are sharing disk bandwidth with RT task. Instead, RT task should get exclusive access to disk.
Secondly, two of the above issues I have mentioned are for tasks with-in same class and how FIFO dispatch will create the problems. These are problems with any second level controller. These will be really hard to solve the issues and will force us to copy more code from cfq and other subsystems.
Quoted 12 lines
Quoted 12 lines
- Task grouping logic
- We already have the notion of cgroup where tasks can be grouped in hierarhical manner. dm-ioband does not make full use of that and comes up with own mechansim of grouping tasks (apart from cgroup). And there are odd ways of specifying cgroup id while configuring the dm-ioband device.IMHO, once somebody has created the cgroup hieararchy, any IO controller logic should be able to internally read that hiearchy and provide control. There should not be need of any other configuration utity on top of cgroup.
Quoted 6 lines
Quoted 2 lines
My RFC patches had tried to get rid of this external configuration requirement.
The reason is that it makes bio-cgroup easy to use for dm-ioband. But It's not a final design of the interface between dm-ioband and cgroup.
It makes it easy for dm-ioband implementation but harder for the user.
What is the alternate interface?
Quoted 25 lines
Quoted 25 lines
- Task and Groups can not be treated at same level.
- Because at any second level solution we are controlling bio per cgroup and don't have any notion of which task queue bio belongs to, one can not treat task and group at same level.
What I meant is following.
root
/ | \
1 2 A
/ \
3 4In dm-ioband approach, at top level tasks 1 and 2 will get 50% of BW together and group A will get 50%. Ideally along the lines of cpu controller, I would expect it to be 33% each for task 1 task 2 and group A.
This can create interesting scenarios where assumg task1 is an RT class task. Now one would expect task 1 get all the BW possible starving task 2 and group A, but that will not be the case and task1 will get 50% of BW.
Quoted 7 lines
Quoted 4 lines
Not that it is critically important but it would probably be nice if we can maitain same semantics as cpu controller. In elevator layer solution we can do it at least for CFQ scheduler as it maintains separate io queue per io context.
I will consider following the CPU controller's manner when dm-ioband supports hierarchical grouping.
But this is an issue even now. If you want to consider task and group at the same level, then you will end up creating separate queues for all the tasks (and not only queues for groups). This will essentially become CFQ.
Quoted 9 lines
Quoted 9 lines
This is in general an issue for any 2nd level IO controller which only accounts for io groups and not for io queues per process.
- We will end copying a lot of code/logic from cfq
- To address many of the concerns like multi class scheduler we will end up duplicating code of IO scheduler. Why can't we have a one point hierarchical IO scheduling (This patchset).
More details about this point.
- To make dm-ioband support multiclass task/groups, we will end up inheriting logic from cfq/bfq.
- To treat task and group at same level we will end up creating separate queues for each task and then import lots of cfq/bfq logic for managing those queues.
- The moment we move to hiearchical support, you will end up creating equivalent logic of our patches.
The point is, why to do all this? CFQ has already solved the problem of multi class IO scheduler and providing service differentiation between tasks of different priority. With cgroup stuff, we need to just extend existing CFQ logic so that it supports hiearchical scheduling and we will have a good IO controller in place.
Can you please point out specifically why do you think extending CFQ logic to support hiearchical scheduling and sharing code with other IO schedulers is not a good idea to implement hiearchical IO control?
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 20 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7 respectively(the corresponding weight should 4:1, right?), and start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?
I extract the following highlight value
8,0 0 0 18.914906549 0 m N 6601ioq served=*0x13* total service=0x184d
Quoted 6 lines
Thanks
Vivek
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 20 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7 respectively(the corresponding weight should 4:1, right?), and start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?
I extract the following highlight value
8,0 0 0 18.914906549 0 m N 6601ioq served=*0x13* total service=0x184d
Quoted 6 lines
Thanks
Vivek
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
Quoted 29 lines · Gui Jianfeng
Quoted 20 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.
Quoted 4 lines
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7
respectively(the corresponding weight should 4:1, right?),
Hi Gui,
Thanks for testing. You are right about weight proportions.
Quoted 6 lines
and
start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?
Actually getting the service proportion in same ratio as weight proportion is quite hard for sync queues. The biggest issue is that many a times sync queues are not continuously backlogged and they do some IO and then dispatch a next round of requests.
Most of the time idling seems to be the solution for giving an impression that sync queue is continuously backlogged but it also has potential to reduce throughput on faster hardware.
Anyway, can you please send me your complete blkparse output. There are many a places where code has been designed to favor throughput than fairness. Looking at your blkparse output, will give me better idea what's the issue in your setup.
Also please try the attached patch. I have experimented with waiting for new request to come before sync queue is expired. It helps me in getting the fairness numbers at least with noop on non-queueing rotational media.
I also have introduced a new tunable "fairness". Above code will kick in only if this variable is set to 1. Many a places where we favor throughput over fairness, I plan to use this variable as condition to let user decide whether to choose fairness over throughput. I am not sure at how many places it really makes sense, but it atleast gives us something to play and compare the throughput in two cases.
This patch applies on my current tree after removing tomost patceh "anticipatory scheduling changes". My code has changed a bit since the posting, so you might have to message this patch a bit.
Thanks
Vivek
DESC
io-controller: idle for sometime on sync queue before expiring it EDESC
o When a sync queue expires, in many cases it might be empty and then it will be deleted from the active tree. This will lead to a scenario where out of two competing queues, only one is on the tree and when a new queue is selected, vtime jump takes place and we don't see services provided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues where queues are not continuously backlogged. Looks like idling is only solution to make sure such kind of queues can get some decent amount of disk bandwidth in the face of competion from continusouly backlogged queues. But excessive idling has potential to reduce performance on SSD and disks with commnad queuing.
o This patch experiments with waiting for next request to come before a queue is expired after it has consumed its time slice. This can ensure more accurate fairness numbers in some cases.
o Introduced a tunable "fairness". If set, io-controller will put more focus on getting fairness right than getting throughput right.
--- block/blk-sysfs.c | 7 ++++ block/elevator-fq.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------- block/elevator-fq.h | 12 +++++++ 3 files changed, 94 insertions(+), 10 deletions(-)
block/elevator-fq.h +12 -0
@@ -318,6 +318,13 @@ struct elv_fq_data {unsigned long long rate_sampling_start;/*sampling window start jifies*/ /* number of sectors finished io during current sampling window */ unsigned long rate_sectors_current; + +/* +* If set to 1, will disable many optimizations done for boost +* throughput and focus more on providing fairness for sync +* queues. +*/ +int fairness; };extern int elv_slice_idle;
@@ -340,6 +347,7 @@ enum elv_queue_state_flags { ELV_QUEUE_FLAG_idle_window,/* elevator slice idling enabled */ ELV_QUEUE_FLAG_wait_request,/* waiting for a request */ ELV_QUEUE_FLAG_slice_new,/* no requests dispatched in slice */ + ELV_QUEUE_FLAG_wait_busy,/* wait for this queue to get busy */ ELV_QUEUE_FLAG_NR, };
@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) ELV_IO_QUEUE_FLAG_FNS(wait_request) ELV_IO_QUEUE_FLAG_FNS(idle_window) ELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy) static inline struct io_service_tree * io_entity_service_tree(struct io_entity *entity)
@@ -554,6 +563,9 @@ static inline struct io_queue *elv_lookuextern ssize_t elv_slice_idle_show (struct request_queue *q,char *name);extern ssize_t elv_slice_idle_store (struct request_queue *q,const char *name,size_t count); +extern ssize_t elv_fairness_show (struct request_queue *q,char *name); +extern ssize_t elv_fairness_store (struct request_queue *q,const char *name, +size_t count);/* Functions used by elevator.c */ extern int elv_init_fq_data (struct request_queue *q,struct elevator_queue *e);
block/elevator-fq.c +75 -10
143 lines not on this page · raw message
block/blk-sysfs.c +7 -0
@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl .show = elv_slice_idle_show, .store = elv_slice_idle_store, }; + +static struct queue_sysfs_entry queue_fairness_entry = { + .attr = {.name ="fairness" , .mode =S_IRUGO |S_IWUSR }, + .show = elv_fairness_show, + .store = elv_fairness_store, +};#endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr,
@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] &queue_iostats_entry.attr, #ifdef CONFIG_ELV_FAIR_QUEUING &queue_slice_idle_entry.attr, + &queue_fairness_entry.attr, #endif NULL, };
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 69 lines · Vivek Goyal
Quoted 27 lines · Gui Jianfeng
Quoted 19 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.Quoted 4 lines
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7
respectively(the corresponding weight should 4:1, right?),Hi Gui,
Thanks for testing. You are right about weight proportions.
Quoted 6 lines
and
start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?Actually getting the service proportion in same ratio as weight proportion is quite hard for sync queues. The biggest issue is that many a times sync queues are not continuously backlogged and they do some IO and then dispatch a next round of requests.
Most of the time idling seems to be the solution for giving an impression that sync queue is continuously backlogged but it also has potential to reduce throughput on faster hardware.
Anyway, can you please send me your complete blkparse output. There are many a places where code has been designed to favor throughput than fairness. Looking at your blkparse output, will give me better idea what's the issue in your setup.
Also please try the attached patch. I have experimented with waiting for new request to come before sync queue is expired. It helps me in getting the fairness numbers at least with noop on non-queueing rotational media.
I also have introduced a new tunable "fairness". Above code will kick in only if this variable is set to 1. Many a places where we favor throughput over fairness, I plan to use this variable as condition to let user decide whether to choose fairness over throughput. I am not sure at how many places it really makes sense, but it atleast gives us something to play and compare the throughput in two cases.
Quoted 3 lines
This patch applies on my current tree after removing tomost patceh "anticipatory scheduling changes". My code has changed a bit since the posting, so you might have to message this patch a bit.
Hi Vivek,
This time I run two dd with pure sync read like this:
dd if=/mnt/500M.1 of=/dev/null, and the proportion of service got by each is very close to the proportion of their weight.
Previously, I run concurrent dd like this:
dd if=/mnt/500M.1 of=/mnt/500M.2
I'd like to try this patch out.
Quoted 263 lines
Thanks
VivekDESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then it will be deleted from the active tree. This will lead to a scenario where out of two competing queues, only one is on the tree and when a new queue is selected, vtime jump takes place and we don't see services provided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues where queues are not continuously backlogged. Looks like idling is only solution to make sure such kind of queues can get some decent amount of disk bandwidth in the face of competion from continusouly backlogged queues. But excessive idling has potential to reduce performance on SSD and disks with commnad queuing.
o This patch experiments with waiting for next request to come before a queue is expired after it has consumed its time slice. This can ensure more accurate fairness numbers in some cases.
o Introduced a tunable "fairness". If set, io-controller will put more focus on getting fairness right than getting throughput right.
--- block/blk-sysfs.c | 7 ++++ block/elevator-fq.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------- block/elevator-fq.h | 12 +++++++ 3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h +12
-0@@ -318,6 +318,13 @@ struct elv_fq_data {unsigned long long rate_sampling_start;/*sampling window start jifies*/ /* number of sectors finished io during current sampling window */ unsigned long rate_sectors_current; + +/* +* If set to 1, will disable many optimizations done for boost +* throughput and focus more on providing fairness for sync +* queues. +*/ +int fairness; };extern int elv_slice_idle;@@ -340,6 +347,7 @@ enum elv_queue_state_flags { ELV_QUEUE_FLAG_idle_window,/* elevator slice idling enabled */ ELV_QUEUE_FLAG_wait_request,/* waiting for a request */ ELV_QUEUE_FLAG_slice_new,/* no requests dispatched in slice */ + ELV_QUEUE_FLAG_wait_busy,/* wait for this queue to get busy */ ELV_QUEUE_FLAG_NR, };@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) ELV_IO_QUEUE_FLAG_FNS(wait_request) ELV_IO_QUEUE_FLAG_FNS(idle_window) ELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy) static inline struct io_service_tree * io_entity_service_tree(struct io_entity *entity)@@ -554,6 +563,9 @@ static inline struct io_queue *elv_lookuextern ssize_t elv_slice_idle_show (struct request_queue *q,char *name);extern ssize_t elv_slice_idle_store (struct request_queue *q,const char *name,size_t count); +extern ssize_t elv_fairness_show (struct request_queue *q,char *name); +extern ssize_t elv_fairness_store (struct request_queue *q,const char *name, +size_t count);/* Functions used by elevator.c */ extern int elv_init_fq_data (struct request_queue *q,struct elevator_queue *e);Index:
linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c +75
-10@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq ioq->total_service); } +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show (struct request_queue *q,char *name) +{ +struct elv_fq_data *efqd; +unsigned int data; +unsigned long flags; + +spin_lock_irqsave (q->queue_lock, flags); + efqd = &q->elevator->efqd; + data = efqd->fairness; +spin_unlock_irqrestore (q->queue_lock, flags); +return sprintf (name,"%d\n" , data); +} + +ssize_t elv_fairness_store (struct request_queue *q,const char *name, +size_t count) +{ +struct elv_fq_data *efqd; +unsigned int data; +unsigned long flags; + +char *p = (char *)name; + + data =simple_strtoul (p, &p,10 ); + +if (data <0 ) + data =0 ; +else if (data >INT_MAX ) + data =INT_MAX ; + +spin_lock_irqsave (q->queue_lock, flags); + efqd = &q->elevator->efqd; + efqd->fairness = data; +spin_unlock_irqrestore (q->queue_lock, flags); + +return count; +} +/* Functions to show and store elv_idle_slice value through sysfs */ ssize_t elv_slice_idle_show (struct request_queue *q,char *name) {@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requassert_spin_locked (q->queue_lock);elv_log_ioq (efqd, ioq,"slice expired upd=%d" , budget_update); -if (elv_ioq_wait_request (ioq)) +if (elv_ioq_wait_request (ioq) ||elv_ioq_wait_busy (ioq))del_timer (&efqd->idle_slice_timer);elv_clear_ioq_wait_request (ioq); +elv_clear_ioq_wait_busy (ioq);/* * if ioq->slice_end = 0, that means a queue was expired before first @@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_* immediately and flag that we must not expire this queue * just now */ -if (elv_ioq_wait_request (ioq)) { +if (elv_ioq_wait_request (ioq) ||elv_ioq_wait_busy (ioq)) {del_timer (&efqd->idle_slice_timer); +elv_clear_ioq_wait_busy (ioq);blk_start_queueing (q); } }else if (elv_should_preempt (q, ioq, rq)) {@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned longif (ioq) { +if (elv_ioq_wait_busy (ioq)) + goto expire; +/* * expired */ @@ -2546,7 +2589,7 @@ out_cont:spin_unlock_irqrestore (q->queue_lock, flags); } -void elv_ioq_arm_slice_timer (struct request_queue *q) +void elv_ioq_arm_slice_timer (struct request_queue *q,int wait_for_busy) {struct elv_fq_data *efqd = &q->elevator->efqd;struct io_queue *ioq =elv_active_ioq (q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requreturn ;/* -* still requests with the driver, don't idle +* idle is disabled, either manually or by past process history */ -if (efqd->rq_in_driver) +if (!efqd->elv_slice_idle || !elv_ioq_idle_window (ioq))return ;/* -* idle is disabled, either manually or by past process history +* This queue has consumed its time slice. We are waiting only for +* it to become busy before we select next queue for dispatch. */ -if (!efqd->elv_slice_idle || !elv_ioq_idle_window (ioq)) +if (efqd->fairness && wait_for_busy) { +elv_mark_ioq_wait_busy (ioq); + sl = efqd->elv_slice_idle; +mod_timer (&efqd->idle_slice_timer, jiffies + sl); +elv_log (efqd,"arm idle: %lu wait busy=1" , sl); +return ; + } + +/* +* still requests with the driver, don't idle +*/ +if (efqd->rq_in_driver)return ;/* @@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q } } +/* We are waiting for this queue to become busy before it expires.*/ +if (efqd->fairness &&elv_ioq_wait_busy (ioq)) { + ioq =NULL ; + goto keep_queue; + } +/* * The active queue has run out of time, expire it and select new. */ @@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct reelv_ioq_set_prio_slice (q, ioq);elv_clear_ioq_slice_new (ioq); } -if (elv_ioq_slice_used (ioq) ||elv_ioq_class_idle (ioq)) +if (elv_ioq_class_idle (ioq))elv_ioq_slice_expired (q,1 ); -else if (sync && !ioq->nr_queued) -elv_ioq_arm_slice_timer (q); +else if (sync && !ioq->nr_queued) { +if (elv_ioq_slice_used (ioq)) +elv_ioq_arm_slice_timer (q,1 ); +else +elv_ioq_arm_slice_timer (q,0 ); + } }if (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c +7
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl .show = elv_slice_idle_show, .store = elv_slice_idle_store, }; + +static struct queue_sysfs_entry queue_fairness_entry = { + .attr = {.name ="fairness" , .mode =S_IRUGO |S_IWUSR }, + .show = elv_fairness_show, + .store = elv_fairness_store, +};#endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr,@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] &queue_iostats_entry.attr, #ifdef CONFIG_ELV_FAIR_QUEUING &queue_slice_idle_entry.attr, + &queue_fairness_entry.attr, #endif NULL, };
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 69 lines · Vivek Goyal
Quoted 27 lines · Gui Jianfeng
Quoted 19 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.Quoted 4 lines
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7
respectively(the corresponding weight should 4:1, right?),Hi Gui,
Thanks for testing. You are right about weight proportions.
Quoted 6 lines
and
start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?Actually getting the service proportion in same ratio as weight proportion is quite hard for sync queues. The biggest issue is that many a times sync queues are not continuously backlogged and they do some IO and then dispatch a next round of requests.
Most of the time idling seems to be the solution for giving an impression that sync queue is continuously backlogged but it also has potential to reduce throughput on faster hardware.
Anyway, can you please send me your complete blkparse output. There are many a places where code has been designed to favor throughput than fairness. Looking at your blkparse output, will give me better idea what's the issue in your setup.
Also please try the attached patch. I have experimented with waiting for new request to come before sync queue is expired. It helps me in getting the fairness numbers at least with noop on non-queueing rotational media.
I also have introduced a new tunable "fairness". Above code will kick in only if this variable is set to 1. Many a places where we favor throughput over fairness, I plan to use this variable as condition to let user decide whether to choose fairness over throughput. I am not sure at how many places it really makes sense, but it atleast gives us something to play and compare the throughput in two cases.
Quoted 3 lines
This patch applies on my current tree after removing tomost patceh "anticipatory scheduling changes". My code has changed a bit since the posting, so you might have to message this patch a bit.
Hi Vivek,
This time I run two dd with pure sync read like this:
dd if=/mnt/500M.1 of=/dev/null, and the proportion of service got by each is very close to the proportion of their weight.
Previously, I run concurrent dd like this:
dd if=/mnt/500M.1 of=/mnt/500M.2
I'd like to try this patch out.
Quoted 263 lines
Thanks
VivekDESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then it will be deleted from the active tree. This will lead to a scenario where out of two competing queues, only one is on the tree and when a new queue is selected, vtime jump takes place and we don't see services provided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues where queues are not continuously backlogged. Looks like idling is only solution to make sure such kind of queues can get some decent amount of disk bandwidth in the face of competion from continusouly backlogged queues. But excessive idling has potential to reduce performance on SSD and disks with commnad queuing.
o This patch experiments with waiting for next request to come before a queue is expired after it has consumed its time slice. This can ensure more accurate fairness numbers in some cases.
o Introduced a tunable "fairness". If set, io-controller will put more focus on getting fairness right than getting throughput right.
--- block/blk-sysfs.c | 7 ++++ block/elevator-fq.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------- block/elevator-fq.h | 12 +++++++ 3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h +12
-0@@ -318,6 +318,13 @@ struct elv_fq_data {unsigned long long rate_sampling_start;/*sampling window start jifies*/ /* number of sectors finished io during current sampling window */ unsigned long rate_sectors_current; + +/* +* If set to 1, will disable many optimizations done for boost +* throughput and focus more on providing fairness for sync +* queues. +*/ +int fairness; };extern int elv_slice_idle;@@ -340,6 +347,7 @@ enum elv_queue_state_flags { ELV_QUEUE_FLAG_idle_window,/* elevator slice idling enabled */ ELV_QUEUE_FLAG_wait_request,/* waiting for a request */ ELV_QUEUE_FLAG_slice_new,/* no requests dispatched in slice */ + ELV_QUEUE_FLAG_wait_busy,/* wait for this queue to get busy */ ELV_QUEUE_FLAG_NR, };@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) ELV_IO_QUEUE_FLAG_FNS(wait_request) ELV_IO_QUEUE_FLAG_FNS(idle_window) ELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy) static inline struct io_service_tree * io_entity_service_tree(struct io_entity *entity)@@ -554,6 +563,9 @@ static inline struct io_queue *elv_lookuextern ssize_t elv_slice_idle_show (struct request_queue *q,char *name);extern ssize_t elv_slice_idle_store (struct request_queue *q,const char *name,size_t count); +extern ssize_t elv_fairness_show (struct request_queue *q,char *name); +extern ssize_t elv_fairness_store (struct request_queue *q,const char *name, +size_t count);/* Functions used by elevator.c */ extern int elv_init_fq_data (struct request_queue *q,struct elevator_queue *e);Index:
linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c +75
-10@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq ioq->total_service); } +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show (struct request_queue *q,char *name) +{ +struct elv_fq_data *efqd; +unsigned int data; +unsigned long flags; + +spin_lock_irqsave (q->queue_lock, flags); + efqd = &q->elevator->efqd; + data = efqd->fairness; +spin_unlock_irqrestore (q->queue_lock, flags); +return sprintf (name,"%d\n" , data); +} + +ssize_t elv_fairness_store (struct request_queue *q,const char *name, +size_t count) +{ +struct elv_fq_data *efqd; +unsigned int data; +unsigned long flags; + +char *p = (char *)name; + + data =simple_strtoul (p, &p,10 ); + +if (data <0 ) + data =0 ; +else if (data >INT_MAX ) + data =INT_MAX ; + +spin_lock_irqsave (q->queue_lock, flags); + efqd = &q->elevator->efqd; + efqd->fairness = data; +spin_unlock_irqrestore (q->queue_lock, flags); + +return count; +} +/* Functions to show and store elv_idle_slice value through sysfs */ ssize_t elv_slice_idle_show (struct request_queue *q,char *name) {@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requassert_spin_locked (q->queue_lock);elv_log_ioq (efqd, ioq,"slice expired upd=%d" , budget_update); -if (elv_ioq_wait_request (ioq)) +if (elv_ioq_wait_request (ioq) ||elv_ioq_wait_busy (ioq))del_timer (&efqd->idle_slice_timer);elv_clear_ioq_wait_request (ioq); +elv_clear_ioq_wait_busy (ioq);/* * if ioq->slice_end = 0, that means a queue was expired before first @@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_* immediately and flag that we must not expire this queue * just now */ -if (elv_ioq_wait_request (ioq)) { +if (elv_ioq_wait_request (ioq) ||elv_ioq_wait_busy (ioq)) {del_timer (&efqd->idle_slice_timer); +elv_clear_ioq_wait_busy (ioq);blk_start_queueing (q); } }else if (elv_should_preempt (q, ioq, rq)) {@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned longif (ioq) { +if (elv_ioq_wait_busy (ioq)) + goto expire; +/* * expired */ @@ -2546,7 +2589,7 @@ out_cont:spin_unlock_irqrestore (q->queue_lock, flags); } -void elv_ioq_arm_slice_timer (struct request_queue *q) +void elv_ioq_arm_slice_timer (struct request_queue *q,int wait_for_busy) {struct elv_fq_data *efqd = &q->elevator->efqd;struct io_queue *ioq =elv_active_ioq (q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requreturn ;/* -* still requests with the driver, don't idle +* idle is disabled, either manually or by past process history */ -if (efqd->rq_in_driver) +if (!efqd->elv_slice_idle || !elv_ioq_idle_window (ioq))return ;/* -* idle is disabled, either manually or by past process history +* This queue has consumed its time slice. We are waiting only for +* it to become busy before we select next queue for dispatch. */ -if (!efqd->elv_slice_idle || !elv_ioq_idle_window (ioq)) +if (efqd->fairness && wait_for_busy) { +elv_mark_ioq_wait_busy (ioq); + sl = efqd->elv_slice_idle; +mod_timer (&efqd->idle_slice_timer, jiffies + sl); +elv_log (efqd,"arm idle: %lu wait busy=1" , sl); +return ; + } + +/* +* still requests with the driver, don't idle +*/ +if (efqd->rq_in_driver)return ;/* @@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q } } +/* We are waiting for this queue to become busy before it expires.*/ +if (efqd->fairness &&elv_ioq_wait_busy (ioq)) { + ioq =NULL ; + goto keep_queue; + } +/* * The active queue has run out of time, expire it and select new. */ @@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct reelv_ioq_set_prio_slice (q, ioq);elv_clear_ioq_slice_new (ioq); } -if (elv_ioq_slice_used (ioq) ||elv_ioq_class_idle (ioq)) +if (elv_ioq_class_idle (ioq))elv_ioq_slice_expired (q,1 ); -else if (sync && !ioq->nr_queued) -elv_ioq_arm_slice_timer (q); +else if (sync && !ioq->nr_queued) { +if (elv_ioq_slice_used (ioq)) +elv_ioq_arm_slice_timer (q,1 ); +else +elv_ioq_arm_slice_timer (q,0 ); + } }if (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c +7
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl .show = elv_slice_idle_show, .store = elv_slice_idle_store, }; + +static struct queue_sysfs_entry queue_fairness_entry = { + .attr = {.name ="fairness" , .mode =S_IRUGO |S_IWUSR }, + .show = elv_fairness_show, + .store = elv_fairness_store, +};#endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr,@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] &queue_iostats_entry.attr, #ifdef CONFIG_ELV_FAIR_QUEUING &queue_slice_idle_entry.attr, + &queue_fairness_entry.attr, #endif NULL, };
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 02/10] Common flat fair queuing code in elevaotor layer
In reply to a message not in the archiveVivek Goyal wrote:
...
Quoted 5 lines
block/elevator-fq.c new file +5
-0+ +int elv_init_ioq (struct elevator_queue *eq,struct io_queue *ioq, +void *sched_queue,int ioprio_class,int ioprio, +int is_sync) +{
block/elevator-fq.c line 965
Quoted 10 lines
block/elevator-fq.c new file +10
-0+struct elv_fq_data *efqd = &eq->efqd; +struct io_group *iog =io_lookup_io_group_current (efqd->queue); + +RB_CLEAR_NODE (&ioq->entity.rb_node); +atomic_set (&ioq->ref,0 ); + ioq->efqd = efqd; + ioq->entity.budget = efqd->elv_slice[is_sync]; +elv_ioq_set_ioprio_class (ioq, ioprio_class); +elv_ioq_set_ioprio (ioq, ioprio); + ioq->pid = current->pid;
Hi Vivek,
If we are using a scheduler other than cfq, IOW single ioq is used. that storing a pid to the ioq makes no sense, it just stores the first serviced task.
Quoted 6 lines
block/elevator-fq.c new file +6
-0+ ioq->sched_queue = sched_queue; +elv_mark_ioq_idle_window (ioq); +bfq_init_entity (&ioq->entity, iog); +return 0 ; +} +EXPORT_SYMBOL (elv_init_ioq);
...
block/elevator-fq.h line 239
Quoted 7 lines
block/elevator-fq.h new file +7
-0+ +extern int elv_slice_idle; +extern int elv_slice_async; + +/* Logging facilities. */ +#define elv_log_ioq(efqd, ioq, fmt, args...) \ + blk_add_trace_msg((efqd)->queue, "%d" fmt, (ioq)->pid, ##args)
Maybe we need to use current->pid instead, for ioq->pid is not valid sometimes.
Quoted 6 lines
block/elevator-fq.h new file +6
-0+ +#define elv_log(efqd, fmt, args...) \ + blk_add_trace_msg((efqd)->queue, "" fmt, ##args) + +#define ioq_sample_valid (samples) ((samples) > 80) +
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 02/10] Common flat fair queuing code in elevaotor layer
In reply to Vivek GoyalVivek Goyal wrote:
...
Quoted 5 lines
block/elevator-fq.c new file +5
-0+ +int elv_init_ioq (struct elevator_queue *eq,struct io_queue *ioq, +void *sched_queue,int ioprio_class,int ioprio, +int is_sync) +{
block/elevator-fq.c line 965
Quoted 10 lines
block/elevator-fq.c new file +10
-0+struct elv_fq_data *efqd = &eq->efqd; +struct io_group *iog =io_lookup_io_group_current (efqd->queue); + +RB_CLEAR_NODE (&ioq->entity.rb_node); +atomic_set (&ioq->ref,0 ); + ioq->efqd = efqd; + ioq->entity.budget = efqd->elv_slice[is_sync]; +elv_ioq_set_ioprio_class (ioq, ioprio_class); +elv_ioq_set_ioprio (ioq, ioprio); + ioq->pid = current->pid;
Hi Vivek,
If we are using a scheduler other than cfq, IOW single ioq is used. that storing a pid to the ioq makes no sense, it just stores the first serviced task.
Quoted 6 lines
block/elevator-fq.c new file +6
-0+ ioq->sched_queue = sched_queue; +elv_mark_ioq_idle_window (ioq); +bfq_init_entity (&ioq->entity, iog); +return 0 ; +} +EXPORT_SYMBOL (elv_init_ioq);
...
block/elevator-fq.h line 239
Quoted 7 lines
block/elevator-fq.h new file +7
-0+ +extern int elv_slice_idle; +extern int elv_slice_async; + +/* Logging facilities. */ +#define elv_log_ioq(efqd, ioq, fmt, args...) \ + blk_add_trace_msg((efqd)->queue, "%d" fmt, (ioq)->pid, ##args)
Maybe we need to use current->pid instead, for ioq->pid is not valid sometimes.
Quoted 6 lines
block/elevator-fq.h new file +6
-0+ +#define elv_log(efqd, fmt, args...) \ + blk_add_trace_msg((efqd)->queue, "" fmt, ##args) + +#define ioq_sample_valid (samples) ((samples) > 80) +
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 96 lines · Vivek Goyal
Quoted 29 lines · Gui Jianfeng
Quoted 20 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.Quoted 4 lines
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7
respectively(the corresponding weight should 4:1, right?),Hi Gui,
Thanks for testing. You are right about weight proportions.
Quoted 6 lines
and
start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?Actually getting the service proportion in same ratio as weight proportion is quite hard for sync queues. The biggest issue is that many a times sync queues are not continuously backlogged and they do some IO and then dispatch a next round of requests.
Most of the time idling seems to be the solution for giving an impression that sync queue is continuously backlogged but it also has potential to reduce throughput on faster hardware.
Anyway, can you please send me your complete blkparse output. There are many a places where code has been designed to favor throughput than fairness. Looking at your blkparse output, will give me better idea what's the issue in your setup.
Also please try the attached patch. I have experimented with waiting for new request to come before sync queue is expired. It helps me in getting the fairness numbers at least with noop on non-queueing rotational media.
I also have introduced a new tunable "fairness". Above code will kick in only if this variable is set to 1. Many a places where we favor throughput over fairness, I plan to use this variable as condition to let user decide whether to choose fairness over throughput. I am not sure at how many places it really makes sense, but it atleast gives us something to play and compare the throughput in two cases.
This patch applies on my current tree after removing tomost patceh "anticipatory scheduling changes". My code has changed a bit since the posting, so you might have to message this patch a bit.
Thanks
VivekDESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then it will be deleted from the active tree. This will lead to a scenario where out of two competing queues, only one is on the tree and when a new queue is selected, vtime jump takes place and we don't see services provided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues where queues are not continuously backlogged. Looks like idling is only solution to make sure such kind of queues can get some decent amount of disk bandwidth in the face of competion from continusouly backlogged queues. But excessive idling has potential to reduce performance on SSD and disks with commnad queuing.
Quoted 3 lines
o This patch experiments with waiting for next request to come before a queue is expired after it has consumed its time slice. This can ensure more accurate fairness numbers in some cases.
Vivek, have you introduced this option just to play with it, or you are planning to make it a part of the patch set. Waiting for a new request to come before expiring time slice sounds problematic.
Quoted 236 lines
o Introduced a tunable "fairness". If set, io-controller will put more focus on getting fairness right than getting throughput right.
---
block/blk-sysfs.c | 7 ++++
block/elevator-fq.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-------block/elevator-fq.h| 12 +++++++3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -318,6 +318,13 @@ struct elv_fq_data {unsigned long long
rate_sampling_start; /*sampling window start jifies*/ /* number of sectors finished io during current sampling window */ unsigned longrate_sectors_current;
+
+ /*
+ * If set to 1, will disable many optimizations done for boost
+ * throughput and focus more on providing fairness for sync
+ * queues.
+ */
+ int fairness;
};extern int
elv_slice_idle;block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -340,6 +347,7 @@ enum elv_queue_state_flags {ELV_QUEUE_FLAG_idle_window, /* elevator slice idling enabled */
ELV_QUEUE_FLAG_wait_request, /* waiting for a request */ELV_QUEUE_FLAG_slice_new, /* no requests dispatched in slice */
+ELV_QUEUE_FLAG_wait_busy, /* wait for this queue to get busy */ELV_QUEUE_FLAG_NR,
};block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +1
-0@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) ELV_IO_QUEUE_FLAG_FNS(wait_request) ELV_IO_QUEUE_FLAG_FNS(idle_window) ELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy)static inline struct
io_service_tree*
io_entity_service_tree(structio_entity*entity)block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -554,6 +563,9 @@ static inline struct io_queue *elv_looku extern ssize_t elv_slice_idle_show(struct request_queue *q, char *name); extern ssize_t elv_slice_idle_store(struct request_queue *q, const char *name, size_t count); +extern ssize_t elv_fairness_show(struct request_queue *q, char *name); +extern ssize_t elv_fairness_store(struct request_queue *q, const char *name, + size_t count); /* Functions used by elevator.c */ extern int elv_init_fq_data(struct request_queue *q, struct elevator_queue *e);Index:
linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c 2009-03-18 17:34:46.000000000 -0400 +75
-10@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq ioq->total_service); } +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show(struct request_queue *q, char *name) +{ + struct elv_fq_data *efqd; + unsigned int data; + unsigned long flags; + + spin_lock_irqsave(q->queue_lock, flags); + efqd = &q->elevator->efqd; + data = efqd->fairness; + spin_unlock_irqrestore(q->queue_lock, flags); + return sprintf(name, "%d\n", data); +} + +ssize_t elv_fairness_store(struct request_queue *q, const char *name, + size_t count) +{ + struct elv_fq_data *efqd; + unsigned int data; + unsigned long flags; + + char *p = (char *)name; + + data = simple_strtoul(p, &p, 10); + + if (data < 0) + data = 0; + else if (data > INT_MAX) + data = INT_MAX; + + spin_lock_irqsave(q->queue_lock, flags); + efqd = &q->elevator->efqd; + efqd->fairness = data; + spin_unlock_irqrestore(q->queue_lock, flags); + + return count; +} + /* Functions to show and store elv_idle_slice value through sysfs */ ssize_t elv_slice_idle_show(struct request_queue *q, char *name) {@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requ assert_spin_locked(q->queue_lock); elv_log_ioq(efqd, ioq, "slice expired upd=%d", budget_update); - if (elv_ioq_wait_request(ioq)) + if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) del_timer(&efqd->idle_slice_timer); elv_clear_ioq_wait_request(ioq); + elv_clear_ioq_wait_busy(ioq); /* * if ioq->slice_end = 0, that means a queue was expired before first@@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_ * immediately and flag that we must not expire this queue * just now */ - if (elv_ioq_wait_request(ioq)) { + if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) { del_timer(&efqd->idle_slice_timer); + elv_clear_ioq_wait_busy(ioq); blk_start_queueing(q); } } else if (elv_should_preempt(q, ioq, rq)) {@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned long if (ioq) { + if (elv_ioq_wait_busy(ioq)) + goto expire; + /* * expired */@@ -2546,7 +2589,7 @@ out_cont: spin_unlock_irqrestore(q->queue_lock, flags); } -void elv_ioq_arm_slice_timer(struct request_queue *q) +void elv_ioq_arm_slice_timer(struct request_queue *q, int wait_for_busy) { struct elv_fq_data *efqd = &q->elevator->efqd; struct io_queue *ioq = elv_active_ioq(q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requ return; /* - * still requests with the driver, don't idle + * idle is disabled, either manually or by past process history */ - if (efqd->rq_in_driver) + if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) return; /* - * idle is disabled, either manually or by past process history + * This queue has consumed its time slice. We are waiting only for + * it to become busy before we select next queue for dispatch. */ - if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) + if (efqd->fairness && wait_for_busy) { + elv_mark_ioq_wait_busy(ioq); + sl = efqd->elv_slice_idle; + mod_timer(&efqd->idle_slice_timer, jiffies + sl); + elv_log(efqd, "arm idle: %lu wait busy=1", sl); + return; + } + + /* + * still requests with the driver, don't idle + */ + if (efqd->rq_in_driver) return; /*@@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q } } + /* We are waiting for this queue to become busy before it expires.*/ + if (efqd->fairness && elv_ioq_wait_busy(ioq)) { + ioq = NULL; + goto keep_queue; + } + /* * The active queue has run out of time, expire it and select new. */@@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct re elv_ioq_set_prio_slice(q, ioq); elv_clear_ioq_slice_new(ioq); } - if (elv_ioq_slice_used(ioq) || elv_ioq_class_idle(ioq)) + if (elv_ioq_class_idle(ioq)) elv_ioq_slice_expired(q, 1); - else if (sync && !ioq->nr_queued) - elv_ioq_arm_slice_timer(q); + else if (sync && !ioq->nr_queued) { + if (elv_ioq_slice_used(ioq)) + elv_ioq_arm_slice_timer(q, 1); + else + elv_ioq_arm_slice_timer(q, 0); + } } if (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c 2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c 2009-03-18 17:34:28.000000000 -0400 +7
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl .show = elv_slice_idle_show, .store = elv_slice_idle_store, }; + +static struct queue_sysfs_entry queue_fairness_entry = { + .attr = {.name = "fairness", .mode = S_IRUGO | S_IWUSR }, + .show = elv_fairness_show, + .store = elv_fairness_store, +}; #endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr,@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] &queue_iostats_entry.attr, #ifdef CONFIG_ELV_FAIR_QUEUING &queue_slice_idle_entry.attr, + &queue_fairness_entry.attr, #endif NULL, };
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 96 lines · Vivek Goyal
Quoted 29 lines · Gui Jianfeng
Quoted 20 lines · Vivek Goyal
Quoted 4 lines
Hi Vivek,
I would be interested in knowing if these are the results expected?
Hi Dhaval,
Good question. Keeping current expectation in mind, yes these are expected results. To begin with, current expectations are that try to emulate cfq behavior and the kind of service differentiation we get between threads of different priority, same kind of service differentiation we should get from different cgroups.
Having said that, in theory a more accurate estimate should be amount of actual disk time a queue/cgroup got. I have put a tracing message to keep track of total service received by a queue. If you run "blktrace" then you can see that. Ideally, total service received by two threads over a period of time should be in same proportion as their cgroup weights.
Quoted 7 lines
It will not be easy to achive it given the constraints we have got in terms of how to accurately we can account for disk time actually used by a queue in certain situations. So to begin with I am targetting that try to meet same kind of service differentation between cgroups as cfq provides between threads and then slowly refine it to see how close one can come to get accurate numbers in terms of "
total_serivce" received by each queue.Quoted 4 lines
Hi Vivek,
I simply tested with blktrace opened. I create two groups and set ioprio 4 and 7
respectively(the corresponding weight should 4:1, right?),Hi Gui,
Thanks for testing. You are right about weight proportions.
Quoted 6 lines
and
start two dd concurrently. UUIC, Ideally, the proportion of service two dd got should be 4:1 in a period of time when they are running. I extract *served* value from blktrace output and sum them up. I found the proportion of the sum of *served* value is about 1.7:1
Am i missing something?Actually getting the service proportion in same ratio as weight proportion is quite hard for sync queues. The biggest issue is that many a times sync queues are not continuously backlogged and they do some IO and then dispatch a next round of requests.
Most of the time idling seems to be the solution for giving an impression that sync queue is continuously backlogged but it also has potential to reduce throughput on faster hardware.
Anyway, can you please send me your complete blkparse output. There are many a places where code has been designed to favor throughput than fairness. Looking at your blkparse output, will give me better idea what's the issue in your setup.
Also please try the attached patch. I have experimented with waiting for new request to come before sync queue is expired. It helps me in getting the fairness numbers at least with noop on non-queueing rotational media.
I also have introduced a new tunable "fairness". Above code will kick in only if this variable is set to 1. Many a places where we favor throughput over fairness, I plan to use this variable as condition to let user decide whether to choose fairness over throughput. I am not sure at how many places it really makes sense, but it atleast gives us something to play and compare the throughput in two cases.
This patch applies on my current tree after removing tomost patceh "anticipatory scheduling changes". My code has changed a bit since the posting, so you might have to message this patch a bit.
Thanks
VivekDESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then it will be deleted from the active tree. This will lead to a scenario where out of two competing queues, only one is on the tree and when a new queue is selected, vtime jump takes place and we don't see services provided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues where queues are not continuously backlogged. Looks like idling is only solution to make sure such kind of queues can get some decent amount of disk bandwidth in the face of competion from continusouly backlogged queues. But excessive idling has potential to reduce performance on SSD and disks with commnad queuing.
Quoted 3 lines
o This patch experiments with waiting for next request to come before a queue is expired after it has consumed its time slice. This can ensure more accurate fairness numbers in some cases.
Vivek, have you introduced this option just to play with it, or you are planning to make it a part of the patch set. Waiting for a new request to come before expiring time slice sounds problematic.
Quoted 236 lines
o Introduced a tunable "fairness". If set, io-controller will put more focus on getting fairness right than getting throughput right.
---
block/blk-sysfs.c | 7 ++++
block/elevator-fq.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-------block/elevator-fq.h| 12 +++++++3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -318,6 +318,13 @@ struct elv_fq_data {unsigned long long
rate_sampling_start; /*sampling window start jifies*/ /* number of sectors finished io during current sampling window */ unsigned longrate_sectors_current;
+
+ /*
+ * If set to 1, will disable many optimizations done for boost
+ * throughput and focus more on providing fairness for sync
+ * queues.
+ */
+ int fairness;
};extern int
elv_slice_idle;block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -340,6 +347,7 @@ enum elv_queue_state_flags {ELV_QUEUE_FLAG_idle_window, /* elevator slice idling enabled */
ELV_QUEUE_FLAG_wait_request, /* waiting for a request */ELV_QUEUE_FLAG_slice_new, /* no requests dispatched in slice */
+ELV_QUEUE_FLAG_wait_busy, /* wait for this queue to get busy */ELV_QUEUE_FLAG_NR,
};block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +1
-0@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) ELV_IO_QUEUE_FLAG_FNS(wait_request) ELV_IO_QUEUE_FLAG_FNS(idle_window) ELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy)static inline struct
io_service_tree*
io_entity_service_tree(structio_entity*entity)block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -554,6 +563,9 @@ static inline struct io_queue *elv_looku extern ssize_t elv_slice_idle_show(struct request_queue *q, char *name); extern ssize_t elv_slice_idle_store(struct request_queue *q, const char *name, size_t count); +extern ssize_t elv_fairness_show(struct request_queue *q, char *name); +extern ssize_t elv_fairness_store(struct request_queue *q, const char *name, + size_t count); /* Functions used by elevator.c */ extern int elv_init_fq_data(struct request_queue *q, struct elevator_queue *e);Index:
linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c 2009-03-18 17:34:46.000000000 -0400 +75
-10@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq ioq->total_service); } +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show(struct request_queue *q, char *name) +{ + struct elv_fq_data *efqd; + unsigned int data; + unsigned long flags; + + spin_lock_irqsave(q->queue_lock, flags); + efqd = &q->elevator->efqd; + data = efqd->fairness; + spin_unlock_irqrestore(q->queue_lock, flags); + return sprintf(name, "%d\n", data); +} + +ssize_t elv_fairness_store(struct request_queue *q, const char *name, + size_t count) +{ + struct elv_fq_data *efqd; + unsigned int data; + unsigned long flags; + + char *p = (char *)name; + + data = simple_strtoul(p, &p, 10); + + if (data < 0) + data = 0; + else if (data > INT_MAX) + data = INT_MAX; + + spin_lock_irqsave(q->queue_lock, flags); + efqd = &q->elevator->efqd; + efqd->fairness = data; + spin_unlock_irqrestore(q->queue_lock, flags); + + return count; +} + /* Functions to show and store elv_idle_slice value through sysfs */ ssize_t elv_slice_idle_show(struct request_queue *q, char *name) {@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requ assert_spin_locked(q->queue_lock); elv_log_ioq(efqd, ioq, "slice expired upd=%d", budget_update); - if (elv_ioq_wait_request(ioq)) + if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) del_timer(&efqd->idle_slice_timer); elv_clear_ioq_wait_request(ioq); + elv_clear_ioq_wait_busy(ioq); /* * if ioq->slice_end = 0, that means a queue was expired before first@@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_ * immediately and flag that we must not expire this queue * just now */ - if (elv_ioq_wait_request(ioq)) { + if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) { del_timer(&efqd->idle_slice_timer); + elv_clear_ioq_wait_busy(ioq); blk_start_queueing(q); } } else if (elv_should_preempt(q, ioq, rq)) {@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned long if (ioq) { + if (elv_ioq_wait_busy(ioq)) + goto expire; + /* * expired */@@ -2546,7 +2589,7 @@ out_cont: spin_unlock_irqrestore(q->queue_lock, flags); } -void elv_ioq_arm_slice_timer(struct request_queue *q) +void elv_ioq_arm_slice_timer(struct request_queue *q, int wait_for_busy) { struct elv_fq_data *efqd = &q->elevator->efqd; struct io_queue *ioq = elv_active_ioq(q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requ return; /* - * still requests with the driver, don't idle + * idle is disabled, either manually or by past process history */ - if (efqd->rq_in_driver) + if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) return; /* - * idle is disabled, either manually or by past process history + * This queue has consumed its time slice. We are waiting only for + * it to become busy before we select next queue for dispatch. */ - if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) + if (efqd->fairness && wait_for_busy) { + elv_mark_ioq_wait_busy(ioq); + sl = efqd->elv_slice_idle; + mod_timer(&efqd->idle_slice_timer, jiffies + sl); + elv_log(efqd, "arm idle: %lu wait busy=1", sl); + return; + } + + /* + * still requests with the driver, don't idle + */ + if (efqd->rq_in_driver) return; /*@@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q } } + /* We are waiting for this queue to become busy before it expires.*/ + if (efqd->fairness && elv_ioq_wait_busy(ioq)) { + ioq = NULL; + goto keep_queue; + } + /* * The active queue has run out of time, expire it and select new. */@@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct re elv_ioq_set_prio_slice(q, ioq); elv_clear_ioq_slice_new(ioq); } - if (elv_ioq_slice_used(ioq) || elv_ioq_class_idle(ioq)) + if (elv_ioq_class_idle(ioq)) elv_ioq_slice_expired(q, 1); - else if (sync && !ioq->nr_queued) - elv_ioq_arm_slice_timer(q); + else if (sync && !ioq->nr_queued) { + if (elv_ioq_slice_used(ioq)) + elv_ioq_arm_slice_timer(q, 1); + else + elv_ioq_arm_slice_timer(q, 0); + } } if (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c 2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c 2009-03-18 17:34:28.000000000 -0400 +7
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl .show = elv_slice_idle_show, .store = elv_slice_idle_store, }; + +static struct queue_sysfs_entry queue_fairness_entry = { + .attr = {.name = "fairness", .mode = S_IRUGO | S_IWUSR }, + .show = elv_fairness_show, + .store = elv_fairness_store, +}; #endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr,@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] &queue_iostats_entry.attr, #ifdef CONFIG_ELV_FAIR_QUEUING &queue_slice_idle_entry.attr, + &queue_fairness_entry.attr, #endif NULL, };
Re: [PATCH 01/10] Documentation
On Mon, Mar 23, 2009 at 10:32:41PM -0700, Nauman Rafique wrote:
[..]
Quoted 17 lines
Quoted 17 lines
DESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then it will be deleted from the active tree. This will lead to a scenario where out of two competing queues, only one is on the tree and when a new queue is selected, vtime jump takes place and we don't see services provided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues where queues are not continuously backlogged. Looks like idling is only solution to make sure such kind of queues can get some decent amount of disk bandwidth in the face of competion from continusouly backlogged queues. But excessive idling has potential to reduce performance on SSD and disks with commnad queuing.
Quoted 7 lines
Quoted 3 lines
o This patch experiments with waiting for next request to come before a queue is expired after it has consumed its time slice. This can ensure more accurate fairness numbers in some cases.
Vivek, have you introduced this option just to play with it, or you are planning to make it a part of the patch set. Waiting for a new request to come before expiring time slice sounds problematic.
Why are the issues you forsee with it. This is just an extra 8ms idling on the sync queue that is also if think time of the queue is not high.
We already do idling on sync queues. In this case we are doing an extra idle even if queue has consumed its allocated quota. It helps me get fairness numbers and I have put it under a tunable "fairness". So by default this code will not kick in.
Other possible option could be that when expiring a sync queue, don't remove the queue immediately from the tree and remove it later if there is no request from the queue in 8ms or so. I am not sure with BFQ, is it feasible to do that without creating issues with current implementation. Current implementation was simple, so I stick to it to begin with.
So yes, I am planning to keep it under tunable, unless there are significant issues in doing that.
Thanks
Vivek
Quoted 237 lines
Quoted 237 lines
o Introduced a tunable "fairness". If set, io-controller will put more focus on getting fairness right than getting throughput right.
---
block/blk-sysfs.c | 7 ++++
block/elevator-fq.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-------block/elevator-fq.h| 12 +++++++3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -318,6 +318,13 @@ struct elv_fq_data {unsigned long long
rate_sampling_start; /*sampling window start jifies*/ /* number of sectors finished io during current sampling window */ unsigned longrate_sectors_current;
+
+ /*
+ * If set to 1, will disable many optimizations done for boost
+ * throughput and focus more on providing fairness for sync
+ * queues.
+ */
+ int fairness;
};extern int
elv_slice_idle;block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -340,6 +347,7 @@ enum elv_queue_state_flags {ELV_QUEUE_FLAG_idle_window, /* elevator slice idling enabled */
ELV_QUEUE_FLAG_wait_request, /* waiting for a request */ELV_QUEUE_FLAG_slice_new, /* no requests dispatched in slice */
+ELV_QUEUE_FLAG_wait_busy, /* wait for this queue to get busy */ELV_QUEUE_FLAG_NR,
};block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +1
-0@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) ELV_IO_QUEUE_FLAG_FNS(wait_request) ELV_IO_QUEUE_FLAG_FNS(idle_window) ELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy)static inline struct
io_service_tree*
io_entity_service_tree(structio_entity*entity)block/elevator-fq.h 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -554,6 +563,9 @@ static inline struct io_queue *elv_looku extern ssize_t elv_slice_idle_show(struct request_queue *q, char *name); extern ssize_t elv_slice_idle_store(struct request_queue *q, const char *name, size_t count); +extern ssize_t elv_fairness_show(struct request_queue *q, char *name); +extern ssize_t elv_fairness_store(struct request_queue *q, const char *name, + size_t count); /* Functions used by elevator.c */ extern int elv_init_fq_data(struct request_queue *q, struct elevator_queue *e);Index:
linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c 2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c 2009-03-18 17:34:46.000000000 -0400 +75
-10@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq ioq->total_service); } +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show(struct request_queue *q, char *name) +{ + struct elv_fq_data *efqd; + unsigned int data; + unsigned long flags; + + spin_lock_irqsave(q->queue_lock, flags); + efqd = &q->elevator->efqd; + data = efqd->fairness; + spin_unlock_irqrestore(q->queue_lock, flags); + return sprintf(name, "%d\n", data); +} + +ssize_t elv_fairness_store(struct request_queue *q, const char *name, + size_t count) +{ + struct elv_fq_data *efqd; + unsigned int data; + unsigned long flags; + + char *p = (char *)name; + + data = simple_strtoul(p, &p, 10); + + if (data < 0) + data = 0; + else if (data > INT_MAX) + data = INT_MAX; + + spin_lock_irqsave(q->queue_lock, flags); + efqd = &q->elevator->efqd; + efqd->fairness = data; + spin_unlock_irqrestore(q->queue_lock, flags); + + return count; +} + /* Functions to show and store elv_idle_slice value through sysfs */ ssize_t elv_slice_idle_show(struct request_queue *q, char *name) {@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requ assert_spin_locked(q->queue_lock); elv_log_ioq(efqd, ioq, "slice expired upd=%d", budget_update); - if (elv_ioq_wait_request(ioq)) + if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) del_timer(&efqd->idle_slice_timer); elv_clear_ioq_wait_request(ioq); + elv_clear_ioq_wait_busy(ioq); /* * if ioq->slice_end = 0, that means a queue was expired before first@@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_ * immediately and flag that we must not expire this queue * just now */ - if (elv_ioq_wait_request(ioq)) { + if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) { del_timer(&efqd->idle_slice_timer); + elv_clear_ioq_wait_busy(ioq); blk_start_queueing(q); } } else if (elv_should_preempt(q, ioq, rq)) {@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned long if (ioq) { + if (elv_ioq_wait_busy(ioq)) + goto expire; + /* * expired */@@ -2546,7 +2589,7 @@ out_cont: spin_unlock_irqrestore(q->queue_lock, flags); } -void elv_ioq_arm_slice_timer(struct request_queue *q) +void elv_ioq_arm_slice_timer(struct request_queue *q, int wait_for_busy) { struct elv_fq_data *efqd = &q->elevator->efqd; struct io_queue *ioq = elv_active_ioq(q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requ return; /* - * still requests with the driver, don't idle + * idle is disabled, either manually or by past process history */ - if (efqd->rq_in_driver) + if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) return; /* - * idle is disabled, either manually or by past process history + * This queue has consumed its time slice. We are waiting only for + * it to become busy before we select next queue for dispatch. */ - if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) + if (efqd->fairness && wait_for_busy) { + elv_mark_ioq_wait_busy(ioq); + sl = efqd->elv_slice_idle; + mod_timer(&efqd->idle_slice_timer, jiffies + sl); + elv_log(efqd, "arm idle: %lu wait busy=1", sl); + return; + } + + /* + * still requests with the driver, don't idle + */ + if (efqd->rq_in_driver) return; /*@@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q } } + /* We are waiting for this queue to become busy before it expires.*/ + if (efqd->fairness && elv_ioq_wait_busy(ioq)) { + ioq = NULL; + goto keep_queue; + } + /* * The active queue has run out of time, expire it and select new. */@@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct re elv_ioq_set_prio_slice(q, ioq); elv_clear_ioq_slice_new(ioq); } - if (elv_ioq_slice_used(ioq) || elv_ioq_class_idle(ioq)) + if (elv_ioq_class_idle(ioq)) elv_ioq_slice_expired(q, 1); - else if (sync && !ioq->nr_queued) - elv_ioq_arm_slice_timer(q); + else if (sync && !ioq->nr_queued) { + if (elv_ioq_slice_used(ioq)) + elv_ioq_arm_slice_timer(q, 1); + else + elv_ioq_arm_slice_timer(q, 0); + } } if (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c 2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c 2009-03-18 17:34:28.000000000 -0400 +7
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl .show = elv_slice_idle_show, .store = elv_slice_idle_store, }; + +static struct queue_sysfs_entry queue_fairness_entry = { + .attr = {.name = "fairness", .mode = S_IRUGO | S_IWUSR }, + .show = elv_fairness_show, + .store = elv_fairness_store, +}; #endif static struct attribute *default_attrs[] = { &queue_requests_entry.attr,@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] &queue_iostats_entry.attr, #ifdef CONFIG_ELV_FAIR_QUEUING &queue_slice_idle_entry.attr, + &queue_fairness_entry.attr, #endif NULL, };
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 36 lines · Vivek Goyal
On Mon, Mar 23, 2009 at 10:32:41PM -0700, Nauman Rafique wrote:
[..]
Quoted 17 lines
Quoted 17 lines
DESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then áit will be deleted from the active tree. This will lead to a scenario áwhere out of two competing queues, only one is on the tree and when a ánew queue is selected, vtime jump takes place and we don't see services áprovided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues áwhere queues are not continuously backlogged. Looks like idling is áonly solution to make sure such kind of queues can get some decent amount áof disk bandwidth in the face of competion from continusouly backlogged áqueues. But excessive idling has potential to reduce performance on SSD áand disks with commnad queuing.
Quoted 7 lines
Quoted 3 lines
o This patch experiments with waiting for next request to come before a áqueue is expired after it has consumed its time slice. This can ensure ámore accurate fairness numbers in some cases.
Vivek, have you introduced this option just to play with it, or you are planning to make it a part of the patch set. Waiting for a new request to come before expiring time slice sounds problematic.
Why are the issues you forsee with it. This is just an extra 8ms idling on the sync queue that is also if think time of the queue is not high.
We already do idling on sync queues. In this case we are doing an extra idle even if queue has consumed its allocated quota. It helps me get fairness numbers and I have put it under a tunable "fairness". So by default this code will not kick in.
Quoted 5 lines
Other possible option could be that when expiring a sync queue, don't remove the queue immediately from the tree and remove it later if there is no request from the queue in 8ms or so. I am not sure with BFQ, is it feasible to do that without creating issues with current implementation. Current implementation was simple, so I stick to it to begin with.
If the maximum wait is bounded by 8ms, then it should be fine. The comments on the patch did not talk about such limit; it sounded like unbounded wait to me.
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 245 lines
So yes, I am planning to keep it under tunable, unless there are significant issues in doing that.
Thanks
VivekQuoted 237 lines
Quoted 237 lines
o Introduced a tunable "fairness". If set, io-controller will put more áfocus on getting fairness right than getting throughput right.
---
áblock/blk-sysfs.c á | á á7 ++++
áblock/elevator-fq.c | á 85 +++++++++++++++++++++++++++++++++++++++++++++------- áblock/elevator-fq.h | á 12 +++++++
á3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -318,6 +318,13 @@ struct elv_fq_data {á á á áunsigned long long
rate_sampling_start; /*sampling window start jifies*/ á á á á/* number of sectors finished io during current sampling window */ á á á áunsigned longrate_sectors_current;
+
+ á á á /*
+ á á á á* If set to 1, will disable many optimizations done for boost
+ á á á á* throughput and focus more on providing fairness for sync
+ á á á á* queues.
+ á á á á*/
+ á á á int fairness;
á};áextern int
elv_slice_idle;block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -340,6 +347,7 @@ enum elv_queue_state_flags {á á á áELV_QUEUE_FLAG_idle_window, á á á /* elevator slice idling enabled */ á á á áELV_QUEUE_FLAG_wait_request, á á á/* waiting for a request */ á á á áELV_QUEUE_FLAG_slice_new, á á á á /* no requests dispatched in slice */
+ á á áELV_QUEUE_FLAG_wait_busy, á á á á /* wait for this queue to get busy */ á á á áELV_QUEUE_FLAG_NR,
á};block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +1
-0@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) áELV_IO_QUEUE_FLAG_FNS(wait_request) áELV_IO_QUEUE_FLAG_FNS(idle_window) áELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy)ástatic inline struct
io_service_tree*
áio_entity_service_tree(structio_entity*entity)block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -554,6 +563,9 @@ static inline struct io_queue *elv_looku áextern ssize_t elv_slice_idle_show(struct request_queue *q, char *name); áextern ssize_t elv_slice_idle_store(struct request_queue *q, const char *name, á á á á á á á á á á á á á á á á á á á á á á á ásize_t count); +extern ssize_t elv_fairness_show(struct request_queue *q, char *name); +extern ssize_t elv_fairness_store(struct request_queue *q, const char *name, + á á á á á á á á á á á á á á á á á á á á á á á size_t count);á/* Functions used by
elevator.c*/
áextern intelv_init_fq_data(struct request_queue *q, struct elevator_queue *e);
Index:linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +38
-0@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq á á á á á á á á á á á áioq->total_service); á} +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show(struct request_queue *q, char *name) +{ + á á á struct elv_fq_data *efqd; + á á á unsigned int data; + á á á unsigned long flags; + + á á á spin_lock_irqsave(q->queue_lock, flags); + á á á efqd = &q->elevator->efqd; + á á á data = efqd->fairness; + á á á spin_unlock_irqrestore(q->queue_lock, flags); + á á á return sprintf(name, "%d\n", data); +} + +ssize_t elv_fairness_store(struct request_queue *q, const char *name, + á á á á á á á á á á á á size_t count) +{ + á á á struct elv_fq_data *efqd; + á á á unsigned int data; + á á á unsigned long flags; + + á á á char *p = (char *)name; + + á á á data = simple_strtoul(p, &p, 10); + + á á á if (data < 0) + á á á á á á á data = 0; + á á á else if (data > INT_MAX) + á á á á á á á data = INT_MAX; + + á á á spin_lock_irqsave(q->queue_lock, flags); + á á á efqd = &q->elevator->efqd; + á á á efqd->fairness = data; + á á á spin_unlock_irqrestore(q->queue_lock, flags); + + á á á return count; +} +á/* Functions to show and store
elv_idle_slicevalue through sysfs */ ássize_telv_slice_idle_show(struct request_queue *q, char *name)á{block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +2
-1@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requ á á á áassert_spin_locked(q->queue_lock); á á á áelv_log_ioq(efqd, ioq, "slice expired upd=%d", budget_update); - á á á if (elv_ioq_wait_request(ioq)) + á á á if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) á á á á á á á ádel_timer(&efqd->idle_slice_timer); á á á áelv_clear_ioq_wait_request(ioq); + á á á elv_clear_ioq_wait_busy(ioq);á á á á/*
á á á á * ifioq->slice_end= 0, that means a queue was expired before firstblock/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_á á á á á á á á * immediately and flag that we must not expire this queue á á á á á á á á * just now
á á á á á á á á */
- á á á á á á á if (elv_ioq_wait_request(ioq)) {
+ á á á á á á á if (elv_ioq_wait_request(ioq)||elv_ioq_wait_busy(ioq)) { á á á á á á á á á á á ádel_timer(&efqd->idle_slice_timer);
+ á á á á á á á á á á áelv_clear_ioq_wait_busy(ioq);
á á á á á á á á á á á áblk_start_queueing(q);
á á á á á á á á}
á á á á} else if (elv_should_preempt(q, ioq, rq)) {block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned long á á á áif (ioq) { + á á á á á á á if (elv_ioq_wait_busy(ioq)) + á á á á á á á á á á á goto expire; +á á á á á á á á/*
á á á á á á á á * expired
á á á á á á á á */block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +1
-1@@ -2546,7 +2589,7 @@ out_cont: á á á áspin_unlock_irqrestore(q->queue_lock, flags); á} -void elv_ioq_arm_slice_timer(struct request_queue *q) +void elv_ioq_arm_slice_timer(struct request_queue *q, int wait_for_busy) á{ á á á ástruct elv_fq_data *efqd = &q->elevator->efqd; á á á ástruct io_queue *ioq = elv_active_ioq(q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requ á á á á á á á áreturn;á á á á/*
- á á á á* still requests with the driver, don't idle
+ á á á á* idle is disabled, either manually or by past process history á á á á */
- á á á if (efqd->rq_in_driver)
+ á á á if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) á á á á á á á áreturn;á á á á/*
- á á á á* idle is disabled, either manually or by past process history
+ á á á á* This queue has consumed its time slice. We are waiting only for
+ á á á á* it to become busy before we select next queue for dispatch. á á á á */
- á á á if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq))
+ á á á if (efqd->fairness&&wait_for_busy) {
+ á á á á á á áelv_mark_ioq_wait_busy(ioq);
+ á á á á á á á sl =efqd->elv_slice_idle;
+ á á á á á á ámod_timer(&efqd->idle_slice_timer, jiffies + sl);
+ á á á á á á áelv_log(efqd, "arm idle: %lu wait busy=1", sl);
+ á á á á á á á return;
+ á á á }
+
+ á á á /*
+ á á á á* still requests with the driver, don't idle
+ á á á á*/
+ á á á if (efqd->rq_in_driver)
á á á á á á á áreturn;á á á á/*
block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +6
-0@@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q á á á á á á á á} á á á á} + á á á /* We are waiting for this queue to become busy before it expires.*/ + á á á if (efqd->fairness && elv_ioq_wait_busy(ioq)) { + á á á á á á á ioq = NULL; + á á á á á á á goto keep_queue; + á á á } +á á á á/*
á á á á * The active queue has run out of time, expire it and select new. á á á á */block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +7
-3@@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct re á á á á á á á á á á á áelv_ioq_set_prio_slice(q, ioq); á á á á á á á á á á á áelv_clear_ioq_slice_new(ioq); á á á á á á á á} - á á á á á á á if (elv_ioq_slice_used(ioq) || elv_ioq_class_idle(ioq)) + á á á á á á á if (elv_ioq_class_idle(ioq)) á á á á á á á á á á á áelv_ioq_slice_expired(q, 1); - á á á á á á á else if (sync && !ioq->nr_queued) - á á á á á á á á á á á elv_ioq_arm_slice_timer(q); + á á á á á á á else if (sync && !ioq->nr_queued) { + á á á á á á á á á á á if (elv_ioq_slice_used(ioq)) + á á á á á á á á á á á á á á á elv_ioq_arm_slice_timer(q, 1); + á á á á á á á á á á á else + á á á á á á á á á á á á á á á elv_ioq_arm_slice_timer(q, 0); + á á á á á á á } á á á á} á á á áif (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c á á2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c á á á 2009-03-18 17:34:28.000000000 -0400 +6
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl á á á á.show = elv_slice_idle_show, á á á á.store = elv_slice_idle_store, á}; + +static struct queue_sysfs_entry queue_fairness_entry = { + á á á .attr = {.name = "fairness", .mode = S_IRUGO | S_IWUSR }, + á á á .show = elv_fairness_show, + á á á .store = elv_fairness_store, +};á#endif
ástatic struct attribute *default_attrs[] = {
á á á á&queue_requests_entry.attr,block/blk-sysfs.c á á2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c á á á 2009-03-18 17:34:28.000000000 -0400 +0
-0@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] á á á á&queue_iostats_entry.attr,á#ifdef
CONFIG_ELV_FAIR_QUEUING
á á á á&queue_slice_idle_entry.attr,
+ á á á &queue_fairness_entry.attr,
á#endif
á á á áNULL,
á};
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 36 lines · Vivek Goyal
On Mon, Mar 23, 2009 at 10:32:41PM -0700, Nauman Rafique wrote:
[..]
Quoted 17 lines
Quoted 17 lines
DESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then áit will be deleted from the active tree. This will lead to a scenario áwhere out of two competing queues, only one is on the tree and when a ánew queue is selected, vtime jump takes place and we don't see services áprovided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues áwhere queues are not continuously backlogged. Looks like idling is áonly solution to make sure such kind of queues can get some decent amount áof disk bandwidth in the face of competion from continusouly backlogged áqueues. But excessive idling has potential to reduce performance on SSD áand disks with commnad queuing.
Quoted 7 lines
Quoted 3 lines
o This patch experiments with waiting for next request to come before a áqueue is expired after it has consumed its time slice. This can ensure ámore accurate fairness numbers in some cases.
Vivek, have you introduced this option just to play with it, or you are planning to make it a part of the patch set. Waiting for a new request to come before expiring time slice sounds problematic.
Why are the issues you forsee with it. This is just an extra 8ms idling on the sync queue that is also if think time of the queue is not high.
We already do idling on sync queues. In this case we are doing an extra idle even if queue has consumed its allocated quota. It helps me get fairness numbers and I have put it under a tunable "fairness". So by default this code will not kick in.
Quoted 5 lines
Other possible option could be that when expiring a sync queue, don't remove the queue immediately from the tree and remove it later if there is no request from the queue in 8ms or so. I am not sure with BFQ, is it feasible to do that without creating issues with current implementation. Current implementation was simple, so I stick to it to begin with.
If the maximum wait is bounded by 8ms, then it should be fine. The comments on the patch did not talk about such limit; it sounded like unbounded wait to me.
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 245 lines
So yes, I am planning to keep it under tunable, unless there are significant issues in doing that.
Thanks
VivekQuoted 237 lines
Quoted 237 lines
o Introduced a tunable "fairness". If set, io-controller will put more áfocus on getting fairness right than getting throughput right.
---
áblock/blk-sysfs.c á | á á7 ++++
áblock/elevator-fq.c | á 85 +++++++++++++++++++++++++++++++++++++++++++++------- áblock/elevator-fq.h | á 12 +++++++
á3 files changed, 94 insertions(+), 10 deletions(-)Index:
linux1/block/elevator-fq.h
===================================================================block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -318,6 +318,13 @@ struct elv_fq_data {á á á áunsigned long long
rate_sampling_start; /*sampling window start jifies*/ á á á á/* number of sectors finished io during current sampling window */ á á á áunsigned longrate_sectors_current;
+
+ á á á /*
+ á á á á* If set to 1, will disable many optimizations done for boost
+ á á á á* throughput and focus more on providing fairness for sync
+ á á á á* queues.
+ á á á á*/
+ á á á int fairness;
á};áextern int
elv_slice_idle;block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -340,6 +347,7 @@ enum elv_queue_state_flags {á á á áELV_QUEUE_FLAG_idle_window, á á á /* elevator slice idling enabled */ á á á áELV_QUEUE_FLAG_wait_request, á á á/* waiting for a request */ á á á áELV_QUEUE_FLAG_slice_new, á á á á /* no requests dispatched in slice */
+ á á áELV_QUEUE_FLAG_wait_busy, á á á á /* wait for this queue to get busy */ á á á áELV_QUEUE_FLAG_NR,
á};block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +1
-0@@ -362,6 +370,7 @@ ELV_IO_QUEUE_FLAG_FNS(sync) áELV_IO_QUEUE_FLAG_FNS(wait_request) áELV_IO_QUEUE_FLAG_FNS(idle_window) áELV_IO_QUEUE_FLAG_FNS(slice_new) +ELV_IO_QUEUE_FLAG_FNS(wait_busy)ástatic inline struct
io_service_tree*
áio_entity_service_tree(structio_entity*entity)block/elevator-fq.h á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.h á á 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -554,6 +563,9 @@ static inline struct io_queue *elv_looku áextern ssize_t elv_slice_idle_show(struct request_queue *q, char *name); áextern ssize_t elv_slice_idle_store(struct request_queue *q, const char *name, á á á á á á á á á á á á á á á á á á á á á á á ásize_t count); +extern ssize_t elv_fairness_show(struct request_queue *q, char *name); +extern ssize_t elv_fairness_store(struct request_queue *q, const char *name, + á á á á á á á á á á á á á á á á á á á á á á á size_t count);á/* Functions used by
elevator.c*/
áextern intelv_init_fq_data(struct request_queue *q, struct elevator_queue *e);
Index:linux1/block/elevator-fq.c
===================================================================block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +38
-0@@ -1837,6 +1837,44 @@ void elv_ioq_served(struct io_queue *ioq á á á á á á á á á á á áioq->total_service); á} +/* Functions to show and store fairness value through sysfs */ +ssize_t elv_fairness_show(struct request_queue *q, char *name) +{ + á á á struct elv_fq_data *efqd; + á á á unsigned int data; + á á á unsigned long flags; + + á á á spin_lock_irqsave(q->queue_lock, flags); + á á á efqd = &q->elevator->efqd; + á á á data = efqd->fairness; + á á á spin_unlock_irqrestore(q->queue_lock, flags); + á á á return sprintf(name, "%d\n", data); +} + +ssize_t elv_fairness_store(struct request_queue *q, const char *name, + á á á á á á á á á á á á size_t count) +{ + á á á struct elv_fq_data *efqd; + á á á unsigned int data; + á á á unsigned long flags; + + á á á char *p = (char *)name; + + á á á data = simple_strtoul(p, &p, 10); + + á á á if (data < 0) + á á á á á á á data = 0; + á á á else if (data > INT_MAX) + á á á á á á á data = INT_MAX; + + á á á spin_lock_irqsave(q->queue_lock, flags); + á á á efqd = &q->elevator->efqd; + á á á efqd->fairness = data; + á á á spin_unlock_irqrestore(q->queue_lock, flags); + + á á á return count; +} +á/* Functions to show and store
elv_idle_slicevalue through sysfs */ ássize_telv_slice_idle_show(struct request_queue *q, char *name)á{block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +2
-1@@ -2263,10 +2301,11 @@ void __elv_ioq_slice_expired(struct requ á á á áassert_spin_locked(q->queue_lock); á á á áelv_log_ioq(efqd, ioq, "slice expired upd=%d", budget_update); - á á á if (elv_ioq_wait_request(ioq)) + á á á if (elv_ioq_wait_request(ioq) || elv_ioq_wait_busy(ioq)) á á á á á á á ádel_timer(&efqd->idle_slice_timer); á á á áelv_clear_ioq_wait_request(ioq); + á á á elv_clear_ioq_wait_busy(ioq);á á á á/*
á á á á * ifioq->slice_end= 0, that means a queue was expired before firstblock/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +0
-0@@ -2482,8 +2521,9 @@ void elv_ioq_request_add(struct request_á á á á á á á á * immediately and flag that we must not expire this queue á á á á á á á á * just now
á á á á á á á á */
- á á á á á á á if (elv_ioq_wait_request(ioq)) {
+ á á á á á á á if (elv_ioq_wait_request(ioq)||elv_ioq_wait_busy(ioq)) { á á á á á á á á á á á ádel_timer(&efqd->idle_slice_timer);
+ á á á á á á á á á á áelv_clear_ioq_wait_busy(ioq);
á á á á á á á á á á á áblk_start_queueing(q);
á á á á á á á á}
á á á á} else if (elv_should_preempt(q, ioq, rq)) {block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +3
-0@@ -2519,6 +2559,9 @@ void elv_idle_slice_timer(unsigned long á á á áif (ioq) { + á á á á á á á if (elv_ioq_wait_busy(ioq)) + á á á á á á á á á á á goto expire; +á á á á á á á á/*
á á á á á á á á * expired
á á á á á á á á */block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +1
-1@@ -2546,7 +2589,7 @@ out_cont: á á á áspin_unlock_irqrestore(q->queue_lock, flags); á} -void elv_ioq_arm_slice_timer(struct request_queue *q) +void elv_ioq_arm_slice_timer(struct request_queue *q, int wait_for_busy) á{ á á á ástruct elv_fq_data *efqd = &q->elevator->efqd; á á á ástruct io_queue *ioq = elv_active_ioq(q->elevator);@@ -2563,15 +2606,27 @@ void elv_ioq_arm_slice_timer(struct requ á á á á á á á áreturn;á á á á/*
- á á á á* still requests with the driver, don't idle
+ á á á á* idle is disabled, either manually or by past process history á á á á */
- á á á if (efqd->rq_in_driver)
+ á á á if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq)) á á á á á á á áreturn;á á á á/*
- á á á á* idle is disabled, either manually or by past process history
+ á á á á* This queue has consumed its time slice. We are waiting only for
+ á á á á* it to become busy before we select next queue for dispatch. á á á á */
- á á á if (!efqd->elv_slice_idle || !elv_ioq_idle_window(ioq))
+ á á á if (efqd->fairness&&wait_for_busy) {
+ á á á á á á áelv_mark_ioq_wait_busy(ioq);
+ á á á á á á á sl =efqd->elv_slice_idle;
+ á á á á á á ámod_timer(&efqd->idle_slice_timer, jiffies + sl);
+ á á á á á á áelv_log(efqd, "arm idle: %lu wait busy=1", sl);
+ á á á á á á á return;
+ á á á }
+
+ á á á /*
+ á á á á* still requests with the driver, don't idle
+ á á á á*/
+ á á á if (efqd->rq_in_driver)
á á á á á á á áreturn;á á á á/*
block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +6
-0@@ -2628,6 +2683,12 @@ void *elv_fq_select_ioq(struct request_q á á á á á á á á} á á á á} + á á á /* We are waiting for this queue to become busy before it expires.*/ + á á á if (efqd->fairness && elv_ioq_wait_busy(ioq)) { + á á á á á á á ioq = NULL; + á á á á á á á goto keep_queue; + á á á } +á á á á/*
á á á á * The active queue has run out of time, expire it and select new. á á á á */block/elevator-fq.c á2009-03-18 17:34:53.000000000 -0400 renamed from block/elevator-fq.c á á 2009-03-18 17:34:46.000000000 -0400 +7
-3@@ -2802,10 +2863,14 @@ void elv_ioq_completed_request(struct re á á á á á á á á á á á áelv_ioq_set_prio_slice(q, ioq); á á á á á á á á á á á áelv_clear_ioq_slice_new(ioq); á á á á á á á á} - á á á á á á á if (elv_ioq_slice_used(ioq) || elv_ioq_class_idle(ioq)) + á á á á á á á if (elv_ioq_class_idle(ioq)) á á á á á á á á á á á áelv_ioq_slice_expired(q, 1); - á á á á á á á else if (sync && !ioq->nr_queued) - á á á á á á á á á á á elv_ioq_arm_slice_timer(q); + á á á á á á á else if (sync && !ioq->nr_queued) { + á á á á á á á á á á á if (elv_ioq_slice_used(ioq)) + á á á á á á á á á á á á á á á elv_ioq_arm_slice_timer(q, 1); + á á á á á á á á á á á else + á á á á á á á á á á á á á á á elv_ioq_arm_slice_timer(q, 0); + á á á á á á á } á á á á} á á á áif (!efqd->rq_in_driver)Index:
linux1/block/blk-sysfs.c
===================================================================block/blk-sysfs.c á á2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c á á á 2009-03-18 17:34:28.000000000 -0400 +6
-0@@ -282,6 +282,12 @@ static struct queue_sysfs_entry queue_sl á á á á.show = elv_slice_idle_show, á á á á.store = elv_slice_idle_store, á}; + +static struct queue_sysfs_entry queue_fairness_entry = { + á á á .attr = {.name = "fairness", .mode = S_IRUGO | S_IWUSR }, + á á á .show = elv_fairness_show, + á á á .store = elv_fairness_store, +};á#endif
ástatic struct attribute *default_attrs[] = {
á á á á&queue_requests_entry.attr,block/blk-sysfs.c á á2009-03-18 17:34:53.000000000 -0400 renamed from block/blk-sysfs.c á á á 2009-03-18 17:34:28.000000000 -0400 +0
-0@@ -296,6 +302,7 @@ static struct attribute *default_attrs[] á á á á&queue_iostats_entry.attr,á#ifdef
CONFIG_ELV_FAIR_QUEUING
á á á á&queue_slice_idle_entry.attr,
+ á á á &queue_fairness_entry.attr,
á#endif
á á á áNULL,
á};
Re: [PATCH 01/10] Documentation
Quoted 43 lines · Nauman Rafique
Quoted 36 lines · Vivek Goyal
On Mon, Mar 23, 2009 at 10:32:41PM -0700, Nauman Rafique wrote:
[..]
Quoted 17 lines
Quoted 17 lines
DESC
io-controller: idle for sometime on sync queue before expiring it EDESCo When a sync queue expires, in many cases it might be empty and then áit will be deleted from the active tree. This will lead to a scenario áwhere out of two competing queues, only one is on the tree and when a ánew queue is selected, vtime jump takes place and we don't see services áprovided in proportion to weight.
o In general this is a fundamental problem with fairness of sync queues áwhere queues are not continuously backlogged. Looks like idling is áonly solution to make sure such kind of queues can get some decent amount áof disk bandwidth in the face of competion from continusouly backlogged áqueues. But excessive idling has potential to reduce performance on SSD áand disks with commnad queuing.
Quoted 7 lines
Quoted 3 lines
o This patch experiments with waiting for next request to come before a áqueue is expired after it has consumed its time slice. This can ensure ámore accurate fairness numbers in some cases.
Vivek, have you introduced this option just to play with it, or you are planning to make it a part of the patch set. Waiting for a new request to come before expiring time slice sounds problematic.
Why are the issues you forsee with it. This is just an extra 8ms idling on the sync queue that is also if think time of the queue is not high.
We already do idling on sync queues. In this case we are doing an extra idle even if queue has consumed its allocated quota. It helps me get fairness numbers and I have put it under a tunable "fairness". So by default this code will not kick in.
Quoted 5 lines
Other possible option could be that when expiring a sync queue, don't remove the queue immediately from the tree and remove it later if there is no request from the queue in 8ms or so. I am not sure with BFQ, is it feasible to do that without creating issues with current implementation. Current implementation was simple, so I stick to it to begin with.
Quoted 7 lines
If the maximum wait is bounded by 8ms, then it should be fine. The comments on the patch did not talk about such limit; it sounded like unbounded wait to me.
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
Quoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400
...
Quoted 7 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Re: [PATCH 01/10] Documentation
Quoted 8 lines · Fabio Checconi
Quoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400...
Quoted 4 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 6 lines
Quoted 3 lines
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Yes. Is it possible to keep a not-backlogged queue in the tree for later expiry. So that we don't actively wait/idle for next request to come and hope queue will become backlogged soon. Otherwise, it will be deleted from the active queue. This is just a thought, I am not even sure how would it interefere with bfq code.
All this to solve the vtime jump issue for sync queues.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400
...
Quoted 7 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 16 lines · Vivek Goyal
Quoted 8 lines · Fabio Checconi
Quoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400...
Quoted 4 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 6 lines
Quoted 3 lines
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Quoted 7 lines
Yes. Is it possible to keep a not-backlogged queue in the tree for later expiry. So that we don't actively wait/idle for next request to come and hope queue will become backlogged soon. Otherwise, it will be deleted from the active queue. This is just a thought, I am not even sure how would it interefere with bfq code.
All this to solve the vtime jump issue for sync queues.
If only vtime jump is an issue, can we solve it by delaying vtime jump? That is, even if we serve an entity with a bigger vtime, we don't update the reference vtime of the service tree until after some time?
Quoted 4 lines
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 16 lines · Vivek Goyal
Quoted 8 lines · Fabio Checconi
Quoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400...
Quoted 4 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 6 lines
Quoted 3 lines
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Quoted 7 lines
Yes. Is it possible to keep a not-backlogged queue in the tree for later expiry. So that we don't actively wait/idle for next request to come and hope queue will become backlogged soon. Otherwise, it will be deleted from the active queue. This is just a thought, I am not even sure how would it interefere with bfq code.
All this to solve the vtime jump issue for sync queues.
If only vtime jump is an issue, can we solve it by delaying vtime jump? That is, even if we serve an entity with a bigger vtime, we don't update the reference vtime of the service tree until after some time?
Quoted 4 lines
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 19 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:35:32PM -0400Quoted 8 lines · Fabio Checconi
Quoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400...
Quoted 4 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 6 lines
Quoted 3 lines
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Quoted 8 lines
Yes. Is it possible to keep a not-backlogged queue in the tree for later expiry. So that we don't actively wait/idle for next request to come and hope queue will become backlogged soon. Otherwise, it will be deleted from the active queue. This is just a thought, I am not even sure how would it interefere with bfq code.
All this to solve the vtime jump issue for sync queues.
Of course it is possible, but if you stick with wf2q+ the virtual time will jump anyway, and the gain would be that each scheduling decision will have O(N logN) complexity instead of O(log N), to skip empty queues.
Otherwise, if you'll do your own timestamping (where any new request can get a timestamp smaller that the virtual time) then nothing from the theory BFQ was based on can give any hint on the guarantees that the resulting algorithm can provide.
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 19 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:35:32PM -0400Quoted 8 lines · Fabio Checconi
Quoted 3 lines
From: Vivek Goyal <[email protected]>
Date: Tue, Mar 24, 2009 02:29:06PM -0400...
Quoted 4 lines
Quoted 3 lines
Does keeping the sync queue in ready tree solves the problem too? Is it because it avoid a virtual time jump?
Quoted 6 lines
Quoted 3 lines
I have not tried the second approch yet. But that also should solve the vtime jump issue.
Do you mean that you intend to keep a queue with no backlog in the active tree?
Quoted 8 lines
Yes. Is it possible to keep a not-backlogged queue in the tree for later expiry. So that we don't actively wait/idle for next request to come and hope queue will become backlogged soon. Otherwise, it will be deleted from the active queue. This is just a thought, I am not even sure how would it interefere with bfq code.
All this to solve the vtime jump issue for sync queues.
Of course it is possible, but if you stick with wf2q+ the virtual time will jump anyway, and the gain would be that each scheduling decision will have O(N logN) complexity instead of O(log N), to skip empty queues.
Otherwise, if you'll do your own timestamping (where any new request can get a timestamp smaller that the virtual time) then nothing from the theory BFQ was based on can give any hint on the guarantees that the resulting algorithm can provide.
PATCH 1/1 IO Controller: No need to stop idling in as
In reply to a message not in the archiveReview
Quoted 8 lines · Vivek Goyal
(quoted diff) +4
-1.elevator_alloc_sched_queue_fn = as_alloc_as_queue, .elevator_free_sched_queue_fn = as_free_as_queue, +#ifdef CONFIG_IOSCHED_AS_HIER + .elevator_expire_ioq_fn = as_expire_ioq, + .elevator_active_ioq_set_fn = as_active_ioq_set, }, - + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE,
Hi Vivek,
I found the IO Controller doesn't work in as.
I dig into this issue, and notice that you stop idling in as. IMHO, this will cause active ioq is always expired when tring to choose a new ioq to serve(elv_fq_select_ioq). Because idling is disabled, active ioq can't be kept anymore.
So i just get rid of ELV_IOSCHED_DONT_IDLE, and it works fine this time.
--- block/as-iosched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block/as-iosched.c +1 -1
@@ -1689,7 +1689,7 @@ static struct elevator_type iosched_as = { .elevator_expire_ioq_fn = as_expire_ioq, .elevator_active_ioq_set_fn = as_active_ioq_set, }, - .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE, + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, #else },#endif
Signature · 1 line
1.5.4.rc3
PATCH 1/1 IO Controller: No need to stop idling in as
In reply to Vivek GoyalReview
Quoted 8 lines · Vivek Goyal
(quoted diff) +4
-1.elevator_alloc_sched_queue_fn = as_alloc_as_queue, .elevator_free_sched_queue_fn = as_free_as_queue, +#ifdef CONFIG_IOSCHED_AS_HIER + .elevator_expire_ioq_fn = as_expire_ioq, + .elevator_active_ioq_set_fn = as_active_ioq_set, }, - + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE,
Hi Vivek,
I found the IO Controller doesn't work in as.
I dig into this issue, and notice that you stop idling in as. IMHO, this will cause active ioq is always expired when tring to choose a new ioq to serve(elv_fq_select_ioq). Because idling is disabled, active ioq can't be kept anymore.
So i just get rid of ELV_IOSCHED_DONT_IDLE, and it works fine this time.
--- block/as-iosched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block/as-iosched.c +1 -1
@@ -1689,7 +1689,7 @@ static struct elevator_type iosched_as = { .elevator_expire_ioq_fn = as_expire_ioq, .elevator_active_ioq_set_fn = as_active_ioq_set, }, - .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE, + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, #else },#endif
Signature · 1 line
1.5.4.rc3
PATCH 1/1 IO Controller: Don't store the pid in single queue circumstances
In reply to a message not in the archiveVivek Goyal wrote:
...
Quoted 4 lines
(quoted diff) +4
-0+int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, + void *sched_queue, int ioprio_class, int ioprio, + int is_sync) +{
Review
Quoted 10 lines
(quoted diff) +10
-0+ struct elv_fq_data *efqd = &eq->efqd; + struct io_group *iog = io_lookup_io_group_current(efqd->queue); + + RB_CLEAR_NODE(&ioq->entity.rb_node); + atomic_set(&ioq->ref, 0); + ioq->efqd = efqd; + ioq->entity.budget = efqd->elv_slice[is_sync]; + elv_ioq_set_ioprio_class(ioq, ioprio_class); + elv_ioq_set_ioprio(ioq, ioprio); + ioq->pid = current->pid;
Hi Vivek,
Storing a pid in single queue circumstances doesn't make sence. So just store the pid when cfq is used.
---
block/elevator-fq.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
block/elevator-fq.c +4 -1
@@ -1988,7 +1988,10 @@ int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, ioq->entity.budget = efqd->elv_slice[is_sync];elv_ioq_set_ioprio_class (ioq, ioprio_class);elv_ioq_set_ioprio (ioq, ioprio); - ioq->pid = current->pid; +if (elv_iosched_single_ioq (eq)) + ioq->pid =0 ; +else + ioq->pid = current->pid; ioq->sched_queue = sched_queue;/* If generic idle logic is enabled, mark it */
Signature · 1 line
1.5.4.rc3
PATCH 1/1 IO Controller: Don't store the pid in single queue circumstances
In reply to Vivek GoyalVivek Goyal wrote:
...
Quoted 4 lines
(quoted diff) +4
-0+int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, + void *sched_queue, int ioprio_class, int ioprio, + int is_sync) +{
Review
Quoted 10 lines
(quoted diff) +10
-0+ struct elv_fq_data *efqd = &eq->efqd; + struct io_group *iog = io_lookup_io_group_current(efqd->queue); + + RB_CLEAR_NODE(&ioq->entity.rb_node); + atomic_set(&ioq->ref, 0); + ioq->efqd = efqd; + ioq->entity.budget = efqd->elv_slice[is_sync]; + elv_ioq_set_ioprio_class(ioq, ioprio_class); + elv_ioq_set_ioprio(ioq, ioprio); + ioq->pid = current->pid;
Hi Vivek,
Storing a pid in single queue circumstances doesn't make sence. So just store the pid when cfq is used.
---
block/elevator-fq.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
block/elevator-fq.c +4 -1
@@ -1988,7 +1988,10 @@ int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, ioq->entity.budget = efqd->elv_slice[is_sync];elv_ioq_set_ioprio_class (ioq, ioprio_class);elv_ioq_set_ioprio (ioq, ioprio); - ioq->pid = current->pid; +if (elv_iosched_single_ioq (eq)) + ioq->pid =0 ; +else + ioq->pid = current->pid; ioq->sched_queue = sched_queue;/* If generic idle logic is enabled, mark it */
Signature · 1 line
1.5.4.rc3
Re: [PATCH] IO Controller: Don't store the pid in single queue circumstances
In reply to a message not in the archiveQuoted 32 lines · Gui Jianfeng
Vivek Goyal wrote:
...Quoted 4 lines
(quoted diff) +4
-0+int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, + void *sched_queue, int ioprio_class, int ioprio, + int is_sync) +{Review
Quoted 10 lines
(quoted diff) +10
-0+ struct elv_fq_data *efqd = &eq->efqd; + struct io_group *iog = io_lookup_io_group_current(efqd->queue); + + RB_CLEAR_NODE(&ioq->entity.rb_node); + atomic_set(&ioq->ref, 0); + ioq->efqd = efqd; + ioq->entity.budget = efqd->elv_slice[is_sync]; + elv_ioq_set_ioprio_class(ioq, ioprio_class); + elv_ioq_set_ioprio(ioq, ioprio); + ioq->pid = current->pid;Hi Vivek,
Storing a pid in single queue circumstances doesn't make sence. So just store the pid when cfq is used.
Signed-off-by Gui Jianfeng <[email protected]>---
block/elevator-fq.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)block/elevator-fq.c +0
-0
block/elevator-fq.c int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, · line 1995
Quoted 9 lines
block/elevator-fq.c +4
-1@@ -1988,7 +1988,10 @@ int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, ioq->entity.budget = efqd->elv_slice[is_sync];elv_ioq_set_ioprio_class (ioq, ioprio_class);elv_ioq_set_ioprio (ioq, ioprio); - ioq->pid = current->pid; +if (elv_iosched_single_ioq (eq)) + ioq->pid =0 ; +else + ioq->pid = current->pid; ioq->sched_queue = sched_queue;
Thanks Gui. Yes, if there is a single ioq, this pid will reflect the pid of the process who caused the creation of the io queue and later requests from all the other processess will go into same queue.
In fact cfq also has the same issue for async queues where async queue will store the pid when it is created later all other processes of same prio level will use it.
So if you think displaying "0" is better than displaying the the pid of the process who created the queue, then I will include this patch. Right now I don't have very strong opinion about it.
Thanks
Vivek
Re: [PATCH] IO Controller: Don't store the pid in single queue circumstances
In reply to Gui JianfengQuoted 32 lines · Gui Jianfeng
Vivek Goyal wrote:
...Quoted 4 lines
(quoted diff) +4
-0+int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, + void *sched_queue, int ioprio_class, int ioprio, + int is_sync) +{Review
Quoted 10 lines
(quoted diff) +10
-0+ struct elv_fq_data *efqd = &eq->efqd; + struct io_group *iog = io_lookup_io_group_current(efqd->queue); + + RB_CLEAR_NODE(&ioq->entity.rb_node); + atomic_set(&ioq->ref, 0); + ioq->efqd = efqd; + ioq->entity.budget = efqd->elv_slice[is_sync]; + elv_ioq_set_ioprio_class(ioq, ioprio_class); + elv_ioq_set_ioprio(ioq, ioprio); + ioq->pid = current->pid;Hi Vivek,
Storing a pid in single queue circumstances doesn't make sence. So just store the pid when cfq is used.
Signed-off-by Gui Jianfeng <[email protected]>---
block/elevator-fq.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)block/elevator-fq.c +0
-0
block/elevator-fq.c int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, · line 1995
Quoted 9 lines
block/elevator-fq.c +4
-1@@ -1988,7 +1988,10 @@ int elv_init_ioq(struct elevator_queue *eq, struct io_queue *ioq, ioq->entity.budget = efqd->elv_slice[is_sync];elv_ioq_set_ioprio_class (ioq, ioprio_class);elv_ioq_set_ioprio (ioq, ioprio); - ioq->pid = current->pid; +if (elv_iosched_single_ioq (eq)) + ioq->pid =0 ; +else + ioq->pid = current->pid; ioq->sched_queue = sched_queue;
Thanks Gui. Yes, if there is a single ioq, this pid will reflect the pid of the process who caused the creation of the io queue and later requests from all the other processess will go into same queue.
In fact cfq also has the same issue for async queues where async queue will store the pid when it is created later all other processes of same prio level will use it.
So if you think displaying "0" is better than displaying the the pid of the process who created the queue, then I will include this patch. Right now I don't have very strong opinion about it.
Thanks
Vivek
Re: [PATCH] IO Controller: No need to stop idling in as
In reply to a message not in the archiveQuoted 13 lines · Gui Jianfeng
Review
Quoted 8 lines · Vivek Goyal
(quoted diff) +4
-1.elevator_alloc_sched_queue_fn = as_alloc_as_queue, .elevator_free_sched_queue_fn = as_free_as_queue, +#ifdef CONFIG_IOSCHED_AS_HIER + .elevator_expire_ioq_fn = as_expire_ioq, + .elevator_active_ioq_set_fn = as_active_ioq_set, }, - + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE,Hi Vivek,
Quoted 6 lines
I found the IO Controller doesn't work in as.
I dig into this issue, and notice that you stop idling in as. IMHO, this will cause active ioq is always expired when tring to choose a new ioq toserve(elv_fq_select_ioq). Because idling is disabled, active ioq can't be kept anymore.
So i just get rid ofELV_IOSCHED_DONT_IDLE, and it works fine this time.
Hi Gui,
Thanks for the testing. I have not enabled idling for AS in common layer becuase AS has its own idling/anticipation logic. I think we should not have anticipation going on at two places, common layer as well as individual io scheduler. That's the reason I have implemented a function elv_iosched_expire_ioq(), which calls io scheduler to find out if an ioq can be expired now.
So in elv_fq_select_ioq(), we call elv_iosched_expire_ioq() and if ioschduler denies expiration, then we don't expire the queue. In this case AS can deny the expiration if it is anticipating for next request.
Actually AS is very different and its little tricky to make it work with common layer, especially in terms of anticipation. This is on my TODO list but before I fix AS, I wanted to get other things right with common layer, cfq, noop and deadline.
Thanks
Vivek
Quoted 21 lines
Signed-off-by Gui Jianfeng <[email protected]>--- block/as-iosched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)block/as-iosched.c +1
-1@@ -1689,7 +1689,7 @@ static struct elevator_type iosched_as = { .elevator_expire_ioq_fn = as_expire_ioq, .elevator_active_ioq_set_fn = as_active_ioq_set, }, - .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE, + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, #else },#endif Signature · 1 line
1.5.4.rc3
Re: [PATCH] IO Controller: No need to stop idling in as
In reply to Gui JianfengQuoted 13 lines · Gui Jianfeng
Review
Quoted 8 lines · Vivek Goyal
(quoted diff) +4
-1.elevator_alloc_sched_queue_fn = as_alloc_as_queue, .elevator_free_sched_queue_fn = as_free_as_queue, +#ifdef CONFIG_IOSCHED_AS_HIER + .elevator_expire_ioq_fn = as_expire_ioq, + .elevator_active_ioq_set_fn = as_active_ioq_set, }, - + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE,Hi Vivek,
Quoted 6 lines
I found the IO Controller doesn't work in as.
I dig into this issue, and notice that you stop idling in as. IMHO, this will cause active ioq is always expired when tring to choose a new ioq toserve(elv_fq_select_ioq). Because idling is disabled, active ioq can't be kept anymore.
So i just get rid ofELV_IOSCHED_DONT_IDLE, and it works fine this time.
Hi Gui,
Thanks for the testing. I have not enabled idling for AS in common layer becuase AS has its own idling/anticipation logic. I think we should not have anticipation going on at two places, common layer as well as individual io scheduler. That's the reason I have implemented a function elv_iosched_expire_ioq(), which calls io scheduler to find out if an ioq can be expired now.
So in elv_fq_select_ioq(), we call elv_iosched_expire_ioq() and if ioschduler denies expiration, then we don't expire the queue. In this case AS can deny the expiration if it is anticipating for next request.
Actually AS is very different and its little tricky to make it work with common layer, especially in terms of anticipation. This is on my TODO list but before I fix AS, I wanted to get other things right with common layer, cfq, noop and deadline.
Thanks
Vivek
Quoted 21 lines
Signed-off-by Gui Jianfeng <[email protected]>--- block/as-iosched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)block/as-iosched.c +1
-1@@ -1689,7 +1689,7 @@ static struct elevator_type iosched_as = { .elevator_expire_ioq_fn = as_expire_ioq, .elevator_active_ioq_set_fn = as_active_ioq_set, }, - .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE, + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, #else },#endif Signature · 1 line
1.5.4.rc3
Re: [PATCH] IO Controller: No need to stop idling in as
In reply to a message not in the archiveQuoted 20 lines · Vivek Goyal
Quoted 12 lines · Gui Jianfeng
Review
Quoted 8 lines · Vivek Goyal
(quoted diff) +4
-1.elevator_alloc_sched_queue_fn = as_alloc_as_queue, .elevator_free_sched_queue_fn = as_free_as_queue, +#ifdef CONFIG_IOSCHED_AS_HIER + .elevator_expire_ioq_fn = as_expire_ioq, + .elevator_active_ioq_set_fn = as_active_ioq_set, }, - + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE,Hi Vivek,
Quoted 6 lines
I found the IO Controller doesn't work in as.
I dig into this issue, and notice that you stop idling in as. IMHO, this will cause active ioq is always expired when tring to choose a new ioq toserve(elv_fq_select_ioq). Because idling is disabled, active ioq can't be kept anymore.
So i just get rid ofELV_IOSCHED_DONT_IDLE, and it works fine this time.
Quoted 8 lines
Hi Gui,
Thanks for the testing. I have not enabled idling for AS in common layer becuase AS has its own idling/anticipation logic. I think we should not have anticipation going on at two places, common layer as well as individual io scheduler. That's the reason I have implemented a function
elv_iosched_expire_ioq(), which calls io scheduler to find out if an ioq can be expired now.
Hi Vivek,
If an user chooses fairness rather than throughput just like what your fairness patch is tring to do. Do we need to enable the common idling logic for as in this scenario.
Quoted 38 lines
So in
elv_fq_select_ioq(), we callelv_iosched_expire_ioq()and if ioschduler denies expiration, then we don't expire the queue. In this case AS can deny the expiration if it is anticipating for next request.Actually AS is very different and its little tricky to make it work with common layer, especially in terms of anticipation. This is on my TODO list but before I fix AS, I wanted to get other things right with common layer, cfq, noop and deadline.
Thanks
VivekQuoted 21 lines
Signed-off-by Gui Jianfeng <[email protected]>--- block/as-iosched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)block/as-iosched.c +1
-1@@ -1689,7 +1689,7 @@ static struct elevator_type iosched_as = { .elevator_expire_ioq_fn = as_expire_ioq, .elevator_active_ioq_set_fn = as_active_ioq_set, }, - .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE, + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, #else },#endif Signature · 1 line
1.5.4.rc3
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH] IO Controller: No need to stop idling in as
In reply to Vivek GoyalQuoted 20 lines · Vivek Goyal
Quoted 12 lines · Gui Jianfeng
Review
Quoted 8 lines · Vivek Goyal
(quoted diff) +4
-1.elevator_alloc_sched_queue_fn = as_alloc_as_queue, .elevator_free_sched_queue_fn = as_free_as_queue, +#ifdef CONFIG_IOSCHED_AS_HIER + .elevator_expire_ioq_fn = as_expire_ioq, + .elevator_active_ioq_set_fn = as_active_ioq_set, }, - + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE,Hi Vivek,
Quoted 6 lines
I found the IO Controller doesn't work in as.
I dig into this issue, and notice that you stop idling in as. IMHO, this will cause active ioq is always expired when tring to choose a new ioq toserve(elv_fq_select_ioq). Because idling is disabled, active ioq can't be kept anymore.
So i just get rid ofELV_IOSCHED_DONT_IDLE, and it works fine this time.
Quoted 8 lines
Hi Gui,
Thanks for the testing. I have not enabled idling for AS in common layer becuase AS has its own idling/anticipation logic. I think we should not have anticipation going on at two places, common layer as well as individual io scheduler. That's the reason I have implemented a function
elv_iosched_expire_ioq(), which calls io scheduler to find out if an ioq can be expired now.
Hi Vivek,
If an user chooses fairness rather than throughput just like what your fairness patch is tring to do. Do we need to enable the common idling logic for as in this scenario.
Quoted 38 lines
So in
elv_fq_select_ioq(), we callelv_iosched_expire_ioq()and if ioschduler denies expiration, then we don't expire the queue. In this case AS can deny the expiration if it is anticipating for next request.Actually AS is very different and its little tricky to make it work with common layer, especially in terms of anticipation. This is on my TODO list but before I fix AS, I wanted to get other things right with common layer, cfq, noop and deadline.
Thanks
VivekQuoted 21 lines
Signed-off-by Gui Jianfeng <[email protected]>--- block/as-iosched.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)block/as-iosched.c +1
-1@@ -1689,7 +1689,7 @@ static struct elevator_type iosched_as = { .elevator_expire_ioq_fn = as_expire_ioq, .elevator_active_ioq_set_fn = as_active_ioq_set, }, - .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ | ELV_IOSCHED_DONT_IDLE, + .elevator_features = ELV_IOSCHED_NEED_FQ | ELV_IOSCHED_SINGLE_IOQ, #else },#endif Signature · 1 line
1.5.4.rc3
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 02/10] Common flat fair queuing code in elevaotor layer
In reply to a message not in the archiveQuoted 18 lines · Vivek Goyal
block/elevator-fq.c new file +17
-0+/* +* elv_exit_fq_data is called before we call elevator_exit_fn. Before +* we ask elevator to cleanup its queues, we do the cleanup here so +* that all the group and idle tree references to ioq are dropped. Later +* during elevator cleanup, ioc reference will be dropped which will lead +* to removal of ioscheduler queue as well as associated ioq object. +*/ +void elv_exit_fq_data (struct elevator_queue *e) +{ +struct elv_fq_data *efqd = &e->efqd; +struct request_queue *q = efqd->queue; + +if (!elv_iosched_fair_queuing_enabled (e)) +return ; + +elv_shutdown_timer_wq (e); +
block/elevator-fq.c line 1842
Quoted 10 lines
block/elevator-fq.c new file +10
-0+spin_lock_irq (q->queue_lock); +/* This should drop all the idle tree references of ioq */ +elv_free_idle_ioq_list (e); +spin_unlock_irq (q->queue_lock); + +elv_shutdown_timer_wq (e); + +BUG_ON (timer_pending (&efqd->idle_slice_timer)); +io_free_root_group (e); +}
Hi Vivek,
When cleaning up the elv_fq_data and ioqs for the iogs
associated with a device on elv_exit(), I don't see any iogs except the root group being freed. In io_disconnect_groups() you remove the ioqs from each of the iog and move them to the root iog and then delete the root iog. Am I missing something here or are there leftover iogs at elv_exit?
-Divyesh
Re: [PATCH 02/10] Common flat fair queuing code in elevaotor layer
In reply to Vivek GoyalQuoted 18 lines · Vivek Goyal
block/elevator-fq.c new file +17
-0+/* +* elv_exit_fq_data is called before we call elevator_exit_fn. Before +* we ask elevator to cleanup its queues, we do the cleanup here so +* that all the group and idle tree references to ioq are dropped. Later +* during elevator cleanup, ioc reference will be dropped which will lead +* to removal of ioscheduler queue as well as associated ioq object. +*/ +void elv_exit_fq_data (struct elevator_queue *e) +{ +struct elv_fq_data *efqd = &e->efqd; +struct request_queue *q = efqd->queue; + +if (!elv_iosched_fair_queuing_enabled (e)) +return ; + +elv_shutdown_timer_wq (e); +
block/elevator-fq.c line 1842
Quoted 10 lines
block/elevator-fq.c new file +10
-0+spin_lock_irq (q->queue_lock); +/* This should drop all the idle tree references of ioq */ +elv_free_idle_ioq_list (e); +spin_unlock_irq (q->queue_lock); + +elv_shutdown_timer_wq (e); + +BUG_ON (timer_pending (&efqd->idle_slice_timer)); +io_free_root_group (e); +}
Hi Vivek,
When cleaning up the elv_fq_data and ioqs for the iogs
associated with a device on elv_exit(), I don't see any iogs except the root group being freed. In io_disconnect_groups() you remove the ioqs from each of the iog and move them to the root iog and then delete the root iog. Am I missing something here or are there leftover iogs at elv_exit?
-Divyesh
Quoted 11 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Hi Vivek,
I did some tests on my *old* i386 box(with two concurrent dd running), and notice that IO Controller doesn't work fine in such situation. But it can work perfectly in my *new* x86 box. I dig into this problem, and i guess the major reason is that my *old* i386 box is too slow, it can't ensure two running ioqs are always backlogged. If that is the case, I happens to have a thought. when an ioq uses up it time slice, we don't expire it immediately. May be we can give a piece of bonus time for idling to wait new requests if this ioq's finish time and its ancestor's finish time are all much smaller than other entities in each corresponding service tree.
Signature · 2 lines
Regards Gui Jianfeng
Quoted 11 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Hi Vivek,
I did some tests on my *old* i386 box(with two concurrent dd running), and notice that IO Controller doesn't work fine in such situation. But it can work perfectly in my *new* x86 box. I dig into this problem, and i guess the major reason is that my *old* i386 box is too slow, it can't ensure two running ioqs are always backlogged. If that is the case, I happens to have a thought. when an ioq uses up it time slice, we don't expire it immediately. May be we can give a piece of bonus time for idling to wait new requests if this ioq's finish time and its ancestor's finish time are all much smaller than other entities in each corresponding service tree.
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 02/10] Common flat fair queuing code in elevaotor layer
In reply to a message not in the archiveQuoted 30 lines · Divyesh Shah
Quoted 18 lines · Vivek Goyal
block/elevator-fq.c new file +17
-0+/* +* elv_exit_fq_data is called before we call elevator_exit_fn. Before +* we ask elevator to cleanup its queues, we do the cleanup here so +* that all the group and idle tree references to ioq are dropped. Later +* during elevator cleanup, ioc reference will be dropped which will lead +* to removal of ioscheduler queue as well as associated ioq object. +*/ +void elv_exit_fq_data (struct elevator_queue *e) +{ +struct elv_fq_data *efqd = &e->efqd; +struct request_queue *q = efqd->queue; + +if (!elv_iosched_fair_queuing_enabled (e)) +return ; + +elv_shutdown_timer_wq (e); +block/elevator-fq.c line 1842
Quoted 10 lines
block/elevator-fq.c new file +10
-0+spin_lock_irq (q->queue_lock); +/* This should drop all the idle tree references of ioq */ +elv_free_idle_ioq_list (e); +spin_unlock_irq (q->queue_lock); + +elv_shutdown_timer_wq (e); + +BUG_ON (timer_pending (&efqd->idle_slice_timer)); +io_free_root_group (e); +}
Quoted 7 lines
Hi Vivek,
When cleaning up theelv_fq_dataand ioqs for the iogs
associated with a device onelv_exit(), I don't see any iogs except the root group being freed. Inio_disconnect_groups()you remove the ioqs from each of the iog and move them to the root iog and then delete the root iog. Am I missing something here or are there leftover iogs atelv_exit?
Hi Divyesh,
io_groups are linked in two lists. One list is maintained by io_cgroup to keep track of how many io_groups are there associated with this cgroup and other list is maintained in elv_fq_data to keep track of how many io_groups are actually doing IO to this device.
Upon elevator exit, we remove the io_groups (io_disconnect_groups())from the list maintained by elv_fq_data but we don't free them up. Freeing up is finally done when cgroup is being deleted (iocg_destroy()).
Thanks
Vivek
Re: [PATCH 02/10] Common flat fair queuing code in elevaotor layer
In reply to Divyesh ShahQuoted 30 lines · Divyesh Shah
Quoted 18 lines · Vivek Goyal
block/elevator-fq.c new file +17
-0+/* +* elv_exit_fq_data is called before we call elevator_exit_fn. Before +* we ask elevator to cleanup its queues, we do the cleanup here so +* that all the group and idle tree references to ioq are dropped. Later +* during elevator cleanup, ioc reference will be dropped which will lead +* to removal of ioscheduler queue as well as associated ioq object. +*/ +void elv_exit_fq_data (struct elevator_queue *e) +{ +struct elv_fq_data *efqd = &e->efqd; +struct request_queue *q = efqd->queue; + +if (!elv_iosched_fair_queuing_enabled (e)) +return ; + +elv_shutdown_timer_wq (e); +block/elevator-fq.c line 1842
Quoted 10 lines
block/elevator-fq.c new file +10
-0+spin_lock_irq (q->queue_lock); +/* This should drop all the idle tree references of ioq */ +elv_free_idle_ioq_list (e); +spin_unlock_irq (q->queue_lock); + +elv_shutdown_timer_wq (e); + +BUG_ON (timer_pending (&efqd->idle_slice_timer)); +io_free_root_group (e); +}
Quoted 7 lines
Hi Vivek,
When cleaning up theelv_fq_dataand ioqs for the iogs
associated with a device onelv_exit(), I don't see any iogs except the root group being freed. Inio_disconnect_groups()you remove the ioqs from each of the iog and move them to the root iog and then delete the root iog. Am I missing something here or are there leftover iogs atelv_exit?
Hi Divyesh,
io_groups are linked in two lists. One list is maintained by io_cgroup to keep track of how many io_groups are there associated with this cgroup and other list is maintained in elv_fq_data to keep track of how many io_groups are actually doing IO to this device.
Upon elevator exit, we remove the io_groups (io_disconnect_groups())from the list maintained by elv_fq_data but we don't free them up. Freeing up is finally done when cgroup is being deleted (iocg_destroy()).
Thanks
Vivek
Quoted 13 lines · Gui Jianfeng
Quoted 11 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Quoted 6 lines
Hi Vivek,
I did some tests on my *old* i386 box(with two concurrent dd running), and notice that IO Controller doesn't work fine in such situation. But it can work perfectly in my *new* x86 box. I dig into this problem, and i guess the major reason is that my *old* i386 box is too slow, it can't ensure two running ioqs are always backlogged.
Hi Gui,
Have you run top to see what's the percentage cpu usage. I suspect that cpu is not keeping up pace disk to enqueue enough requests. I think process might be blocked somewhere else so that it could not issue requests.
Quoted 4 lines
If that is the case, I happens to have a thought. when an ioq uses up it time slice, we don't expire it immediately. May be we can give a piece of bonus time for idling to wait new requests if this ioq's finish time and its ancestor's finish time are all much smaller than other entities in each corresponding service tree.
Have you tried it with "fairness" enabled? With "fairness" enabled, for sync queues I am waiting for one extra idle time slice "8ms" for queue to get backlogged again before I move to the next queue?
Otherwise try to increase the idle time length to higher value say "12ms" just to see if that has any impact.
Can you please also send me output of blkparse. It might give some idea how IO schedulers see IO pattern.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/
There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Quoted 9 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Quoted 8 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Quoted 5 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time. So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.
I still have to look closely at your patchset anyway. I will do and give a feedback.
-Andrea
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/
There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Quoted 9 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Quoted 8 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Quoted 5 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time. So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.
I still have to look closely at your patchset anyway. I will do and give a feedback.
-Andrea
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 81 lines · Andrea Righi
Quoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Quoted 9 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Quoted 8 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Quoted 5 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Quoted 6 lines
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time. So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.
I completely agree with Andrea here. The final solution has to have both absolute limits and proportions. But instead of adding a token based approach on top of proportional based system, I have been thinking about modifying the proportional approach to support absolute limits. This might not work, but I think this is an interesting idea to think about.
Here are my thoughts on it so far. We start with the patches that Vivek has sent, and change the notion of weights to percent. That is, the user space specifies percents of disk times instead of weights. We do not put entities in idle tree; whenever an entity is not backlogged, we still keep them in the active trees, and allocate them time slices. But since they have not requests in them, no requests will get dispatched during the time slices allocated to these entities. Moreover, if the percents of all entities do not add upto hundred, we introduce a dummy entity at each level to soak up the rest of "percent". This dummy entity would get time slices just like any other entity, but will not dispatch any requests. With these modification, we can limit entities to their allocated percent of disk time.
We might want a situation in which we want to allow certain entities to exceed their "percent" of disk time, while others should be limited. In this case, we can extend the above mentioned approach by introducing a secondary active tree. All entities which are allowed to exceed their "percent" can be queued in the secondary tree, besides the primary tree. Whenever an idle (or dummy) entity gets a time slice, instead of idling the disk, an entity can be picked from the secondary tree.
The advantage of an approach like this is that it will be relatively smaller modification of the proposed proportional approach. Moreover, entities will be throttled by getting time slices less frequently, instead of being allowed to send a burst and then getting starved (like in ticket based approach). The downside is that this approach sounds unconventional and probably have not been tried in other domains either. Thoughts? opinions?
I will create patches based on the above idea in a few weeks.
Quoted 6 lines
I still have to look closely at your patchset anyway. I will do and give a feedback.
-Andrea
Re: [PATCH 01/10] Documentation
In reply to Andrea RighiQuoted 81 lines · Andrea Righi
Quoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Quoted 9 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Quoted 8 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Quoted 5 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Quoted 6 lines
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time. So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.
I completely agree with Andrea here. The final solution has to have both absolute limits and proportions. But instead of adding a token based approach on top of proportional based system, I have been thinking about modifying the proportional approach to support absolute limits. This might not work, but I think this is an interesting idea to think about.
Here are my thoughts on it so far. We start with the patches that Vivek has sent, and change the notion of weights to percent. That is, the user space specifies percents of disk times instead of weights. We do not put entities in idle tree; whenever an entity is not backlogged, we still keep them in the active trees, and allocate them time slices. But since they have not requests in them, no requests will get dispatched during the time slices allocated to these entities. Moreover, if the percents of all entities do not add upto hundred, we introduce a dummy entity at each level to soak up the rest of "percent". This dummy entity would get time slices just like any other entity, but will not dispatch any requests. With these modification, we can limit entities to their allocated percent of disk time.
We might want a situation in which we want to allow certain entities to exceed their "percent" of disk time, while others should be limited. In this case, we can extend the above mentioned approach by introducing a secondary active tree. All entities which are allowed to exceed their "percent" can be queued in the secondary tree, besides the primary tree. Whenever an idle (or dummy) entity gets a time slice, instead of idling the disk, an entity can be picked from the secondary tree.
The advantage of an approach like this is that it will be relatively smaller modification of the proposed proportional approach. Moreover, entities will be throttled by getting time slices less frequently, instead of being allowed to send a burst and then getting starved (like in ticket based approach). The downside is that this approach sounds unconventional and probably have not been tried in other domains either. Thoughts? opinions?
I will create patches based on the above idea in a few weeks.
Quoted 6 lines
I still have to look closely at your patchset anyway. I will do and give a feedback.
-Andrea
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 49 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>--- Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++ 1 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +35
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 +
Documentation/block/io-controller.txt line 45
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight.
What if we have partitions sda1, sda2 and sda3 instead of sda, sdb and sdc?
Quoted 9 lines
Documentation/block/io-controller.txt new file +9
-0+ +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't
Documentation/block/io-controller.txt line 64
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. +
References to BFQ, please. I can search them, but having them in the doc would be nice.
Quoted 4 lines
Documentation/block/io-controller.txt new file +4
-0+Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividing
Documentation/block/io-controller.txt line 78
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. +
Could you elaborate, when you say timeslices get smaller -
1. Are you referring to inability to use higher resolution time?
2. Loss of throughput due to timeslice degradation?
Documentation/block/io-controller.txt line 85
Quoted 7 lines
Documentation/block/io-controller.txt new file +7
-0+- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue.
I assume by sectors you mean the kernel sector size?
Quoted 14 lines
Documentation/block/io-controller.txt new file +14
-0+ + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. +
Documentation/block/io-controller.txt line 109
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). +
I assume there is one io_context per cgroup.
Documentation/block/io-controller.txt line 114
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.
That seem acceptable
Quoted 46 lines
Documentation/block/io-controller.txt new file +46
-0+ +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer.
Documentation/block/io-controller.txt line 170
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought.
What are the problems with the code?
Documentation/block/io-controller.txt line 171
Quoted 1 line
Documentation/block/io-controller.txt new file +1
-0+- Use of bio-cgroup patches.
I saw these posted as well
Documentation/block/io-controller.txt line 173
Quoted 2 lines
Documentation/block/io-controller.txt new file +2
-0+- Use of Nauman's per cgroup request descriptor patches. +
More details would be nice, I am not sure I understand
Quoted 9 lines
Documentation/block/io-controller.txt new file +9
-0+HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller.
Documentation/block/io-controller.txt line 192
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio +
What is the meaning of priorities? Which is higher, which is lower? What is the maximum? How does it impact b/w?
Quoted 33 lines
Documentation/block/io-controller.txt new file +29
-0+- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/sSignature · 1 line
1.6.0.1
Signature · 1 line
Balbir
Re: [PATCH 01/10] Documentation
Quoted 212 lines · Balbir Singh
Quoted 49 lines · Vivek Goyal
o Documentation for io-controller.
Signed-off-by Vivek Goyal <[email protected]>---
Documentation/block/io-controller.txt | 221 +++++++++++++++++++++++++++++++++1 files changed, 221 insertions(+), 0 deletions(-)create mode 100644
Documentation/block/io-controller.txtDocumentation/block/io-controller.txt new file +35
-0@@ -0,0 +1,221 @@ + IO Controller + ============= + +Overview +======== + +This patchset implements a proportional weight IO controller. That is one +can create cgroups and assign prio/weights to those cgroups and task group +will get access to disk proportionate to the weight of the group. + +These patches modify elevator layer and individual IO schedulers to do +IO control hence this io controller works only on block devices which use +one of the standard io schedulers can not be used with any xyz logical block +device. + +The assumption/thought behind modifying IO scheduler is that resource control +is needed only on leaf nodes where the actual contention for resources is +present and not on intertermediate logical block devices. + +Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 +Documentation/block/io-controller.txt line 45
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). + +So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight.What if we have partitions sda1, sda2 and sda3 instead of sda, sdb and sdc?
Quoted 9 lines
Documentation/block/io-controller.txt new file +9
-0+ +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don'tDocumentation/block/io-controller.txt line 64
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. +References to BFQ, please. I can search them, but having them in the doc would be nice.
Quoted 4 lines
Documentation/block/io-controller.txt new file +4
-0+Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividingDocumentation/block/io-controller.txt line 78
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. +Could you elaborate, when you say timeslices get smaller -
1. Are you referring to inability to use higher resolution time?
2. Loss of throughput due to timeslice degradation?Documentation/block/io-controller.txt line 85
Quoted 7 lines
Documentation/block/io-controller.txt new file +7
-0+- BFQ was designed to provide tighter bounds/delay w.r.t service provided + to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue.I assume by sectors you mean the kernel sector size?
Quoted 14 lines
Documentation/block/io-controller.txt new file +14
-0+ + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. +Documentation/block/io-controller.txt line 109
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). +I assume there is one
io_contextper cgroup.Documentation/block/io-controller.txt line 114
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.That seem acceptable
Quoted 46 lines
Documentation/block/io-controller.txt new file +46
-0+ +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer.Documentation/block/io-controller.txt line 170
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. + +TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought.What are the problems with the code?
Quoted 3 lines
Documentation/block/io-controller.txt line 171
Quoted 1 line
Documentation/block/io-controller.txt new file +1
-0+- Use of bio-cgroup patches.I saw these posted as well
I have refactored the bio-cgroup patches to work on top of this patch set, and keep track of async writes. But we have not been able to get proportional division for async writes. The problem seems to stem from the fact that pdflush is cgroup agnostic. Getting proportional IO scheduling to work might need work beyond block layer. Vivek has been able to do more testing with those patches, and can explain more.
Quoted 5 lines
Documentation/block/io-controller.txt line 173
Quoted 3 lines
Documentation/block/io-controller.txt new file +2
-0+- Use of Nauman's per cgroup request descriptor patches. +More details would be nice, I am not sure I understand
Right now, the block layer has a limit on request descriptors that can be allocated. Once that limit is reached, a process trying to get a request descriptor would be blocked. I wrote a patch in which I made the request descriptor limit per cgroup, i.e a process will only be blocked if request descriptors allocated to a give cgroup exceed a certain limit.
This patch set is already big and we are trying to be careful to include all the work we have done for solving the problem. So I was planning to hold onto that patch, and send it out for comments once the basic infrastructure gets some traction.
Quoted 61 lines
Quoted 10 lines
Documentation/block/io-controller.txt new file +9
-0+HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller.Documentation/block/io-controller.txt line 192
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2 + +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio +What is the meaning of priorities? Which is higher, which is lower? What is the maximum? How does it impact b/w?
Quoted 30 lines
Documentation/block/io-controller.txt new file +29
-1+- Create two same size files (say 512MB each) on same disk (file1, file2) and + launch two dd threads in different cgroup to read those files. Make sure + right io scheduler is being used for the block device where files are + present (the one you compiled in hierarchical mode). + + echo 1 > /proc/sys/vm/drop_caches + + dd if=/mnt/lv0/zerofile1 of=/dev/null & + echo $! > /cgroup/test1/tasks + cat /cgroup/test1/tasks + + dd if=/mnt/lv0/zerofile2 of=/dev/null & + echo $! > /cgroup/test2/tasks + cat /cgroup/test2/tasks + +- First dd should finish first. + +Some Test Results +================= +- Two dd in two cgroups with prio 0 and 4. Ran two "dd" in those cgroups. + +234179072 bytes (234 MB) copied, 10.1811 s, 23.0 MB/s +234179072 bytes (234 MB) copied, 12.6187 s, 18.6 MB/s + +- Three dd in three cgroups with prio 0, 4, 4. + +234179072 bytes (234 MB) copied, 13.7654 s, 17.0 MB/s +234179072 bytes (234 MB) copied, 19.476 s, 12.0 MB/s +234179072 bytes (234 MB) copied, 20.1858 s, 11.6 MB/s --Quoted 3 lines
1.6.0.1
--
Balbir
Quoted 37 lines · Vivek Goyal
Quoted 13 lines · Gui Jianfeng
Quoted 11 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Quoted 6 lines
Hi Vivek,
I did some tests on my *old* i386 box(with two concurrent dd running), and notice that IO Controller doesn't work fine in such situation. But it can work perfectly in my *new* x86 box. I dig into this problem, and i guess the major reason is that my *old* i386 box is too slow, it can't ensure two running ioqs are always backlogged.
Hi Gui,
Have you run top to see what's the percentage cpu usage. I suspect that cpu is not keeping up pace disk to enqueue enough requests. I think process might be blocked somewhere else so that it could not issue requests.
Quoted 4 lines
If that is the case, I happens to have a thought. when an ioq uses up it time slice, we don't expire it immediately. May be we can give a piece of bonus time for idling to wait new requests if this ioq's finish time and its ancestor's finish time are all much smaller than other entities in each corresponding service tree.
Have you tried it with "fairness" enabled? With "fairness" enabled, for sync queues I am waiting for one extra idle time slice "8ms" for queue to get backlogged again before I move to the next queue?
Quoted 5 lines
Otherwise try to increase the idle time length to higher value say "12ms" just to see if that has any impact.
Can you please also send me output of blkparse. It might give some idea how IO schedulers see IO pattern.
Hi Vivek,
Sorry for the late reply, I tried the "fairness" patch, it seems not working. I'v also tried to extend the idle value, not working either.
The blktrace output is attached. It seems that the high priority ioq is deleting from busy tree too often due to lacking of requests. My box is single CPU and CPU speed is a little slow. May be two concurrent dd is contending CPU to submit requests, that's the reason for not always backlogged for ioqs.
Quoted 6 lines
Thanks
Vivek
Signature · 2 lines
Regards Gui Jianfeng
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Quoted 37 lines · Vivek Goyal
Quoted 13 lines · Gui Jianfeng
Quoted 11 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Quoted 6 lines
Hi Vivek,
I did some tests on my *old* i386 box(with two concurrent dd running), and notice that IO Controller doesn't work fine in such situation. But it can work perfectly in my *new* x86 box. I dig into this problem, and i guess the major reason is that my *old* i386 box is too slow, it can't ensure two running ioqs are always backlogged.
Hi Gui,
Have you run top to see what's the percentage cpu usage. I suspect that cpu is not keeping up pace disk to enqueue enough requests. I think process might be blocked somewhere else so that it could not issue requests.
Quoted 4 lines
If that is the case, I happens to have a thought. when an ioq uses up it time slice, we don't expire it immediately. May be we can give a piece of bonus time for idling to wait new requests if this ioq's finish time and its ancestor's finish time are all much smaller than other entities in each corresponding service tree.
Have you tried it with "fairness" enabled? With "fairness" enabled, for sync queues I am waiting for one extra idle time slice "8ms" for queue to get backlogged again before I move to the next queue?
Quoted 5 lines
Otherwise try to increase the idle time length to higher value say "12ms" just to see if that has any impact.
Can you please also send me output of blkparse. It might give some idea how IO schedulers see IO pattern.
Hi Vivek,
Sorry for the late reply, I tried the "fairness" patch, it seems not working. I'v also tried to extend the idle value, not working either.
The blktrace output is attached. It seems that the high priority ioq is deleting from busy tree too often due to lacking of requests. My box is single CPU and CPU speed is a little slow. May be two concurrent dd is contending CPU to submit requests, that's the reason for not always backlogged for ioqs.
Quoted 6 lines
Thanks
Vivek
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 20 lines · Balbir Singh
Quoted 18 lines · Vivek Goyal
Documentation/block/io-controller.txt new file +18
-0+ + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). +
Quoted 8 lines
Documentation/block/io-controller.txt line 45
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight.What if we have partitions sda1, sda2 and sda3 instead of sda, sdb and sdc?
The bandwidth controlling is device basis, so with sda1, sda2 and sda3 instead, they will contending on sda.
Quoted 139 lines
Quoted 10 lines
Documentation/block/io-controller.txt new file +9
-0+ +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don'tDocumentation/block/io-controller.txt line 64
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. +References to BFQ, please. I can search them, but having them in the doc would be nice.
Quoted 4 lines
Documentation/block/io-controller.txt new file +4
-0+Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividingDocumentation/block/io-controller.txt line 78
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. +Could you elaborate, when you say timeslices get smaller -
1. Are you referring to inability to use higher resolution time?
2. Loss of throughput due to timeslice degradation?Documentation/block/io-controller.txt line 85
Quoted 7 lines
+- BFQ was designed to provide tighter bounds/delay w.r.t service provided
Documentation/block/io-controller.txt new file +6
-0+ to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue.I assume by sectors you mean the kernel sector size?
Quoted 14 lines
Documentation/block/io-controller.txt new file +14
-0+ + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. +Documentation/block/io-controller.txt line 109
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). +I assume there is one
io_contextper cgroup.Documentation/block/io-controller.txt line 114
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.That seem acceptable
Quoted 50 lines
Documentation/block/io-controller.txt new file +50
-0+ +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. +
Quoted 8 lines
Documentation/block/io-controller.txt line 170
Quoted 6 lines
Documentation/block/io-controller.txt new file +6
-0+TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought.What are the problems with the code?
Anticipatory has its own idling logic, so what is the concerning here is how to make as work together with commom layer.
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to Balbir SinghQuoted 20 lines · Balbir Singh
Quoted 18 lines · Vivek Goyal
Documentation/block/io-controller.txt new file +18
-0+ + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). +
Quoted 8 lines
Documentation/block/io-controller.txt line 45
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight.What if we have partitions sda1, sda2 and sda3 instead of sda, sdb and sdc?
The bandwidth controlling is device basis, so with sda1, sda2 and sda3 instead, they will contending on sda.
Quoted 139 lines
Quoted 10 lines
Documentation/block/io-controller.txt new file +9
-0+ +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don'tDocumentation/block/io-controller.txt line 64
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design +====== +This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. +References to BFQ, please. I can search them, but having them in the doc would be nice.
Quoted 4 lines
Documentation/block/io-controller.txt new file +4
-0+Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividingDocumentation/block/io-controller.txt line 78
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. +Could you elaborate, when you say timeslices get smaller -
1. Are you referring to inability to use higher resolution time?
2. Loss of throughput due to timeslice degradation?Documentation/block/io-controller.txt line 85
Quoted 7 lines
+- BFQ was designed to provide tighter bounds/delay w.r.t service provided
Documentation/block/io-controller.txt new file +6
-0+ to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue.I assume by sectors you mean the kernel sector size?
Quoted 14 lines
Documentation/block/io-controller.txt new file +14
-0+ + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. +Documentation/block/io-controller.txt line 109
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq). + +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). +I assume there is one
io_contextper cgroup.Documentation/block/io-controller.txt line 114
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.That seem acceptable
Quoted 50 lines
Documentation/block/io-controller.txt new file +50
-0+ +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. +
Quoted 8 lines
Documentation/block/io-controller.txt line 170
Quoted 6 lines
Documentation/block/io-controller.txt new file +6
-0+TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought.What are the problems with the code?
Anticipatory has its own idling logic, so what is the concerning here is how to make as work together with commom layer.
Signature · 2 lines
Regards Gui Jianfeng
Quoted 42 lines · Gui Jianfeng
Quoted 35 lines · Vivek Goyal
Quoted 13 lines · Gui Jianfeng
Quoted 11 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
http://lkml.org/lkml/2008/11/6/227
One of the takeaway from the discussion in this thread was that let us implement a common layer which contains the proportional weight scheduling code which can be shared by all the IO schedulers.
Quoted 6 lines
Hi Vivek,
I did some tests on my *old* i386 box(with two concurrent dd running), and notice that IO Controller doesn't work fine in such situation. But it can work perfectly in my *new* x86 box. I dig into this problem, and i guess the major reason is that my *old* i386 box is too slow, it can't ensure two running ioqs are always backlogged.
Hi Gui,
Have you run top to see what's the percentage cpu usage. I suspect that cpu is not keeping up pace disk to enqueue enough requests. I think process might be blocked somewhere else so that it could not issue requests.
Quoted 4 lines
If that is the case, I happens to have a thought. when an ioq uses up it time slice, we don't expire it immediately. May be we can give a piece of bonus time for idling to wait new requests if this ioq's finish time and its ancestor's finish time are all much smaller than other entities in each corresponding service tree.
Have you tried it with "fairness" enabled? With "fairness" enabled, for sync queues I am waiting for one extra idle time slice "8ms" for queue to get backlogged again before I move to the next queue?
Quoted 5 lines
Otherwise try to increase the idle time length to higher value say "12ms" just to see if that has any impact.
Can you please also send me output of blkparse. It might give some idea how IO schedulers see IO pattern.
Quoted 8 lines
Hi Vivek,
Sorry for the late reply, I tried the "fairness" patch, it seems not working. I'v also tried to extend the idle value, not working either.
The blktrace output is attached. It seems that the high priority ioq is deleting from busy tree too often due to lacking of requests. My box is single CPU and CPU speed is a little slow. May be two concurrent dd is contending CPU to submit requests, that's the reason for not always backlogged for ioqs.
Hi Vivek,
Sorry for bothering, there were some configure errors when i tested, and got the improper result.
The "fairness" patch seems to work fine now! It makes the high priority ioq *always* backlogged :)
Quoted 7 lines
Quoted 6 lines
Thanks
Vivek
Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to Andrea RighiQuoted 15 lines · Andrea Righi
Quoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Quoted 7 lines
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Thanks Andrea. I will spend more time in looking through your patches and do a bit of testing.
Quoted 6 lines
Quoted 6 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
Quoted 9 lines
Quoted 3 lines
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Please do have a look at this patchset and would you do it differently to implement proportional weight control?
Few thoughts/queries.
- Max bandwidth control and Prportional weight control are two entirely different ways of controlling the IO. Former one tries to put an upper limit on the IO rate and later one kind of tries to gurantee minmum percentage share of disk.
How does an determine what throughput rate you will get from a disk? That is so much dependent on workload and miscalculations can lead to getting lower BW for a particular cgroup?
I am assuming that one can probably do some random read-write IO test to try to get some idea of disk throughput. If that's the case, then in proportional weight control also you should be able to predict the minimum BW a cgroup will be getting? The only difference will be that a cgroup can get higher BW also if there is no contention present and I am wondring that how getting more BW than promised minumum is harmful?
- I can think of atleast one usage of uppper limit controller where we might have spare IO resources still we don't want to give it to a cgroup because customer has not paid for that kind of service level. In those cases we need to implement uppper limit also.
May be prportional weight and max bw controller can co-exist depending on what user's requirements are.
If yes, then can't this control be done at the same layer/level where proportional weight control is being done? IOW, this set of patches is trying to do prportional weight control at IO scheduler level. I think we should be able to store another max rate as another feature in cgroup (apart from weight) and not dispatch requests from the queue if we have exceeded the max BW as specified by the user?
- Have you thought of doing hierarchical control?
- What happens to the notion of CFQ task classes and task priority. Looks like max bw rule supercede everything. There is no way that an RT task get unlimited amount of disk BW even if it wants to? (There is no notion of RT cgroup etc)
Quoted 19 lines
Quoted 8 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
Quoted 6 lines
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Yes, I meant LVM, Software RAID etc. So if I have got many disks in the system and I have created software raid on some of them, I need to create rules for lvm devices or physical devices behind those lvm devices? I am assuming that it will be logical devices.
So I need to know exactly to what all devices applications in a particular cgroup is going to do IO, and also know exactly how many cgroups are contending for that cgroup, and also know what worst case disk rate I can expect from that device and then I can do a good job of giving a reasonable value to the max rate of that cgroup on a particular device?
Quoted 19 lines
Quoted 6 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Quoted 5 lines
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time.
Can you please give little more details here regarding how QoS requirements are not met with proportional weight?
Quoted 5 lines
So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.I still have to look closely at your patchset anyway. I will do and give a feedback.
You feedback is always welcome.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 46 lines · Vivek Goyal
Quoted 15 lines · Andrea Righi
Quoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Quoted 7 lines
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Thanks Andrea. I will spend more time in looking through your patches and do a bit of testing.
Quoted 6 lines
Quoted 6 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
Quoted 9 lines
Quoted 3 lines
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Please do have a look at this patchset and would you do it differently to implement proportional weight control?
Quoted 6 lines
Few thoughts/queries.
- Max bandwidth control and Prportional weight control are two entirely different ways of controlling the IO. Former one tries to put an upper limit on the IO rate and later one kind of tries to gurantee minmum percentage share of disk.
Agree.
Quoted 11 lines
How does an determine what throughput rate you will get from a disk? That is so much dependent on workload and miscalculations can lead to getting lower BW for a particular cgroup?
I am assuming that one can probably do some random read-write IO test to try to get some idea of disk throughput. If that's the case, then in proportional weight control also you should be able to predict the minimum BW a cgroup will be getting? The only difference will be that a cgroup can get higher BW also if there is no contention present and I am wondring that how getting more BW than promised minumum is harmful?
IMHO we shouldn't care too much on how to extract the exact BW from a disk. With proportional weights we can directly map different levels of service to different weights.
With absolute limiting we can measure the consumed BW post facto and try to do the best to satisfy the limits defined by the user (absolute max, min or proportional). Predict a priori how much BW will consume a particular application's workload is a very hard task (maybe even impossible) and probably it doesn't give huge advantages respect to the approach we're currently using. I think this is true for both solutions.
Quoted 9 lines
- I can think of atleast one usage of uppper limit controller where we might have spare IO resources still we don't want to give it to a cgroup because customer has not paid for that kind of service level. In those cases we need to implement uppper limit also.
May be prportional weight and max bw controller can co-exist depending on what user's requirements are.
Quoted 6 lines
If yes, then can't this control be done at the same layer/level where proportional weight control is being done? IOW, this set of patches is trying to do prportional weight control at IO scheduler level. I think we should be able to store another max rate as another feature in cgroup (apart from weight) and not dispatch requests from the queue if we have exceeded the max BW as specified by the user?
The more I think about a "perfect" solution (at least for my requirements), the more I'm convinced that we need both functionalities.
I think it would be possible to implement both proportional and limiting rules at the same level (e.g., the IO scheduler), but we need also to address the memory consumption problem (I still need to review your patchset in details and I'm going to test it soon :), so I don't know if you already addressed this issue).
IOW if we simply don't dispatch requests and we don't throttle the tasks in the cgroup that exceeds its limit, how do we avoid the waste of memory due to the succeeding IO requests and the increasingly dirty pages in the page cache (that are also hard to reclaim)? I may be wrong, but I think we talked about this problem in a previous email... sorry I don't find the discussion in my mail archives.
IMHO a nice approach would be to measure IO consumption at the IO scheduler level, and control IO applying proportional weights / absolute limits _both_ at the IO scheduler / elevator level _and_ at the same time block the tasks from dirtying memory that will generate additional IO requests.
Anyway, there's no need to provide this with a single IO controller, we could split the problem in two parts: 1) provide a proportional / absolute IO controller in the IO schedulers and 2) allow to set, for example, a maximum limit of dirty pages for each cgroup.
Maybe I'm just repeating what we already said in a previous discussion... in this case sorry for the duplicate thoughts. :)
Quoted 3 lines
- Have you thought of doing hierarchical control?
Providing hiearchies in cgroups is in general expensive, deeper hierarchies imply checking all the way up to the root cgroup, so I think we need to be very careful and be aware of the trade-offs before providing such feature. For this particular case (IO controller) wouldn't it be simpler and more efficient to just ignore hierarchies in the kernel and opportunely handle them in userspace? for absolute limiting rules this isn't difficult at all, just imagine a config file and a script or a deamon that dynamically create the opportune cgroups and configure them accordingly to what is defined in the configuration file.
I think we can simply define hierarchical dependencies in the configuration file, translate them in absolute values and use the absolute values to configure the cgroups' properties.
For example, we can just check that the BW allocated for a particular parent cgroup is not greater than the total BW allocated for the children. And for each child just use the min(parent_BW, BW) or equally divide the parent's BW among the children, etc.
Quoted 4 lines
- What happens to the notion of CFQ task classes and task priority. Looks like max bw rule supercede everything. There is no way that an RT task get unlimited amount of disk BW even if it wants to? (There is no notion of RT cgroup etc)
What about moving all the RT tasks in a separate cgroup with unlimited BW?
Quoted 32 lines
Quoted 20 lines
Quoted 9 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
Quoted 6 lines
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Yes, I meant LVM, Software RAID etc. So if I have got many disks in the system and I have created software raid on some of them, I need to create rules for lvm devices or physical devices behind those lvm devices? I am assuming that it will be logical devices.
Quoted 5 lines
So I need to know exactly to what all devices applications in a particular cgroup is going to do IO, and also know exactly how many cgroups are contending for that cgroup, and also know what worst case disk rate I can expect from that device and then I can do a good job of giving a reasonable value to the max rate of that cgroup on a particular device?
ok, I understand. For these cases dm-ioband perfectly addresses the problem. For the general case, I think the only solution is to provide a common interface that each dm subsystem must call to account IO and apply limiting and proportional rules.
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Quoted 8 lines
Quoted 5 lines
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time.
Can you please give little more details here regarding how QoS requirements are not met with proportional weight?
With proportional weights the whole bandwidth is allocated if no one else is using it. When IO is submitted other tasks with a higher weight can be forced to sleep until the IO generated by the low weight tasks is not completely dispatched. Or any extent of the priority inversion problems.
Maybe it's not an issue at all for the most part of the cases, but using a solution that is able to provide also a real partitioning of the available resources can be profitely used by those who need to guarantee _strict_ BW requirements (soft real-time, maximize the responsiveness of certain services, etc.), because in this case we're sure that a certain amount of "spare" BW will be always available when needed by some "critical" services.
Quoted 11 lines
Quoted 6 lines
So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.I still have to look closely at your patchset anyway. I will do and give a feedback.
You feedback is always welcome.
Thanks
Vivek
Thanks,
-Andrea
Re: [PATCH 01/10] Documentation
In reply to Vivek GoyalQuoted 46 lines · Vivek Goyal
Quoted 15 lines · Andrea Righi
Quoted 2 lines · Vivek Goyal
Quoted 1 line · Andrew Morton
On Wed, 11 Mar 2009 21:56:46 -0400 Vivek Goyal <[email protected]> wrote:
[snip]
Quoted 10 lines
Quoted 7 lines
Also.. there are so many IO controller implementations that I've lost track of who is doing what. I do have one private report here that Andreas's controller "is incredibly productive for us and has allowed us to put twice as many users per server with faster times for all users". Which is pretty stunning, although it should be viewed as a condemnation of the current code, I'm afraid.
I had looked briefly at Andrea's implementation in the past. I will look again. I had thought that this approach did not get much traction.
Quoted 7 lines
Hi Vivek, sorry for my late reply. I periodically upload the latest versions of io-throttle here if you're still interested:
http://download.systemimager.org/~arighi/linux/patches/io-throttle/There's no consistent changes respect to the latest version I posted to the LKML, just rebasing to the recent kernels.
Thanks Andrea. I will spend more time in looking through your patches and do a bit of testing.
Quoted 6 lines
Quoted 6 lines
Some quick thoughts about this approach though.
- It is not a proportional weight controller. It is more of limiting bandwidth in absolute numbers for each cgroup on each disk.
Quoted 9 lines
Quoted 3 lines
So each cgroup will define a rule for each disk in the system mentioning at what maximum rate that cgroup can issue IO to that disk and throttle the IO from that cgroup if rate has excedded.
Correct. Add also the proportional weight control has been in the TODO list since the early versions, but I never dedicated too much effort to implement this feature, I can focus on this and try to write something if we all think it is worth to be done.
Please do have a look at this patchset and would you do it differently to implement proportional weight control?
Quoted 6 lines
Few thoughts/queries.
- Max bandwidth control and Prportional weight control are two entirely different ways of controlling the IO. Former one tries to put an upper limit on the IO rate and later one kind of tries to gurantee minmum percentage share of disk.
Agree.
Quoted 11 lines
How does an determine what throughput rate you will get from a disk? That is so much dependent on workload and miscalculations can lead to getting lower BW for a particular cgroup?
I am assuming that one can probably do some random read-write IO test to try to get some idea of disk throughput. If that's the case, then in proportional weight control also you should be able to predict the minimum BW a cgroup will be getting? The only difference will be that a cgroup can get higher BW also if there is no contention present and I am wondring that how getting more BW than promised minumum is harmful?
IMHO we shouldn't care too much on how to extract the exact BW from a disk. With proportional weights we can directly map different levels of service to different weights.
With absolute limiting we can measure the consumed BW post facto and try to do the best to satisfy the limits defined by the user (absolute max, min or proportional). Predict a priori how much BW will consume a particular application's workload is a very hard task (maybe even impossible) and probably it doesn't give huge advantages respect to the approach we're currently using. I think this is true for both solutions.
Quoted 9 lines
- I can think of atleast one usage of uppper limit controller where we might have spare IO resources still we don't want to give it to a cgroup because customer has not paid for that kind of service level. In those cases we need to implement uppper limit also.
May be prportional weight and max bw controller can co-exist depending on what user's requirements are.
Quoted 6 lines
If yes, then can't this control be done at the same layer/level where proportional weight control is being done? IOW, this set of patches is trying to do prportional weight control at IO scheduler level. I think we should be able to store another max rate as another feature in cgroup (apart from weight) and not dispatch requests from the queue if we have exceeded the max BW as specified by the user?
The more I think about a "perfect" solution (at least for my requirements), the more I'm convinced that we need both functionalities.
I think it would be possible to implement both proportional and limiting rules at the same level (e.g., the IO scheduler), but we need also to address the memory consumption problem (I still need to review your patchset in details and I'm going to test it soon :), so I don't know if you already addressed this issue).
IOW if we simply don't dispatch requests and we don't throttle the tasks in the cgroup that exceeds its limit, how do we avoid the waste of memory due to the succeeding IO requests and the increasingly dirty pages in the page cache (that are also hard to reclaim)? I may be wrong, but I think we talked about this problem in a previous email... sorry I don't find the discussion in my mail archives.
IMHO a nice approach would be to measure IO consumption at the IO scheduler level, and control IO applying proportional weights / absolute limits _both_ at the IO scheduler / elevator level _and_ at the same time block the tasks from dirtying memory that will generate additional IO requests.
Anyway, there's no need to provide this with a single IO controller, we could split the problem in two parts: 1) provide a proportional / absolute IO controller in the IO schedulers and 2) allow to set, for example, a maximum limit of dirty pages for each cgroup.
Maybe I'm just repeating what we already said in a previous discussion... in this case sorry for the duplicate thoughts. :)
Quoted 3 lines
- Have you thought of doing hierarchical control?
Providing hiearchies in cgroups is in general expensive, deeper hierarchies imply checking all the way up to the root cgroup, so I think we need to be very careful and be aware of the trade-offs before providing such feature. For this particular case (IO controller) wouldn't it be simpler and more efficient to just ignore hierarchies in the kernel and opportunely handle them in userspace? for absolute limiting rules this isn't difficult at all, just imagine a config file and a script or a deamon that dynamically create the opportune cgroups and configure them accordingly to what is defined in the configuration file.
I think we can simply define hierarchical dependencies in the configuration file, translate them in absolute values and use the absolute values to configure the cgroups' properties.
For example, we can just check that the BW allocated for a particular parent cgroup is not greater than the total BW allocated for the children. And for each child just use the min(parent_BW, BW) or equally divide the parent's BW among the children, etc.
Quoted 4 lines
- What happens to the notion of CFQ task classes and task priority. Looks like max bw rule supercede everything. There is no way that an RT task get unlimited amount of disk BW even if it wants to? (There is no notion of RT cgroup etc)
What about moving all the RT tasks in a separate cgroup with unlimited BW?
Quoted 32 lines
Quoted 20 lines
Quoted 9 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
Quoted 6 lines
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Yes, I meant LVM, Software RAID etc. So if I have got many disks in the system and I have created software raid on some of them, I need to create rules for lvm devices or physical devices behind those lvm devices? I am assuming that it will be logical devices.
Quoted 5 lines
So I need to know exactly to what all devices applications in a particular cgroup is going to do IO, and also know exactly how many cgroups are contending for that cgroup, and also know what worst case disk rate I can expect from that device and then I can do a good job of giving a reasonable value to the max rate of that cgroup on a particular device?
ok, I understand. For these cases dm-ioband perfectly addresses the problem. For the general case, I think the only solution is to provide a common interface that each dm subsystem must call to account IO and apply limiting and proportional rules.
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Quoted 8 lines
Quoted 5 lines
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time.
Can you please give little more details here regarding how QoS requirements are not met with proportional weight?
With proportional weights the whole bandwidth is allocated if no one else is using it. When IO is submitted other tasks with a higher weight can be forced to sleep until the IO generated by the low weight tasks is not completely dispatched. Or any extent of the priority inversion problems.
Maybe it's not an issue at all for the most part of the cases, but using a solution that is able to provide also a real partitioning of the available resources can be profitely used by those who need to guarantee _strict_ BW requirements (soft real-time, maximize the responsiveness of certain services, etc.), because in this case we're sure that a certain amount of "spare" BW will be always available when needed by some "critical" services.
Quoted 11 lines
Quoted 6 lines
So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.I still have to look closely at your patchset anyway. I will do and give a feedback.
You feedback is always welcome.
Thanks
Vivek
Thanks,
-Andrea
Quoted 4 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
Hi Vivek,
I got the following OOPS when testing, can't reproduce again :(
kernel BUG at block/elevator-fq.c:1396!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/block/hdb/queue/scheduler
Modules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbd
Pid: 5032, comm: rmdir Not tainted (2.6.29-rc7-vivek #17) Veriton M460
EIP: 0060:[<c04ec7de>] EFLAGS: 00010082 CPU: 0
EIP is at iocg_destroy+0xdc/0x14e
EAX: 00000000 EBX: f62278b4 ECX: f6207800 EDX: f6227904
ESI: f6227800 EDI: f62278a0 EBP: 00000003 ESP: c8790f00
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmdir (pid: 5032, ti=c8790000 task=f6636960 task.ti=c8790000)
Stack: f53cc5c0 f62b7258 f10991c8 00000282 f6227800 c0733fa0 ec1c5140 edfc6d34 c8790000 c04463ce f6a4c84c edfc6d34 0804c840 c048883c f6a4c84c f6a4c84c c04888d6 f6a4c84c 00000000 c04897de f6a4c84c c048504c f115f4c0 ebc37954 Call Trace: [<c04463ce>] cgroup_diput+0x41/0x8c [<c048883c>] dentry_iput+0x45/0x5e [<c04888d6>] d_kill+0x19/0x32 [<c04897de>] dput+0xd8/0xdf [<c048504c>] do_rmdir+0x8f/0xb6 [<c06330fc>] do_page_fault+0x2a2/0x579 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x641/0x830 Code: 08 00 74 04 0f 0b eb fe 83 7f 04 00 74 04 0f 0b eb fe 45 83 c3 1c 83 fd 0 EIP: [<c04ec7de>] iocg_destroy+0xdc/0x14e SS:ESP 0068:c8790f00
Signature · 2 lines
Regards Gui Jianfeng
Quoted 4 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
Hi Vivek,
I got the following OOPS when testing, can't reproduce again :(
kernel BUG at block/elevator-fq.c:1396!
invalid opcode: 0000 [#1] SMP
last sysfs file: /sys/block/hdb/queue/scheduler
Modules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbd
Pid: 5032, comm: rmdir Not tainted (2.6.29-rc7-vivek #17) Veriton M460
EIP: 0060:[<c04ec7de>] EFLAGS: 00010082 CPU: 0
EIP is at iocg_destroy+0xdc/0x14e
EAX: 00000000 EBX: f62278b4 ECX: f6207800 EDX: f6227904
ESI: f6227800 EDI: f62278a0 EBP: 00000003 ESP: c8790f00
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmdir (pid: 5032, ti=c8790000 task=f6636960 task.ti=c8790000)
Stack: f53cc5c0 f62b7258 f10991c8 00000282 f6227800 c0733fa0 ec1c5140 edfc6d34 c8790000 c04463ce f6a4c84c edfc6d34 0804c840 c048883c f6a4c84c f6a4c84c c04888d6 f6a4c84c 00000000 c04897de f6a4c84c c048504c f115f4c0 ebc37954 Call Trace: [<c04463ce>] cgroup_diput+0x41/0x8c [<c048883c>] dentry_iput+0x45/0x5e [<c04888d6>] d_kill+0x19/0x32 [<c04897de>] dput+0xd8/0xdf [<c048504c>] do_rmdir+0x8f/0xb6 [<c06330fc>] do_page_fault+0x2a2/0x579 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x641/0x830 Code: 08 00 74 04 0f 0b eb fe 83 7f 04 00 74 04 0f 0b eb fe 45 83 c3 1c 83 fd 0 EIP: [<c04ec7de>] iocg_destroy+0xdc/0x14e SS:ESP 0068:c8790f00
Signature · 2 lines
Regards Gui Jianfeng
Quoted 21 lines · Gui Jianfeng
Quoted 4 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
Hi Vivek,
I got the following OOPS when testing, can't reproduce again :(
kernel BUG at
block/elevator-fq.c:1396!
invalid opcode: 0000 [#1] SMP
last sysfs file:/sys/block/hdb/queue/schedulerModules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbdPid: 5032, comm: rmdir Not tainted (2.6.29-rc7-vivek #17) Veriton M460
EIP: 0060:[<c04ec7de>] EFLAGS: 00010082 CPU: 0
EIP is atiocg_destroy+0xdc/0x14e
EAX: 00000000 EBX:f62278b4ECX:f6207800EDX:f6227904
ESI:f6227800EDI:f62278a0EBP: 00000003 ESP:c8790f00
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmdir (pid: 5032, ti=c8790000 task=f6636960 task.ti=c8790000)
Quoted 15 lines
Stack: f53cc5c0 f62b7258 f10991c8 00000282 f6227800 c0733fa0 ec1c5140 edfc6d34 c8790000 c04463ce f6a4c84c edfc6d34 0804c840 c048883c f6a4c84c f6a4c84c c04888d6 f6a4c84c 00000000 c04897de f6a4c84c c048504c f115f4c0 ebc37954 Call Trace: [<c04463ce>] cgroup_diput+0x41/0x8c [<c048883c>] dentry_iput+0x45/0x5e [<c04888d6>] d_kill+0x19/0x32 [<c04897de>] dput+0xd8/0xdf [<c048504c>] do_rmdir+0x8f/0xb6 [<c06330fc>] do_page_fault+0x2a2/0x579 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x641/0x830 Code: 08 00 74 04 0f 0b eb fe 83 7f 04 00 74 04 0f 0b eb fe 45 83 c3 1c 83 fd 0 EIP: [<c04ec7de>] iocg_destroy+0xdc/0x14e SS:ESP 0068:c8790f00
We have seen this too. And have been able to reproduce it. I did not get a chance to fix it so far, but my understanding is that one of the async queues was active when the cgroup was getting destroyed. We moved it to root cgroup, but did not deactivate it; so active_entity still points to the entity of the async queue which has now been moved to the root cgroup. I will send an update if I can verify this, or fix it.
Quoted 6 lines
--
Regards
Gui Jianfeng
Quoted 21 lines · Gui Jianfeng
Quoted 4 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
Hi Vivek,
I got the following OOPS when testing, can't reproduce again :(
kernel BUG at
block/elevator-fq.c:1396!
invalid opcode: 0000 [#1] SMP
last sysfs file:/sys/block/hdb/queue/schedulerModules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbdPid: 5032, comm: rmdir Not tainted (2.6.29-rc7-vivek #17) Veriton M460
EIP: 0060:[<c04ec7de>] EFLAGS: 00010082 CPU: 0
EIP is atiocg_destroy+0xdc/0x14e
EAX: 00000000 EBX:f62278b4ECX:f6207800EDX:f6227904
ESI:f6227800EDI:f62278a0EBP: 00000003 ESP:c8790f00
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmdir (pid: 5032, ti=c8790000 task=f6636960 task.ti=c8790000)
Quoted 15 lines
Stack: f53cc5c0 f62b7258 f10991c8 00000282 f6227800 c0733fa0 ec1c5140 edfc6d34 c8790000 c04463ce f6a4c84c edfc6d34 0804c840 c048883c f6a4c84c f6a4c84c c04888d6 f6a4c84c 00000000 c04897de f6a4c84c c048504c f115f4c0 ebc37954 Call Trace: [<c04463ce>] cgroup_diput+0x41/0x8c [<c048883c>] dentry_iput+0x45/0x5e [<c04888d6>] d_kill+0x19/0x32 [<c04897de>] dput+0xd8/0xdf [<c048504c>] do_rmdir+0x8f/0xb6 [<c06330fc>] do_page_fault+0x2a2/0x579 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x641/0x830 Code: 08 00 74 04 0f 0b eb fe 83 7f 04 00 74 04 0f 0b eb fe 45 83 c3 1c 83 fd 0 EIP: [<c04ec7de>] iocg_destroy+0xdc/0x14e SS:ESP 0068:c8790f00
We have seen this too. And have been able to reproduce it. I did not get a chance to fix it so far, but my understanding is that one of the async queues was active when the cgroup was getting destroyed. We moved it to root cgroup, but did not deactivate it; so active_entity still points to the entity of the async queue which has now been moved to the root cgroup. I will send an update if I can verify this, or fix it.
Quoted 6 lines
--
Regards
Gui Jianfeng
Quoted 10 lines · Gui Jianfeng
Quoted 4 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
Hi Vivek,
I got the following OOPS when testing, can't reproduce again :(
Hi Gui,
Thanks for the report. Will look into it and see if I can reproduce it.
Thanks
Vivek
Quoted 30 lines
kernel BUG at
block/elevator-fq.c:1396!
invalid opcode: 0000 [#1] SMP
last sysfs file:/sys/block/hdb/queue/schedulerModules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbdPid: 5032, comm: rmdir Not tainted (2.6.29-rc7-vivek #17) Veriton M460
EIP: 0060:[<c04ec7de>] EFLAGS: 00010082 CPU: 0
EIP is atiocg_destroy+0xdc/0x14e
EAX: 00000000 EBX:f62278b4ECX:f6207800EDX:f6227904
ESI:f6227800EDI:f62278a0EBP: 00000003 ESP:c8790f00
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmdir (pid: 5032, ti=c8790000 task=f6636960 task.ti=c8790000)Stack: f53cc5c0 f62b7258 f10991c8 00000282 f6227800 c0733fa0 ec1c5140 edfc6d34 c8790000 c04463ce f6a4c84c edfc6d34 0804c840 c048883c f6a4c84c f6a4c84c c04888d6 f6a4c84c 00000000 c04897de f6a4c84c c048504c f115f4c0 ebc37954 Call Trace: [<c04463ce>] cgroup_diput+0x41/0x8c [<c048883c>] dentry_iput+0x45/0x5e [<c04888d6>] d_kill+0x19/0x32 [<c04897de>] dput+0xd8/0xdf [<c048504c>] do_rmdir+0x8f/0xb6 [<c06330fc>] do_page_fault+0x2a2/0x579 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x641/0x830 Code: 08 00 74 04 0f 0b eb fe 83 7f 04 00 74 04 0f 0b eb fe 45 83 c3 1c 83 fd 0 EIP: [<c04ec7de>] iocg_destroy+0xdc/0x14e SS:ESP 0068:c8790f00Signature · 2 lines
Regards Gui Jianfeng
Quoted 10 lines · Gui Jianfeng
Quoted 4 lines · Vivek Goyal
Hi All,
Here is another posting for IO controller patches. Last time I had posted RFC patches for an IO controller which did bio control per cgroup.
Hi Vivek,
I got the following OOPS when testing, can't reproduce again :(
Hi Gui,
Thanks for the report. Will look into it and see if I can reproduce it.
Thanks
Vivek
Quoted 30 lines
kernel BUG at
block/elevator-fq.c:1396!
invalid opcode: 0000 [#1] SMP
last sysfs file:/sys/block/hdb/queue/schedulerModules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbdPid: 5032, comm: rmdir Not tainted (2.6.29-rc7-vivek #17) Veriton M460
EIP: 0060:[<c04ec7de>] EFLAGS: 00010082 CPU: 0
EIP is atiocg_destroy+0xdc/0x14e
EAX: 00000000 EBX:f62278b4ECX:f6207800EDX:f6227904
ESI:f6227800EDI:f62278a0EBP: 00000003 ESP:c8790f00
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process rmdir (pid: 5032, ti=c8790000 task=f6636960 task.ti=c8790000)Stack: f53cc5c0 f62b7258 f10991c8 00000282 f6227800 c0733fa0 ec1c5140 edfc6d34 c8790000 c04463ce f6a4c84c edfc6d34 0804c840 c048883c f6a4c84c f6a4c84c c04888d6 f6a4c84c 00000000 c04897de f6a4c84c c048504c f115f4c0 ebc37954 Call Trace: [<c04463ce>] cgroup_diput+0x41/0x8c [<c048883c>] dentry_iput+0x45/0x5e [<c04888d6>] d_kill+0x19/0x32 [<c04897de>] dput+0xd8/0xdf [<c048504c>] do_rmdir+0x8f/0xb6 [<c06330fc>] do_page_fault+0x2a2/0x579 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x641/0x830 Code: 08 00 74 04 0f 0b eb fe 83 7f 04 00 74 04 0f 0b eb fe 45 83 c3 1c 83 fd 0 EIP: [<c04ec7de>] iocg_destroy+0xdc/0x14e SS:ESP 0068:c8790f00Signature · 2 lines
Regards Gui Jianfeng
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 2 lines · Balbir Singh
* Vivek Goyal <[email protected]> [2009-03-11 21:56:46]:
Thanks for having a look balbir. Sorry for the late reply..
[..]
Quoted 21 lines
Quoted 21 lines
Documentation/block/io-controller.txt new file +21
-0+Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). +
Quoted 8 lines
Documentation/block/io-controller.txt line 45
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight.What if we have partitions sda1, sda2 and sda3 instead of sda, sdb and sdc?
As Gui already mentioned, IO control is on per device basis (like IO scheduler) and we don't try to control it per partition basis.
Quoted 15 lines
Quoted 15 lines
Documentation/block/io-controller.txt new file +14
-0+ +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design
Quoted 8 lines
Documentation/block/io-controller.txt line 64
Quoted 5 lines
+======
Documentation/block/io-controller.txt new file +4
-0+This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. +References to BFQ, please. I can search them, but having them in the doc would be nice.
That's a good point. In next posting I will put references also.
Quoted 18 lines
Quoted 5 lines
Documentation/block/io-controller.txt new file +4
-0+Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividingDocumentation/block/io-controller.txt line 78
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. +Could you elaborate, when you say timeslices get smaller -
Quoted 2 lines
1. Are you referring to inability to use higher resolution time?
2. Loss of throughput due to timeslice degradation?
I think keeping a track of time using higher resolution time should not be a problem but it would be rather more of loss of throughput due to smaller timeslices and frequent queue switching.
Quoted 10 lines
Documentation/block/io-controller.txt line 85
Quoted 8 lines
+- BFQ was designed to provide tighter bounds/delay w.r.t service provided
Documentation/block/io-controller.txt new file +6
-0+ to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue.I assume by sectors you mean the kernel sector size?
Yes.
Quoted 19 lines
Quoted 19 lines
Documentation/block/io-controller.txt new file +18
-0+ + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq).
Quoted 8 lines
Documentation/block/io-controller.txt line 109
Quoted 6 lines
Documentation/block/io-controller.txt new file +6
-0+ +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). +I assume there is one
io_contextper cgroup.
No. There can be multiple io_context per cgroup because currently io_context is defined as threads which are doing IO sharing and are kept in one queue from IO point of view by cfq and multiple queues are not created. So there might be many processes/threads in a cgroup and not necessarily they are sharing the io_context.
Quoted 8 lines
Documentation/block/io-controller.txt line 114
Quoted 6 lines
Documentation/block/io-controller.txt new file +5
-0+A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.That seem acceptable
Andrew first wants to see a solid plan for handling async writes :-) So currently I am playing with patches to map writes to correct cgroup. Mapping the IO to right cgroup is only one part of the problem. Other part is that I am not seeing a continuious stream of writes at IO scheduler level. So if two dd processes are running in user space, ideally one can expect two continuous stream of write requests at IO scheduler but instead I see bursty serialized traffic. So a bunch of write request from first dd then another bunch of write requests from second dd and it goes on.. and this leads to no service differentiation between two writes because when higher priority task is not dispatching any IO (for .2 seconds), lower priority task/group gets to use full disk and soon catches up with higher priority one..
Part of this serialization was taking place at request descriptor allocation infrastructure where number of request descriptors are limited and if one writer first consumes most of the descriptors it will block/serialize other writer.
Now I have got a crude working patch where I can limit per group request descriptors so that one group can not block other group. But still don't see continuously backlogged write queues at IO scheduler...
Time to do more debugging and move up the layer and see where this serialization is taking place (i guess page cache...).
Quoted 51 lines
Quoted 51 lines
Documentation/block/io-controller.txt new file +50
-0+ +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. +
Quoted 8 lines
Documentation/block/io-controller.txt line 170
Quoted 6 lines
Documentation/block/io-controller.txt new file +6
-0+TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought.What are the problems with the code?
Have not got a chance to look into the issues in detail yet. Just a crude run saw drop in performance. Will debug it later the moment I have got async writes handled...
Quoted 8 lines
Quoted 1 line
+- Use of bio-cgroup patches.
I saw these posted as well
Quoted 2 lines
+- Use of Nauman's per cgroup request descriptor patches. +
More details would be nice, I am not sure I understand
Currently the number of request descriptors which can be allocated per device/request queue are fixed by a sysfs tunable (q->nr_requests). So if there is lots of IO going on from one cgroup then it will consume all the available request descriptors and other cgroup might starve and not get its fair share.
Hence we also need to introduce the notion of request descriptor limit per cgroup so that if request descriptors from one group are exhausted, then it does not impact the IO of other cgroup.
Quoted 15 lines
Quoted 15 lines
Documentation/block/io-controller.txt new file +14
-0+HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2
Quoted 8 lines
Documentation/block/io-controller.txt line 192
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+ +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio +What is the meaning of priorities? Which is higher, which is lower? What is the maximum? How does it impact b/w?
Currently cfq has notion of priority range 0-7 (0 being highest). To being with we simply adopted that notion though we are converting it to weights now for group.
Mapping from group priority to group weight is linear. So prio 0 group should get double the BW of prio 4 group.
Thanks
Vivek
Re: [PATCH 01/10] Documentation
In reply to Balbir SinghQuoted 2 lines · Balbir Singh
* Vivek Goyal <[email protected]> [2009-03-11 21:56:46]:
Thanks for having a look balbir. Sorry for the late reply..
[..]
Quoted 21 lines
Quoted 21 lines
Documentation/block/io-controller.txt new file +21
-0+Consider following hypothetical scenario. Lets say there are three physical +disks, namely sda, sdb and sdc. Two logical volumes (lv0 and lv1) have been +created on top of these. Some part of sdb is in lv0 and some part is in lv1. + + lv0 lv1 + / \ / \ + sda sdb sdc + +Also consider following cgroup hierarchy + + root + / \ + A B + / \ / \ + T1 T2 T3 T4 + +A and B are two cgroups and T1, T2, T3 and T4 are tasks with-in those cgroups. +Assuming T1, T2, T3 and T4 are doing IO on lv0 and lv1. These tasks should +get their fair share of bandwidth on disks sda, sdb and sdc. There is no +IO control on intermediate logical block nodes (lv0, lv1). +
Quoted 8 lines
Documentation/block/io-controller.txt line 45
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+So if tasks T1 and T2 are doing IO on lv0 and T3 and T4 are doing IO on lv1 +only, there will not be any contetion for resources between group A and B if +IO is going to sda or sdc. But if actual IO gets translated to disk sdb, then +IO scheduler associated with the sdb will distribute disk bandwidth to +group A and B proportionate to their weight.What if we have partitions sda1, sda2 and sda3 instead of sda, sdb and sdc?
As Gui already mentioned, IO control is on per device basis (like IO scheduler) and we don't try to control it per partition basis.
Quoted 15 lines
Quoted 15 lines
Documentation/block/io-controller.txt new file +14
-0+ +CFQ already has the notion of fairness and it provides differential disk +access based on priority and class of the task. Just that it is flat and +with cgroup stuff, it needs to be made hierarchical. + +Rest of the IO schedulers (noop, deadline and AS) don't have any notion +of fairness among various threads. + +One of the concerns raised with modifying IO schedulers was that we don't +want to replicate the code in all the IO schedulers. These patches share +the fair queuing code which has been moved to a common layer (elevator +layer). Hence we don't end up replicating code across IO schedulers. + +Design
Quoted 8 lines
Documentation/block/io-controller.txt line 64
Quoted 5 lines
+======
Documentation/block/io-controller.txt new file +4
-0+This patchset primarily uses BFQ (Budget Fair Queuing) code to provide +fairness among different IO queues. Fabio and Paolo implemented BFQ which uses +B-WF2Q+ algorithm for fair queuing. +References to BFQ, please. I can search them, but having them in the doc would be nice.
That's a good point. In next posting I will put references also.
Quoted 18 lines
Quoted 5 lines
Documentation/block/io-controller.txt new file +4
-0+Why BFQ? + +- Not sure if weighted round robin logic of CFQ can be easily extended for + hierarchical mode. One of the things is that we can not keep dividingDocumentation/block/io-controller.txt line 78
Quoted 10 lines
Documentation/block/io-controller.txt new file +10
-0+ the time slice of parent group among childrens. Deeper we go in hierarchy + time slice will get smaller. + + One of the ways to implement hierarchical support could be to keep track + of virtual time and service provided to queue/group and select a queue/group + for service based on any of the various available algoriths. + + BFQ already had support for hierarchical scheduling, taking those patches + was easier. +Could you elaborate, when you say timeslices get smaller -
Quoted 2 lines
1. Are you referring to inability to use higher resolution time?
2. Loss of throughput due to timeslice degradation?
I think keeping a track of time using higher resolution time should not be a problem but it would be rather more of loss of throughput due to smaller timeslices and frequent queue switching.
Quoted 10 lines
Documentation/block/io-controller.txt line 85
Quoted 8 lines
+- BFQ was designed to provide tighter bounds/delay w.r.t service provided
Documentation/block/io-controller.txt new file +6
-0+ to a queue. Delay/Jitter with BFQ is supposed to be O(1). + + Note: BFQ originally used amount of IO done (number of sectors) as notion + of service provided. IOW, it tried to provide fairness in terms of + actual IO done and not in terms of actual time disk access was + given to a queue.I assume by sectors you mean the kernel sector size?
Yes.
Quoted 19 lines
Quoted 19 lines
Documentation/block/io-controller.txt new file +18
-0+ + This patcheset modified BFQ to provide fairness in time domain because + that's what CFQ does. So idea was try not to deviate too much from + the CFQ behavior initially. + + Providing fairness in time domain makes accounting trciky because + due to command queueing, at one time there might be multiple requests + from different queues and there is no easy way to find out how much + disk time actually was consumed by the requests of a particular + queue. More about this in comments in source code. + +So it is yet to be seen if changing to time domain still retains BFQ gurantees +or not. + +From data structure point of view, one can think of a tree per device, where +io groups and io queues are hanging and are being scheduled using B-WF2Q+ +algorithm. io_queue, is end queue where requests are actually stored and +dispatched from (like cfqq).
Quoted 8 lines
Documentation/block/io-controller.txt line 109
Quoted 6 lines
Documentation/block/io-controller.txt new file +6
-0+ +These io queues are primarily created by and managed by end io schedulers +depending on its semantics. For example, noop, deadline and AS ioschedulers +keep one io queues per cgroup and cfqq keeps one io queue per io_context in +a cgroup (apart from async queues). +I assume there is one
io_contextper cgroup.
No. There can be multiple io_context per cgroup because currently io_context is defined as threads which are doing IO sharing and are kept in one queue from IO point of view by cfq and multiple queues are not created. So there might be many processes/threads in a cgroup and not necessarily they are sharing the io_context.
Quoted 8 lines
Documentation/block/io-controller.txt line 114
Quoted 6 lines
Documentation/block/io-controller.txt new file +5
-0+A request is mapped to an io group by elevator layer and which io queue it +is mapped to with in group depends on ioscheduler. Currently "current" task +is used to determine the cgroup (hence io group) of the request. Down the +line we need to make use of bio-cgroup patches to map delayed writes to +right group.That seem acceptable
Andrew first wants to see a solid plan for handling async writes :-) So currently I am playing with patches to map writes to correct cgroup. Mapping the IO to right cgroup is only one part of the problem. Other part is that I am not seeing a continuious stream of writes at IO scheduler level. So if two dd processes are running in user space, ideally one can expect two continuous stream of write requests at IO scheduler but instead I see bursty serialized traffic. So a bunch of write request from first dd then another bunch of write requests from second dd and it goes on.. and this leads to no service differentiation between two writes because when higher priority task is not dispatching any IO (for .2 seconds), lower priority task/group gets to use full disk and soon catches up with higher priority one..
Part of this serialization was taking place at request descriptor allocation infrastructure where number of request descriptors are limited and if one writer first consumes most of the descriptors it will block/serialize other writer.
Now I have got a crude working patch where I can limit per group request descriptors so that one group can not block other group. But still don't see continuously backlogged write queues at IO scheduler...
Time to do more debugging and move up the layer and see where this serialization is taking place (i guess page cache...).
Quoted 51 lines
Quoted 51 lines
Documentation/block/io-controller.txt new file +50
-0+ +Going back to old behavior +========================== +In new scheme of things essentially we are creating hierarchical fair +queuing logic in elevator layer and chaning IO schedulers to make use of +that logic so that end IO schedulers start supporting hierarchical scheduling. + +Elevator layer continues to support the old interfaces. So even if fair queuing +is enabled at elevator layer, one can have both new hierchical scheduler as +well as old non-hierarchical scheduler operating. + +Also noop, deadline and AS have option of enabling hierarchical scheduling. +If it is selected, fair queuing is done in hierarchical manner. If hierarchical +scheduling is disabled, noop, deadline and AS should retain their existing +behavior. + +CFQ is the only exception where one can not disable fair queuing as it is +needed for provding fairness among various threads even in non-hierarchical +mode. + +Various user visible config options +=================================== +CONFIG_IOSCHED_NOOP_HIER + - Enables hierchical fair queuing in noop. Not selecting this option + leads to old behavior of noop. + +CONFIG_IOSCHED_DEADLINE_HIER + - Enables hierchical fair queuing in deadline. Not selecting this + option leads to old behavior of deadline. + +CONFIG_IOSCHED_AS_HIER + - Enables hierchical fair queuing in AS. Not selecting this option + leads to old behavior of AS. + +CONFIG_IOSCHED_CFQ_HIER + - Enables hierarchical fair queuing in CFQ. Not selecting this option + still does fair queuing among various queus but it is flat and not + hierarchical. + +Config options selected automatically +===================================== +These config options are not user visible and are selected/deselected +automatically based on IO scheduler configurations. + +CONFIG_ELV_FAIR_QUEUING + - Enables/Disables the fair queuing logic at elevator layer. + +CONFIG_GROUP_IOSCHED + - Enables/Disables hierarchical queuing and associated cgroup bits. +
Quoted 8 lines
Documentation/block/io-controller.txt line 170
Quoted 6 lines
Documentation/block/io-controller.txt new file +6
-0+TODO +==== +- Lots of cleanups, testing, bug fixing, optimizations, benchmarking etc... +- Convert cgroup ioprio to notion of weight. +- Anticipatory code will need more work. It is not working properly currently + and needs more thought.What are the problems with the code?
Have not got a chance to look into the issues in detail yet. Just a crude run saw drop in performance. Will debug it later the moment I have got async writes handled...
Quoted 8 lines
Quoted 1 line
+- Use of bio-cgroup patches.
I saw these posted as well
Quoted 2 lines
+- Use of Nauman's per cgroup request descriptor patches. +
More details would be nice, I am not sure I understand
Currently the number of request descriptors which can be allocated per device/request queue are fixed by a sysfs tunable (q->nr_requests). So if there is lots of IO going on from one cgroup then it will consume all the available request descriptors and other cgroup might starve and not get its fair share.
Hence we also need to introduce the notion of request descriptor limit per cgroup so that if request descriptors from one group are exhausted, then it does not impact the IO of other cgroup.
Quoted 15 lines
Quoted 15 lines
Documentation/block/io-controller.txt new file +14
-0+HOWTO +===== +So far I have done very simple testing of running two dd threads in two +different cgroups. Here is what you can do. + +- Enable hierarchical scheduling in io scheuduler of your choice (say cfq). + CONFIG_IOSCHED_CFQ_HIER=y + +- Compile and boot into kernel and mount IO controller. + + mount -t cgroup -o io none /cgroup + +- Create two cgroups + mkdir -p /cgroup/test1/ /cgroup/test2
Quoted 8 lines
Documentation/block/io-controller.txt line 192
Quoted 5 lines
Documentation/block/io-controller.txt new file +5
-0+ +- Set io priority of group test1 and test2 + echo 0 > /cgroup/test1/io.ioprio + echo 4 > /cgroup/test2/io.ioprio +What is the meaning of priorities? Which is higher, which is lower? What is the maximum? How does it impact b/w?
Currently cfq has notion of priority range 0-7 (0 being highest). To being with we simply adopted that notion though we are converting it to weights now for group.
Mapping from group priority to group weight is linear. So prio 0 group should get double the BW of prio 4 group.
Thanks
Vivek
PATCH 1/1 IO-Controller: Fix kernel panic after moving a task
In reply to a message not in the archiveQuoted 9 lines · Vivek Goyal
(quoted diff) +9
-0+#ifdef CONFIG_IOSCHED_CFQ_HIER +static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic) +{ + struct cfq_queue *async_cfqq = cic_to_cfqq(cic, 0); + struct cfq_queue *sync_cfqq = cic_to_cfqq(cic, 1); + struct cfq_data *cfqd = cic->key; + struct io_group *iog, *__iog; + unsigned long flags; + struct request_queue *q;
Review
Quoted 10 lines
(quoted diff) +10
-0+ + if (unlikely(!cfqd)) + return; + + q = cfqd->q; + + spin_lock_irqsave(q->queue_lock, flags); + + iog = io_lookup_io_group_current(q); +
Hi Vivek,
I triggered another kernel panic when testing. When moving a task to another cgroup, the corresponding iog may not be setup properly all the time. "iog" might be NULL here. io_ioq_move() receives a NULL iog, kernel crash.
Consider the following piece of code:
941 int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) 942 {
943 struct elevator_queue *e = q->elevator;
944
945 elv_fq_set_request_io_group(q, rq);
-->task moving to a new group is happenning here.
946
947 /*
948 * Optimization for noop, deadline and AS which maintain only single 949 * ioq per io group 950 */
951 if (elv_iosched_single_ioq(e))
952 return elv_fq_set_request_ioq(q, rq, gfp_mask);
953
954 if (e->ops->elevator_set_req_fn)
955 return e->ops->elevator_set_req_fn(q, rq, gfp_mask);
cfq_set_request() will finally call io_ioq_move(), but the iog is NULL, beacause the iogs in the hierarchy are not built yet. So kernel crashes.
956
957 rq->elevator_private = NULL;
958 return 0;
959 }
BUG: unable to handle kernel NULL pointer dereference at 000000bc IP: [<c04ebf8f>] io_ioq_move+0xf2/0x109 *pde = 6cc00067 Oops: 0000 [#1] SMP last sysfs file: /sys/block/hdb/queue/slice_idle Modules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbs sbshc battery ac lp snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss snd_pcm serio_raw snd_timer rtc_cmos parport_pc snd r8169 button rtc_core parport soundcore mii i2c_i801 rtc_lib snd_page_alloc pcspkr i2c_core dm_region_hash dm_log dm_mod ext3 jbd mbcache uhci_hcd ohci_hcd ehci_hcd
Pid: 5431, comm: dd Not tainted (2.6.29-rc7-vivek #19) Veriton M460
EIP: 0060:[<c04ebf8f>] EFLAGS: 00010046 CPU: 0
EIP is at io_ioq_move+0xf2/0x109
EAX: f6203a88 EBX: f6792c94 ECX: f6203a84 EDX: 00000006
ESI: 00000000 EDI: 00000000 EBP: f6203a60 ESP: f6304c28
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process dd (pid: 5431, ti=f6304000 task=f669dae0 task.ti=f6304000)
Stack: f62478c0 0100dd40 f6247908 f62d995c 00000000 00000000 f675b54c c04e9182 f638e9b0 00000282 f62d99a4 f6325a2c c04e9113 f5a707c0 c04e7ae0 f675b000 f62d95fc f6325a2c c04e8501 00000010 f631e4e8 f675b000 00080000 ffffff10 Call Trace: [<c04e9182>] changed_cgroup+0x6f/0x8d [<c04e9113>] changed_cgroup+0x0/0x8d [<c04e7ae0>] __call_for_each_cic+0x1b/0x25 [<c04e8501>] cfq_set_request+0x158/0x2c7 [<c06316e6>] _spin_unlock_irqrestore+0x5/0x6 [<c04eb106>] elv_fq_set_request_io_group+0x2b/0x3e [<c04e83a9>] cfq_set_request+0x0/0x2c7 [<c04dddcb>] elv_set_request+0x3e/0x4e [<c04df3da>] get_request+0x1ed/0x29b [<c04df9bb>] get_request_wait+0xdf/0xf2 [<c04dfd89>] __make_request+0x2c6/0x372 [<c049bd76>] do_mpage_readpage+0x4fe/0x5e3 [<c04deba5>] generic_make_request+0x2d0/0x355 [<c04dff47>] submit_bio+0x92/0x97 [<c045bfcb>] add_to_page_cache_locked+0x8a/0xb7 [<c049bfa4>] mpage_end_io_read+0x0/0x50 [<c049b1b6>] mpage_bio_submit+0x19/0x1d [<c049bf9a>] mpage_readpages+0x9b/0xa5 [<f7dd18c7>] ext3_readpages+0x0/0x15 [ext3] [<c0462192>] __do_page_cache_readahead+0xea/0x154 [<f7dd2286>] ext3_get_block+0x0/0xbe [ext3] [<c045d34d>] generic_file_aio_read+0x276/0x569 [<c047cdd9>] do_sync_read+0xbf/0xfe [<c043a3f2>] getnstimeofday+0x51/0xdb [<c0434d3c>] autoremove_wake_function+0x0/0x2d [<c041bdc3>] sched_slice+0x61/0x6a [<c0423114>] task_tick_fair+0x3d/0x60 [<c04c1d79>] security_file_permission+0xc/0xd [<c047cd1a>] do_sync_read+0x0/0xfe [<c047d35a>] vfs_read+0x6c/0x8b [<c047d67e>] sys_read+0x3c/0x63 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x551/0x830 Code: 08 31 c9 89 da e8 77 fc ff ff 8b 86 bc 00 00 00 85 ff 89 43 38 8d 46 60 89 43 40 74 1d 83 c4 0c 89 d8 5b 5e 5f 5d e9 aa f9 ff ff <8b> 86 bc 00 00 00 89 43 38 8d 46 60 89 43 40 83 c4 0c 5b 5e 5f EIP: [<c04ebf8f>] io_ioq_move+0xf2/0x109 SS:ESP 0068:f6304c28
Changelog:
Make sure iogs in the hierarchy are built properly after moving a task to a new cgroup.
--- block/cfq-iosched.c | 4 +++- block/elevator-fq.c | 1 + block/elevator-fq.h | 1 + 3 files changed, 5 insertions(+), 1 deletions(-)
block/cfq-iosched.c +3 -1
@@ -12,6 +12,8 @@#include <linux/rbtree.h> #include <linux/ioprio.h> #include <linux/blktrace_api.h> +#include "elevator-fq.h" +/* * tunables */
@@ -1086,7 +1088,7 @@ static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic)spin_lock_irqsave (q->queue_lock, flags); - iog =io_lookup_io_group_current (q); + iog =io_get_io_group (q);if (async_cfqq !=NULL ) { __iog =cfqq_to_io_group (async_cfqq);
block/elevator-fq.c +1 -0
@@ -1191,6 +1191,7 @@ struct io_group *io_get_io_group(struct request_queue *q)return iog; } +EXPORT_SYMBOL (io_get_io_group);void io_free_root_group (struct elevator_queue *e) {
block/elevator-fq.h +1 -0
@@ -459,6 +459,7 @@ static inline struct io_group *ioq_to_io_group(struct io_queue *ioq) }#ifdef CONFIG_GROUP_IOSCHED +extern struct io_group *io_get_io_group (struct request_queue *q);extern int io_group_allow_merge (struct request *rq,struct bio *bio);extern void io_ioq_move (struct elevator_queue *e,struct io_queue *ioq,struct io_group *iog);
Signature · 1 line
1.5.4.rc3
PATCH 1/1 IO-Controller: Fix kernel panic after moving a task
In reply to Vivek GoyalQuoted 9 lines · Vivek Goyal
(quoted diff) +9
-0+#ifdef CONFIG_IOSCHED_CFQ_HIER +static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic) +{ + struct cfq_queue *async_cfqq = cic_to_cfqq(cic, 0); + struct cfq_queue *sync_cfqq = cic_to_cfqq(cic, 1); + struct cfq_data *cfqd = cic->key; + struct io_group *iog, *__iog; + unsigned long flags; + struct request_queue *q;
Review
Quoted 10 lines
(quoted diff) +10
-0+ + if (unlikely(!cfqd)) + return; + + q = cfqd->q; + + spin_lock_irqsave(q->queue_lock, flags); + + iog = io_lookup_io_group_current(q); +
Hi Vivek,
I triggered another kernel panic when testing. When moving a task to another cgroup, the corresponding iog may not be setup properly all the time. "iog" might be NULL here. io_ioq_move() receives a NULL iog, kernel crash.
Consider the following piece of code:
941 int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask) 942 {
943 struct elevator_queue *e = q->elevator;
944
945 elv_fq_set_request_io_group(q, rq);
-->task moving to a new group is happenning here.
946
947 /*
948 * Optimization for noop, deadline and AS which maintain only single 949 * ioq per io group 950 */
951 if (elv_iosched_single_ioq(e))
952 return elv_fq_set_request_ioq(q, rq, gfp_mask);
953
954 if (e->ops->elevator_set_req_fn)
955 return e->ops->elevator_set_req_fn(q, rq, gfp_mask);
cfq_set_request() will finally call io_ioq_move(), but the iog is NULL, beacause the iogs in the hierarchy are not built yet. So kernel crashes.
956
957 rq->elevator_private = NULL;
958 return 0;
959 }
BUG: unable to handle kernel NULL pointer dereference at 000000bc IP: [<c04ebf8f>] io_ioq_move+0xf2/0x109 *pde = 6cc00067 Oops: 0000 [#1] SMP last sysfs file: /sys/block/hdb/queue/slice_idle Modules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbs sbshc battery ac lp snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss snd_pcm serio_raw snd_timer rtc_cmos parport_pc snd r8169 button rtc_core parport soundcore mii i2c_i801 rtc_lib snd_page_alloc pcspkr i2c_core dm_region_hash dm_log dm_mod ext3 jbd mbcache uhci_hcd ohci_hcd ehci_hcd
Pid: 5431, comm: dd Not tainted (2.6.29-rc7-vivek #19) Veriton M460
EIP: 0060:[<c04ebf8f>] EFLAGS: 00010046 CPU: 0
EIP is at io_ioq_move+0xf2/0x109
EAX: f6203a88 EBX: f6792c94 ECX: f6203a84 EDX: 00000006
ESI: 00000000 EDI: 00000000 EBP: f6203a60 ESP: f6304c28
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process dd (pid: 5431, ti=f6304000 task=f669dae0 task.ti=f6304000)
Stack: f62478c0 0100dd40 f6247908 f62d995c 00000000 00000000 f675b54c c04e9182 f638e9b0 00000282 f62d99a4 f6325a2c c04e9113 f5a707c0 c04e7ae0 f675b000 f62d95fc f6325a2c c04e8501 00000010 f631e4e8 f675b000 00080000 ffffff10 Call Trace: [<c04e9182>] changed_cgroup+0x6f/0x8d [<c04e9113>] changed_cgroup+0x0/0x8d [<c04e7ae0>] __call_for_each_cic+0x1b/0x25 [<c04e8501>] cfq_set_request+0x158/0x2c7 [<c06316e6>] _spin_unlock_irqrestore+0x5/0x6 [<c04eb106>] elv_fq_set_request_io_group+0x2b/0x3e [<c04e83a9>] cfq_set_request+0x0/0x2c7 [<c04dddcb>] elv_set_request+0x3e/0x4e [<c04df3da>] get_request+0x1ed/0x29b [<c04df9bb>] get_request_wait+0xdf/0xf2 [<c04dfd89>] __make_request+0x2c6/0x372 [<c049bd76>] do_mpage_readpage+0x4fe/0x5e3 [<c04deba5>] generic_make_request+0x2d0/0x355 [<c04dff47>] submit_bio+0x92/0x97 [<c045bfcb>] add_to_page_cache_locked+0x8a/0xb7 [<c049bfa4>] mpage_end_io_read+0x0/0x50 [<c049b1b6>] mpage_bio_submit+0x19/0x1d [<c049bf9a>] mpage_readpages+0x9b/0xa5 [<f7dd18c7>] ext3_readpages+0x0/0x15 [ext3] [<c0462192>] __do_page_cache_readahead+0xea/0x154 [<f7dd2286>] ext3_get_block+0x0/0xbe [ext3] [<c045d34d>] generic_file_aio_read+0x276/0x569 [<c047cdd9>] do_sync_read+0xbf/0xfe [<c043a3f2>] getnstimeofday+0x51/0xdb [<c0434d3c>] autoremove_wake_function+0x0/0x2d [<c041bdc3>] sched_slice+0x61/0x6a [<c0423114>] task_tick_fair+0x3d/0x60 [<c04c1d79>] security_file_permission+0xc/0xd [<c047cd1a>] do_sync_read+0x0/0xfe [<c047d35a>] vfs_read+0x6c/0x8b [<c047d67e>] sys_read+0x3c/0x63 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x551/0x830 Code: 08 31 c9 89 da e8 77 fc ff ff 8b 86 bc 00 00 00 85 ff 89 43 38 8d 46 60 89 43 40 74 1d 83 c4 0c 89 d8 5b 5e 5f 5d e9 aa f9 ff ff <8b> 86 bc 00 00 00 89 43 38 8d 46 60 89 43 40 83 c4 0c 5b 5e 5f EIP: [<c04ebf8f>] io_ioq_move+0xf2/0x109 SS:ESP 0068:f6304c28
Changelog:
Make sure iogs in the hierarchy are built properly after moving a task to a new cgroup.
--- block/cfq-iosched.c | 4 +++- block/elevator-fq.c | 1 + block/elevator-fq.h | 1 + 3 files changed, 5 insertions(+), 1 deletions(-)
block/cfq-iosched.c +3 -1
@@ -12,6 +12,8 @@#include <linux/rbtree.h> #include <linux/ioprio.h> #include <linux/blktrace_api.h> +#include "elevator-fq.h" +/* * tunables */
@@ -1086,7 +1088,7 @@ static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic)spin_lock_irqsave (q->queue_lock, flags); - iog =io_lookup_io_group_current (q); + iog =io_get_io_group (q);if (async_cfqq !=NULL ) { __iog =cfqq_to_io_group (async_cfqq);
block/elevator-fq.c +1 -0
@@ -1191,6 +1191,7 @@ struct io_group *io_get_io_group(struct request_queue *q)return iog; } +EXPORT_SYMBOL (io_get_io_group);void io_free_root_group (struct elevator_queue *e) {
block/elevator-fq.h +1 -0
@@ -459,6 +459,7 @@ static inline struct io_group *ioq_to_io_group(struct io_queue *ioq) }#ifdef CONFIG_GROUP_IOSCHED +extern struct io_group *io_get_io_group (struct request_queue *q);extern int io_group_allow_merge (struct request *rq,struct bio *bio);extern void io_ioq_move (struct elevator_queue *e,struct io_queue *ioq,struct io_group *iog);
Signature · 1 line
1.5.4.rc3
Re: [PATCH 01/10] Documentation
In reply to Andrea RighiOn Wed, Apr 08, 2009 at 10:37:59PM +0200, Andrea Righi wrote:
[..]
Quoted 16 lines
Quoted 9 lines
- I can think of atleast one usage of uppper limit controller where we might have spare IO resources still we don't want to give it to a cgroup because customer has not paid for that kind of service level. In those cases we need to implement uppper limit also.
May be prportional weight and max bw controller can co-exist depending on what user's requirements are.
Quoted 6 lines
If yes, then can't this control be done at the same layer/level where proportional weight control is being done? IOW, this set of patches is trying to do prportional weight control at IO scheduler level. I think we should be able to store another max rate as another feature in cgroup (apart from weight) and not dispatch requests from the queue if we have exceeded the max BW as specified by the user?
Quoted 3 lines
The more I think about a "perfect" solution (at least for my requirements), the more I'm convinced that we need both functionalities.
I agree here. In some scenarios people might want to put an upper cap on BW even if more BW is available and in some scenarios people will like to do proportional distribution and let one get more share of disk if it is free.
Quoted 6 lines
I think it would be possible to implement both proportional and limiting rules at the same level (e.g., the IO scheduler), but we need also to address the memory consumption problem (I still need to review your patchset in details and I'm going to test it soon :), so I don't know if you already addressed this issue).
Can you please elaborate a bit on this? Are you concerned about that data structures created to solve the problem consume a lot of memory?
Quoted 13 lines
IOW if we simply don't dispatch requests and we don't throttle the tasks in the cgroup that exceeds its limit, how do we avoid the waste of memory due to the succeeding IO requests and the increasingly dirty pages in the page cache (that are also hard to reclaim)? I may be wrong, but I think we talked about this problem in a previous email... sorry I don't find the discussion in my mail archives.
IMHO a nice approach would be to measure IO consumption at the IO scheduler level, and control IO applying proportional weights / absolute limits _both_ at the IO scheduler / elevator level _and_ at the same time block the tasks from dirtying memory that will generate additional IO requests.
Quoted 5 lines
Anyway, there's no need to provide this with a single IO controller, we could split the problem in two parts: 1) provide a proportional / absolute IO controller in the IO schedulers and 2) allow to set, for example, a maximum limit of dirty pages for each cgroup.
I think setting a maximum limit on dirty pages is an interesting thought. It sounds like as if memory controller can handle it?
I guess currently memory controller puts limit on total amount of memory consumed by cgroup and there are no knobs on type of memory consumed. So if one can limit amount of dirty page cache memory per cgroup, it automatically throttles the aysnc writes at the input itself.
So I agree that if we can limit the process from dirtying too much of memory than IO scheduler level controller should be able to do both proportional weight and max bw controller.
Currently doing proportional weight control for async writes is very tricky. I am not seeing constantly backlogged traffic at IO scheudler level and hence two different weight processes seem to be getting same BW.
I will dive deeper into the patches on dm-ioband to see how they have solved this issue. Looks like they are just waiting longer for slowest group to consume its tokens and that will keep the disk idle. Extended delays might now show up immediately as performance hog, because it might also promote increased merging but it should lead to increased latency of response. And proving latency issues is hard. :-)
Quoted 18 lines
Maybe I'm just repeating what we already said in a previous discussion... in this case sorry for the duplicate thoughts. :)
Quoted 3 lines
- Have you thought of doing hierarchical control?
Providing hiearchies in cgroups is in general expensive, deeper hierarchies imply checking all the way up to the root cgroup, so I think we need to be very careful and be aware of the trade-offs before providing such feature. For this particular case (IO controller) wouldn't it be simpler and more efficient to just ignore hierarchies in the kernel and opportunely handle them in userspace? for absolute limiting rules this isn't difficult at all, just imagine a config file and a script or a deamon that dynamically create the opportune cgroups and configure them accordingly to what is defined in the configuration file.
Quoted 8 lines
I think we can simply define hierarchical dependencies in the configuration file, translate them in absolute values and use the absolute values to configure the cgroups' properties.
For example, we can just check that the BW allocated for a particular parent cgroup is not greater than the total BW allocated for the children. And for each child just use the
min(parent_BW, BW)or equally divide the parent's BW among the children, etc.
IIUC, you are saying that allow hiearchy in user space and then flatten it out and pass it to kernel?
Hmm.., agree that handling hierarchies is hard and expensive. But at the same time rest of the controllers like cpu and memory are handling it in kernel so it probably makes sense to keep the IO controller also in line.
In practice I am not expecting deep hiearchices. May be 2- 3 levels would be good for most of the people.
Quoted 8 lines
Quoted 5 lines
- What happens to the notion of CFQ task classes and task priority. Looks like max bw rule supercede everything. There is no way that an RT task get unlimited amount of disk BW even if it wants to? (There is no notion of RT cgroup etc)
What about moving all the RT tasks in a separate cgroup with unlimited BW?
Hmm.., I think that should work. I have yet to look at your patches in detail but it looks like unlimited BW group will not be throttled at all hence RT tasks can just go right through without getting impacted.
Quoted 70 lines
Quoted 33 lines
Quoted 21 lines
Quoted 10 lines
Above requirement can create configuration problems.
- If there are large number of disks in system, per cgroup one shall have to create rules for each disk. Until and unless admin knows what applications are in which cgroup and strictly what disk these applications do IO to and create rules for only those disks.
I don't think this is a huge problem anyway. IMHO a userspace tool, e.g. a script, would be able to efficiently create/modify rules parsing user defined rules in some human-readable form (config files, etc.), even in presence of hundreds of disk. The same is valid for dm-ioband I think.
Quoted 4 lines
- I think problem gets compounded if there is a hierarchy of logical devices. I think in that case one shall have to create rules for logical devices and not actual physical devices.
Quoted 6 lines
With logical devices you mean device-mapper devices (i.e. LVM, software RAID, etc.)? or do you mean that we need to introduce the concept of "logical device" to easily (quickly) configure IO requirements and then map those logical devices to the actual physical devices? In this case I think this can be addressed in userspace. Or maybe I'm totally missing the point here.
Yes, I meant LVM, Software RAID etc. So if I have got many disks in the system and I have created software raid on some of them, I need to create rules for lvm devices or physical devices behind those lvm devices? I am assuming that it will be logical devices.
Quoted 5 lines
So I need to know exactly to what all devices applications in a particular cgroup is going to do IO, and also know exactly how many cgroups are contending for that cgroup, and also know what worst case disk rate I can expect from that device and then I can do a good job of giving a reasonable value to the max rate of that cgroup on a particular device?
ok, I understand. For these cases dm-ioband perfectly addresses the problem. For the general case, I think the only solution is to provide a common interface that each dm subsystem must call to account IO and apply limiting and proportional rules.
Quoted 26 lines
Quoted 25 lines
Quoted 7 lines
- Because it is not proportional weight distribution, if some cgroup is not using its planned BW, other group sharing the disk can not make use of spare BW.
Right.
Quoted 9 lines
- I think one should know in advance the throughput rate of underlying media and also know competing applications so that one can statically define the BW assigned to each cgroup on each disk.
This will be difficult. Effective BW extracted out of a rotational media is dependent on the seek pattern so one shall have to either try to make some conservative estimates and try to divide BW (we will not utilize disk fully) or take some peak numbers and divide BW (cgroup might not get the maximum rate configured).
Correct. I think the proportional weight approach is the only solution to efficiently use the whole BW. OTOH absolute limiting rules offer a better control over QoS, because you can totally remove performance bursts/peaks that could break QoS requirements for short periods of time.
Quoted 8 lines
Quoted 2 lines
Can you please give little more details here regarding how QoS requirements are not met with proportional weight?
With proportional weights the whole bandwidth is allocated if no one else is using it. When IO is submitted other tasks with a higher weight can be forced to sleep until the IO generated by the low weight tasks is not completely dispatched. Or any extent of the priority inversion problems.
Hmm..., I am not very sure here. When admin is allocating the weights, he has the whole picture. He knows how many groups are conteding for the disk and what could be the worst case scenario. So if I have got two groups with A and B with weight 1 and 2 and both are contending, then as an admin one would expect to get 33% of BW for group A in worst case (if group B is continuously backlogged). If B is not contending than A can get 100% of BW. So while configuring the system, will one not plan for worst case (33% for A, and 66 % for B)?
Quoted 9 lines
Maybe it's not an issue at all for the most part of the cases, but using a solution that is able to provide also a real partitioning of the available resources can be profitely used by those who need to guarantee _strict_ BW requirements (soft real-time, maximize the responsiveness of certain services, etc.), because in this case we're sure that a certain amount of "spare" BW will be always available when needed by some "critical" services.
Will the same thing not happen in proportional weight? If it is an RT application, one can put it in RT groups to make sure it always gets the BW first even if there is contention.
Even in regular group, the moment you issue the IO and IO scheduler sees it, you will start getting your reserved share according to your weight.
How it will be different in the case of io throttling? Even if I don't utilize the disk fully, cfq will still put the new guy in the queue and then try to give its share (based on prio).
Are you saying that by keeping disk relatively free, the latency of response for soft real time application will become better? In that case can't one simply underprovision the disk?
But having said that I am not disputing the need of max BW controller as some people have expressed the need of a constant BW view and don't want too big a fluctuations even if BW is available. Max BW controller can't gurantee the minumum BW hence can't avoid the fluctuations completely, but it can still help in smoothing the traffic because other competitiors will be stopped from doing too much of IO.
Thanks
Vivek
Quoted 14 lines
Quoted 11 lines
Quoted 6 lines
So, my "ideal" IO controller should allow to define both rules:
absolute and proportional limits.I still have to look closely at your patchset anyway. I will do and give a feedback.
You feedback is always welcome.
Thanks
VivekThanks,
-Andrea
Re: [PATCH] IO-Controller: Fix kernel panic after moving a task
In reply to Gui JianfengQuoted 48 lines · Gui Jianfeng
Quoted 9 lines · Vivek Goyal
(quoted diff) +9
-0+#ifdef CONFIG_IOSCHED_CFQ_HIER +static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic) +{ + struct cfq_queue *async_cfqq = cic_to_cfqq(cic, 0); + struct cfq_queue *sync_cfqq = cic_to_cfqq(cic, 1); + struct cfq_data *cfqd = cic->key; + struct io_group *iog, *__iog; + unsigned long flags; + struct request_queue *q;Review
Quoted 10 lines
(quoted diff) +10
-0+ + if (unlikely(!cfqd)) + return; + + q = cfqd->q; + + spin_lock_irqsave(q->queue_lock, flags); + + iog = io_lookup_io_group_current(q); +Hi Vivek,
I triggered another kernel panic when testing. When moving a task to another cgroup, the corresponding iog may not be setup properly all the time. "iog" might be NULL here.
io_ioq_move()receives a NULL iog, kernel crash.Consider the following piece of code:
941 int
elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)942 {
943 structelevator_queue*e =q->elevator;
944
945elv_fq_set_request_io_group(q, rq);-->task moving to a new group is happenning here.
946
947 /*948 * Optimization for noop, deadline and AS which maintain only single 949 * ioq per io group 950 */951 if (
elv_iosched_single_ioq(e))
952 returnelv_fq_set_request_ioq(q, rq, gfp_mask);
953
954 if (e->ops->elevator_set_req_fn)
955 returne->ops->elevator_set_req_fn(q, rq, gfp_mask);
Quoted 8 lines
cfq_set_request()will finally callio_ioq_move(), but the iog is NULL, beacause the iogs in the hierarchy are not built yet. So kernel crashes.956
957rq->elevator_private= NULL;
958 return 0;
959 }
Thanks Gui. Good catch.
Quoted 71 lines
BUG: unable to handle kernel NULL pointer dereference at 000000bc IP: [<c04ebf8f>] io_ioq_move+0xf2/0x109 *pde = 6cc00067 Oops: 0000 [#1] SMP last sysfs file: /sys/block/hdb/queue/slice_idle Modules linked in: ipv6 cpufreq_ondemand acpi_cpufreq dm_mirror dm_multipath sbs sbshc battery ac lp snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_seq_dummy snd_seq_oss snd_seq_midi_event snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss snd_pcm serio_raw snd_timer rtc_cmos parport_pc snd r8169 button rtc_core parport soundcore mii i2c_i801 rtc_lib snd_page_alloc pcspkr i2c_core dm_region_hash dm_log dm_mod ext3 jbd mbcache uhci_hcd ohci_hcd ehci_hcdPid: 5431, comm: dd Not tainted (2.6.29-rc7-vivek #19) Veriton M460
EIP: 0060:[<c04ebf8f>] EFLAGS: 00010046 CPU: 0
EIP is atio_ioq_move+0xf2/0x109
EAX:f6203a88EBX:f6792c94ECX:f6203a84EDX: 00000006
ESI: 00000000 EDI: 00000000 EBP:f6203a60ESP:f6304c28
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process dd (pid: 5431, ti=f6304000 task=f669dae0 task.ti=f6304000)Stack: f62478c0 0100dd40 f6247908 f62d995c 00000000 00000000 f675b54c c04e9182 f638e9b0 00000282 f62d99a4 f6325a2c c04e9113 f5a707c0 c04e7ae0 f675b000 f62d95fc f6325a2c c04e8501 00000010 f631e4e8 f675b000 00080000 ffffff10 Call Trace: [<c04e9182>] changed_cgroup+0x6f/0x8d [<c04e9113>] changed_cgroup+0x0/0x8d [<c04e7ae0>] __call_for_each_cic+0x1b/0x25 [<c04e8501>] cfq_set_request+0x158/0x2c7 [<c06316e6>] _spin_unlock_irqrestore+0x5/0x6 [<c04eb106>] elv_fq_set_request_io_group+0x2b/0x3e [<c04e83a9>] cfq_set_request+0x0/0x2c7 [<c04dddcb>] elv_set_request+0x3e/0x4e [<c04df3da>] get_request+0x1ed/0x29b [<c04df9bb>] get_request_wait+0xdf/0xf2 [<c04dfd89>] __make_request+0x2c6/0x372 [<c049bd76>] do_mpage_readpage+0x4fe/0x5e3 [<c04deba5>] generic_make_request+0x2d0/0x355 [<c04dff47>] submit_bio+0x92/0x97 [<c045bfcb>] add_to_page_cache_locked+0x8a/0xb7 [<c049bfa4>] mpage_end_io_read+0x0/0x50 [<c049b1b6>] mpage_bio_submit+0x19/0x1d [<c049bf9a>] mpage_readpages+0x9b/0xa5 [<f7dd18c7>] ext3_readpages+0x0/0x15 [ext3] [<c0462192>] __do_page_cache_readahead+0xea/0x154 [<f7dd2286>] ext3_get_block+0x0/0xbe [ext3] [<c045d34d>] generic_file_aio_read+0x276/0x569 [<c047cdd9>] do_sync_read+0xbf/0xfe [<c043a3f2>] getnstimeofday+0x51/0xdb [<c0434d3c>] autoremove_wake_function+0x0/0x2d [<c041bdc3>] sched_slice+0x61/0x6a [<c0423114>] task_tick_fair+0x3d/0x60 [<c04c1d79>] security_file_permission+0xc/0xd [<c047cd1a>] do_sync_read+0x0/0xfe [<c047d35a>] vfs_read+0x6c/0x8b [<c047d67e>] sys_read+0x3c/0x63 [<c0402fc1>] sysenter_do_call+0x12/0x21 [<c0630000>] schedule+0x551/0x830 Code: 08 31 c9 89 da e8 77 fc ff ff 8b 86 bc 00 00 00 85 ff 89 43 38 8d 46 60 89 43 40 74 1d 83 c4 0c 89 d8 5b 5e 5f 5d e9 aa f9 ff ff <8b> 86 bc 00 00 00 89 43 38 8d 46 60 89 43 40 83 c4 0c 5b 5e 5f EIP: [<c04ebf8f>] io_ioq_move+0xf2/0x109 SS:ESP 0068:f6304c28Changelog:
Make sure iogs in the hierarchy are built properly after moving a task to a new cgroup.
Signed-off-by Gui Jianfeng <[email protected]>--- block/cfq-iosched.c | 4 +++- block/elevator-fq.c | 1 + block/elevator-fq.h | 1 + 3 files changed, 5 insertions(+), 1 deletions(-)block/cfq-iosched.c +0
-0
block/cfq-iosched.c line 16
Quoted 5 lines
block/cfq-iosched.c +2
-0@@ -12,6 +12,8 @@#include <linux/rbtree.h> #include <linux/ioprio.h> #include <linux/blktrace_api.h> +#include "elevator-fq.h" +
I think above explicit inclusion of "elevator-fq.h" might be unnecessary as elevator.h includes elevator-fq.h and cfq-iosched.c is including elevator.h
block/cfq-iosched.c static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic) · line 1091
Quoted 9 lines
block/cfq-iosched.c +1
-1/* * tunables */ @@ -1086,7 +1088,7 @@ static void changed_cgroup(struct io_context *ioc, struct cfq_io_context *cic)spin_lock_irqsave (q->queue_lock, flags); - iog =io_lookup_io_group_current (q); + iog =io_get_io_group (q);
A one line comment here explaining the need to get_io_group instead of lookup_io_group will be nice.
Thanks
Vivek
Quoted 31 lines
block/cfq-iosched.c +0
-0if (async_cfqq !=NULL ) { __iog =cfqq_to_io_group (async_cfqq);block/elevator-fq.c +1
-0@@ -1191,6 +1191,7 @@ struct io_group *io_get_io_group(struct request_queue *q)return iog; } +EXPORT_SYMBOL (io_get_io_group);void io_free_root_group (struct elevator_queue *e) {block/elevator-fq.h +1
-0@@ -459,6 +459,7 @@ static inline struct io_group *ioq_to_io_group(struct io_queue *ioq) }#ifdef CONFIG_GROUP_IOSCHED +extern struct io_group *io_get_io_group (struct request_queue *q);extern int io_group_allow_merge (struct request *rq,struct bio *bio);extern void io_ioq_move (struct elevator_queue *e,struct io_queue *ioq,struct io_group *iog);Signature · 1 line
1.5.4.rc3
Re: [PATCH 01/10] Documentation
In reply to a message not in the archiveQuoted 22 lines · Vivek Goyal
On Wed, Apr 08, 2009 at 10:37:59PM +0200, Andrea Righi wrote:
[..]
Quoted 19 lines
Quoted 9 lines
- I can think of atleast one usage of uppper limit controller where we might have spare IO resources still we don't want to give it to a cgroup because customer has not paid for that kind of service level. In those cases we need to implement uppper limit also.
May be prportional weight and max bw controller can co-exist depending on what user's requirements are.
Quoted 6 lines
If yes, then can't this control be done at the same layer/level where proportional weight control is being done? IOW, this set of patches is trying to do prportional weight control at IO scheduler level. I think we should be able to store another max rate as another feature in cgroup (apart from weight) and not dispatch requests from the queue if we have exceeded the max BW as specified by the user?
The more I think about a "perfect" solution (at least for my requirements), the more I'm convinced that we need both functionalities.
hard limits vs work conserving argument again :). I agree, we need both of the functionalities. I think first the aim should be to get the proportional weight functionality and then look at doing hard limits.
[..]
Quoted 27 lines
Quoted 15 lines
Quoted 3 lines
- Have you thought of doing hierarchical control?
Providing hiearchies in cgroups is in general expensive, deeper hierarchies imply checking all the way up to the root cgroup, so I think we need to be very careful and be aware of the trade-offs before providing such feature. For this particular case (IO controller) wouldn't it be simpler and more efficient to just ignore hierarchies in the kernel and opportunely handle them in userspace? for absolute limiting rules this isn't difficult at all, just imagine a config file and a script or a deamon that dynamically create the opportune cgroups and configure them accordingly to what is defined in the configuration file.
Quoted 8 lines
I think we can simply define hierarchical dependencies in the configuration file, translate them in absolute values and use the absolute values to configure the cgroups' properties.
For example, we can just check that the BW allocated for a particular parent cgroup is not greater than the total BW allocated for the children. And for each child just use the
min(parent_BW, BW)or equally divide the parent's BW among the children, etc.IIUC, you are saying that allow hiearchy in user space and then flatten it out and pass it to kernel?
Quoted 7 lines
Hmm.., agree that handling hierarchies is hard and expensive. But at the same time rest of the controllers like cpu and memory are handling it in kernel so it probably makes sense to keep the IO controller also in line.
In practice I am not expecting deep hiearchices. May be 2- 3 levels would be good for most of the people.
FWIW, even in the CPU controller having deep hierarchies is not a good idea. I think this can be documented for IO Controller as well. Beyond that, we realized that having a proportional system and doing it in userspace is not a good idea. It would require a lot of calculations dependending on the system load. (Because, the sub-group should be just the same as a process in the parent group). Having hierarchy in the kernel just makes it way more easier and way more accurate.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
- What happens to the notion of CFQ task classes and task priority. Looks like max bw rule supercede everything. There is no way that an RT task get unlimited amount of disk BW even if it wants to? (There is no notion of RT cgroup etc)
Quoted 7 lines
Quoted 2 lines
What about moving all the RT tasks in a separate cgroup with unlimited BW?
Hmm.., I think that should work. I have yet to look at your patches in detail but it looks like unlimited BW group will not be throttled at all hence RT tasks can just go right through without getting impacted.
This is where the cpu scheduler design helped a lot :). Having different classes for differnet types of processes allowed us to handle them separately.
thanks,
Signature · 2 lines
regards, Dhaval