From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752896AbZH1VfU (ORCPT ); Fri, 28 Aug 2009 17:35:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752643AbZH1VfP (ORCPT ); Fri, 28 Aug 2009 17:35:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbZH1Vcj (ORCPT ); Fri, 28 Aug 2009 17:32:39 -0400 From: Vivek Goyal To: linux-kernel@vger.kernel.org, jens.axboe@oracle.com Cc: containers@lists.linux-foundation.org, dm-devel@redhat.com, nauman@google.com, dpshah@google.com, lizf@cn.fujitsu.com, mikew@google.com, fchecconi@gmail.com, paolo.valente@unimore.it, ryov@valinux.co.jp, fernando@oss.ntt.co.jp, s-uchida@ap.jp.nec.com, taka@valinux.co.jp, guijianfeng@cn.fujitsu.com, jmoyer@redhat.com, dhaval@linux.vnet.ibm.com, balbir@linux.vnet.ibm.com, righi.andrea@gmail.com, m-ikeda@ds.jp.nec.com, agk@redhat.com, vgoyal@redhat.com, akpm@linux-foundation.org, peterz@infradead.org, jmarchan@redhat.com, torvalds@linux-foundation.org, mingo@elte.hu, riel@redhat.com Subject: [PATCH 12/23] io-controller: Wait for requests to complete from last queue before new queue is scheduled Date: Fri, 28 Aug 2009 17:31:01 -0400 Message-Id: <1251495072-7780-13-git-send-email-vgoyal@redhat.com> In-Reply-To: <1251495072-7780-1-git-send-email-vgoyal@redhat.com> References: <1251495072-7780-1-git-send-email-vgoyal@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org o Currently one can dispatch requests from multiple queues to the disk. This is true for hardware which supports queuing. So if a disk support queue depth of 31 it is possible that 20 requests are dispatched from queue 1 and then next queue is scheduled in which dispatches more requests. o This multiple queue dispatch introduces issues for accurate accounting of disk time consumed by a particular queue. For example, if one async queue is scheduled in, it can dispatch 31 requests to the disk and then it will be expired and a new sync queue might get scheduled in. These 31 requests might take a long time to finish but this time is never accounted to the async queue which dispatched these requests. o This patch introduces the functionality where we wait for all the requests to finish from previous queue before next queue is scheduled in. That way a queue is more accurately accounted for disk time it has consumed. Note this still does not take care of errors introduced by disk write caching. o Because above behavior can result in reduced throughput, this behavior will be enabled only if user sets "fairness" tunable to 1. o This patch helps in achieving more isolation between reads and buffered writes in different cgroups. buffered writes typically utilize full queue depth and then expire the queue. On the contarary, sequential reads typicaly driver queue depth of 1. So despite the fact that writes are using more disk time it is never accounted to write queue because we don't wait for requests to finish after dispatching these. This patch helps do more accurate accounting of disk time, especially for buffered writes hence providing better fairness hence better isolation between two cgroups running read and write workloads. Signed-off-by: Vivek Goyal --- block/cfq-iosched.c | 1 + block/elevator-fq.c | 21 ++++++++++++++++++++- block/elevator-fq.h | 10 +++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 11ae473..52c4710 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2123,6 +2123,7 @@ static struct elv_fs_entry cfq_attrs[] = { ELV_ATTR(slice_async), #ifdef CONFIG_GROUP_IOSCHED ELV_ATTR(group_idle), + ELV_ATTR(fairness), #endif __ATTR_NULL }; diff --git a/block/elevator-fq.c b/block/elevator-fq.c index 6ea5be4..840b73b 100644 --- a/block/elevator-fq.c +++ b/block/elevator-fq.c @@ -681,6 +681,8 @@ SHOW_FUNCTION(elv_slice_sync_show, efqd->elv_slice[1], 1); EXPORT_SYMBOL(elv_slice_sync_show); SHOW_FUNCTION(elv_slice_async_show, efqd->elv_slice[0], 1); EXPORT_SYMBOL(elv_slice_async_show); +SHOW_FUNCTION(elv_fairness_show, efqd->fairness, 0); +EXPORT_SYMBOL(elv_fairness_show); #undef SHOW_FUNCTION #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ @@ -705,6 +707,8 @@ STORE_FUNCTION(elv_slice_sync_store, &efqd->elv_slice[1], 1, UINT_MAX, 1); EXPORT_SYMBOL(elv_slice_sync_store); STORE_FUNCTION(elv_slice_async_store, &efqd->elv_slice[0], 1, UINT_MAX, 1); EXPORT_SYMBOL(elv_slice_async_store); +STORE_FUNCTION(elv_fairness_store, &efqd->fairness, 0, 1, 0); +EXPORT_SYMBOL(elv_fairness_store); #undef STORE_FUNCTION void elv_schedule_dispatch(struct request_queue *q) @@ -2271,6 +2275,17 @@ void *elv_select_ioq(struct request_queue *q, int force) } expire: + if (efqd->fairness && !force && ioq && ioq->dispatched) { + /* + * If there are request dispatched from this queue, don't + * dispatch requests from new queue till all the requests from + * this queue have completed. + */ + elv_log_ioq(efqd, ioq, "select: wait for requests to finish" + " disp=%lu", ioq->dispatched); + ioq = NULL; + goto keep_queue; + } elv_slice_expired(q); new_queue: ioq = elv_set_active_ioq(q, new_ioq); @@ -2386,6 +2401,10 @@ void elv_ioq_completed_request(struct request_queue *q, struct request *rq) goto done; } + /* Wait for requests to finish from this queue */ + if (efqd->fairness && elv_ioq_nr_dispatched(ioq)) + goto done; + /* Expire the queue */ elv_slice_expired(q); goto done; @@ -2396,7 +2415,7 @@ void elv_ioq_completed_request(struct request_queue *q, struct request *rq) * If this is the last queue in the group and we did not * decide to idle on queue, idle on group. */ - if (elv_iog_should_idle(ioq) && !ioq->dispatched + if (elv_iog_should_idle(ioq) && !elv_ioq_nr_dispatched(ioq) && !timer_pending(&efqd->idle_slice_timer)) { /* * If queue has used up its slice, wait for the diff --git a/block/elevator-fq.h b/block/elevator-fq.h index 0a34c7f..b9f3fc7 100644 --- a/block/elevator-fq.h +++ b/block/elevator-fq.h @@ -180,6 +180,12 @@ struct elv_fq_data { /* Fallback dummy ioq for extreme OOM conditions */ struct io_queue oom_ioq; + + /* + * If set to 1, waits for all request completions from current + * queue before new queue is scheduled in + */ + unsigned int fairness; }; /* Logging facilities. */ @@ -437,7 +443,9 @@ extern ssize_t elv_slice_sync_store(struct elevator_queue *q, const char *name, extern ssize_t elv_slice_async_show(struct elevator_queue *q, char *name); extern ssize_t elv_slice_async_store(struct elevator_queue *q, const char *name, size_t count); - +extern ssize_t elv_fairness_show(struct elevator_queue *q, char *name); +extern ssize_t elv_fairness_store(struct elevator_queue *q, const char *name, + size_t count); /* Functions used by elevator.c */ extern struct elv_fq_data *elv_alloc_fq_data(struct request_queue *q, struct elevator_queue *e); -- 1.6.0.6 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vivek Goyal Subject: [PATCH 12/23] io-controller: Wait for requests to complete from last queue before new queue is scheduled Date: Fri, 28 Aug 2009 17:31:01 -0400 Message-ID: <1251495072-7780-13-git-send-email-vgoyal@redhat.com> References: <1251495072-7780-1-git-send-email-vgoyal@redhat.com> Reply-To: device-mapper development Return-path: In-Reply-To: <1251495072-7780-1-git-send-email-vgoyal@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: linux-kernel@vger.kernel.org, jens.axboe@oracle.com Cc: dhaval@linux.vnet.ibm.com, peterz@infradead.org, dm-devel@redhat.com, dpshah@google.com, agk@redhat.com, balbir@linux.vnet.ibm.com, paolo.valente@unimore.it, jmarchan@redhat.com, guijianfeng@cn.fujitsu.com, fernando@oss.ntt.co.jp, mikew@google.com, jmoyer@redhat.com, nauman@google.com, mingo@elte.hu, vgoyal@redhat.com, m-ikeda@ds.jp.nec.com, riel@redhat.com, lizf@cn.fujitsu.com, fchecconi@gmail.com, s-uchida@ap.jp.nec.com, containers@lists.linux-foundation.org, akpm@linux-foundation.org, righi.andrea@gmail.com, torvalds@linux-foundation.org List-Id: dm-devel.ids o Currently one can dispatch requests from multiple queues to the disk. This is true for hardware which supports queuing. So if a disk support queue depth of 31 it is possible that 20 requests are dispatched from queue 1 and then next queue is scheduled in which dispatches more requests. o This multiple queue dispatch introduces issues for accurate accounting of disk time consumed by a particular queue. For example, if one async queue is scheduled in, it can dispatch 31 requests to the disk and then it will be expired and a new sync queue might get scheduled in. These 31 requests might take a long time to finish but this time is never accounted to the async queue which dispatched these requests. o This patch introduces the functionality where we wait for all the requests to finish from previous queue before next queue is scheduled in. That way a queue is more accurately accounted for disk time it has consumed. Note this still does not take care of errors introduced by disk write caching. o Because above behavior can result in reduced throughput, this behavior will be enabled only if user sets "fairness" tunable to 1. o This patch helps in achieving more isolation between reads and buffered writes in different cgroups. buffered writes typically utilize full queue depth and then expire the queue. On the contarary, sequential reads typicaly driver queue depth of 1. So despite the fact that writes are using more disk time it is never accounted to write queue because we don't wait for requests to finish after dispatching these. This patch helps do more accurate accounting of disk time, especially for buffered writes hence providing better fairness hence better isolation between two cgroups running read and write workloads. Signed-off-by: Vivek Goyal --- block/cfq-iosched.c | 1 + block/elevator-fq.c | 21 ++++++++++++++++++++- block/elevator-fq.h | 10 +++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 11ae473..52c4710 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2123,6 +2123,7 @@ static struct elv_fs_entry cfq_attrs[] = { ELV_ATTR(slice_async), #ifdef CONFIG_GROUP_IOSCHED ELV_ATTR(group_idle), + ELV_ATTR(fairness), #endif __ATTR_NULL }; diff --git a/block/elevator-fq.c b/block/elevator-fq.c index 6ea5be4..840b73b 100644 --- a/block/elevator-fq.c +++ b/block/elevator-fq.c @@ -681,6 +681,8 @@ SHOW_FUNCTION(elv_slice_sync_show, efqd->elv_slice[1], 1); EXPORT_SYMBOL(elv_slice_sync_show); SHOW_FUNCTION(elv_slice_async_show, efqd->elv_slice[0], 1); EXPORT_SYMBOL(elv_slice_async_show); +SHOW_FUNCTION(elv_fairness_show, efqd->fairness, 0); +EXPORT_SYMBOL(elv_fairness_show); #undef SHOW_FUNCTION #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ @@ -705,6 +707,8 @@ STORE_FUNCTION(elv_slice_sync_store, &efqd->elv_slice[1], 1, UINT_MAX, 1); EXPORT_SYMBOL(elv_slice_sync_store); STORE_FUNCTION(elv_slice_async_store, &efqd->elv_slice[0], 1, UINT_MAX, 1); EXPORT_SYMBOL(elv_slice_async_store); +STORE_FUNCTION(elv_fairness_store, &efqd->fairness, 0, 1, 0); +EXPORT_SYMBOL(elv_fairness_store); #undef STORE_FUNCTION void elv_schedule_dispatch(struct request_queue *q) @@ -2271,6 +2275,17 @@ void *elv_select_ioq(struct request_queue *q, int force) } expire: + if (efqd->fairness && !force && ioq && ioq->dispatched) { + /* + * If there are request dispatched from this queue, don't + * dispatch requests from new queue till all the requests from + * this queue have completed. + */ + elv_log_ioq(efqd, ioq, "select: wait for requests to finish" + " disp=%lu", ioq->dispatched); + ioq = NULL; + goto keep_queue; + } elv_slice_expired(q); new_queue: ioq = elv_set_active_ioq(q, new_ioq); @@ -2386,6 +2401,10 @@ void elv_ioq_completed_request(struct request_queue *q, struct request *rq) goto done; } + /* Wait for requests to finish from this queue */ + if (efqd->fairness && elv_ioq_nr_dispatched(ioq)) + goto done; + /* Expire the queue */ elv_slice_expired(q); goto done; @@ -2396,7 +2415,7 @@ void elv_ioq_completed_request(struct request_queue *q, struct request *rq) * If this is the last queue in the group and we did not * decide to idle on queue, idle on group. */ - if (elv_iog_should_idle(ioq) && !ioq->dispatched + if (elv_iog_should_idle(ioq) && !elv_ioq_nr_dispatched(ioq) && !timer_pending(&efqd->idle_slice_timer)) { /* * If queue has used up its slice, wait for the diff --git a/block/elevator-fq.h b/block/elevator-fq.h index 0a34c7f..b9f3fc7 100644 --- a/block/elevator-fq.h +++ b/block/elevator-fq.h @@ -180,6 +180,12 @@ struct elv_fq_data { /* Fallback dummy ioq for extreme OOM conditions */ struct io_queue oom_ioq; + + /* + * If set to 1, waits for all request completions from current + * queue before new queue is scheduled in + */ + unsigned int fairness; }; /* Logging facilities. */ @@ -437,7 +443,9 @@ extern ssize_t elv_slice_sync_store(struct elevator_queue *q, const char *name, extern ssize_t elv_slice_async_show(struct elevator_queue *q, char *name); extern ssize_t elv_slice_async_store(struct elevator_queue *q, const char *name, size_t count); - +extern ssize_t elv_fairness_show(struct elevator_queue *q, char *name); +extern ssize_t elv_fairness_store(struct elevator_queue *q, const char *name, + size_t count); /* Functions used by elevator.c */ extern struct elv_fq_data *elv_alloc_fq_data(struct request_queue *q, struct elevator_queue *e); -- 1.6.0.6