From patchwork Mon Jun 22 07:44:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 31709 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5M7kcfK012395 for ; Mon, 22 Jun 2009 07:46:38 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 9859C618F73; Mon, 22 Jun 2009 03:46:37 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n5M7kXqA016425 for ; Mon, 22 Jun 2009 03:46:33 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5M7kT2e031945; Mon, 22 Jun 2009 03:46:29 -0400 Received: from song.cn.fujitsu.com (cn.fujitsu.com [222.73.24.84] (may be forged)) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n5M7kFV7030189; Mon, 22 Jun 2009 03:46:16 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 9F13617003F; Mon, 22 Jun 2009 16:18:12 +0800 (CST) Received: from fnst.cn.fujitsu.com (localhost.localdomain [127.0.0.1]) by tang.cn.fujitsu.com (8.13.1/8.13.1) with ESMTP id n5M88CUo006884; Mon, 22 Jun 2009 16:08:13 +0800 Received: from [127.0.0.1] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id D8C0DD4016; Mon, 22 Jun 2009 15:47:36 +0800 (CST) Message-ID: <4A3F3648.7080007@cn.fujitsu.com> Date: Mon, 22 Jun 2009 15:44:08 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Vivek Goyal References: <1245443858-8487-1-git-send-email-vgoyal@redhat.com> <1245443858-8487-21-git-send-email-vgoyal@redhat.com> In-Reply-To: <1245443858-8487-21-git-send-email-vgoyal@redhat.com> X-RedHat-Spam-Score: -0.749 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-loop: dm-devel@redhat.com Cc: dhaval@linux.vnet.ibm.com, snitzer@redhat.com, peterz@infradead.org, dm-devel@redhat.com, dpshah@google.com, jens.axboe@oracle.com, agk@redhat.com, balbir@linux.vnet.ibm.com, paolo.valente@unimore.it, fernando@oss.ntt.co.jp, mikew@google.com, jmoyer@redhat.com, nauman@google.com, m-ikeda@ds.jp.nec.com, lizf@cn.fujitsu.com, fchecconi@gmail.com, akpm@linux-foundation.org, jbaron@redhat.com, linux-kernel@vger.kernel.org, s-uchida@ap.jp.nec.com, righi.andrea@gmail.com, containers@lists.linux-foundation.org Subject: [dm-devel] [PATCH] io-controller: Preempt a non-rt queue if a rt ioq is present in ancestor or sibling groups X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Preempt the ongoing non-rt ioq if there are rt ioqs waiting for dispatching in ancestor or sibling groups. It will give other group's rt ioq an chance to dispatch ASAP. Signed-off-by: Gui Jianfeng --- block/elevator-fq.c | 44 +++++++++++++++++++++++++++++++++++++++----- block/elevator-fq.h | 1 + 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/block/elevator-fq.c b/block/elevator-fq.c index 2ad40eb..80526fd 100644 --- a/block/elevator-fq.c +++ b/block/elevator-fq.c @@ -3245,8 +3245,16 @@ void elv_add_ioq_busy(struct elv_fq_data *efqd, struct io_queue *ioq) elv_mark_ioq_busy(ioq); efqd->busy_queues++; if (elv_ioq_class_rt(ioq)) { + struct io_entity *entity; struct io_group *iog = ioq_to_io_group(ioq); + iog->busy_rt_queues++; + entity = iog->entity.parent; + + for_each_entity(entity) { + iog = io_entity_to_iog(entity); + iog->sub_busy_rt_queues++; + } } #ifdef CONFIG_DEBUG_GROUP_IOSCHED @@ -3290,9 +3298,18 @@ void elv_del_ioq_busy(struct elevator_queue *e, struct io_queue *ioq, elv_clear_ioq_busy(ioq); BUG_ON(efqd->busy_queues == 0); efqd->busy_queues--; + if (elv_ioq_class_rt(ioq)) { + struct io_entity *entity; struct io_group *iog = ioq_to_io_group(ioq); + iog->busy_rt_queues--; + entity = iog->entity.parent; + + for_each_entity(entity) { + iog = io_entity_to_iog(entity); + iog->sub_busy_rt_queues--; + } } elv_deactivate_ioq(efqd, ioq, requeue); @@ -3735,12 +3752,32 @@ int elv_iosched_expire_ioq(struct request_queue *q, int slice_expired, return ret; } +static int check_rt_queue(struct io_queue *ioq) +{ + struct io_group *iog; + struct io_entity *entity; + + iog = ioq_to_io_group(ioq); + + if (iog->busy_rt_queues) + return 1; + + entity = iog->entity.parent; + + for_each_entity(entity) { + iog = io_entity_to_iog(entity); + if (iog->sub_busy_rt_queues) + return 1; + } + + return 0; +} + /* Common layer function to select the next queue to dispatch from */ void *elv_fq_select_ioq(struct request_queue *q, int force) { struct elv_fq_data *efqd = &q->elevator->efqd; struct io_queue *new_ioq = NULL, *ioq = elv_active_ioq(q->elevator); - struct io_group *iog; int slice_expired = 1; if (!elv_nr_busy_ioq(q->elevator)) @@ -3811,12 +3848,9 @@ void *elv_fq_select_ioq(struct request_queue *q, int force) /* * If we have a RT cfqq waiting, then we pre-empt the current non-rt * cfqq. - * - * TODO: This does not seem right across the io groups. Fix it. */ - iog = ioq_to_io_group(ioq); - if (!elv_ioq_class_rt(ioq) && iog->busy_rt_queues) { + if (!elv_ioq_class_rt(ioq) && check_rt_queue(ioq)) { /* * We simulate this as cfqq timed out so that it gets to bank * the remaining of its time slice. diff --git a/block/elevator-fq.h b/block/elevator-fq.h index b3193f8..be6c1af 100644 --- a/block/elevator-fq.h +++ b/block/elevator-fq.h @@ -248,6 +248,7 @@ struct io_group { * non-RT cfqq in service when this value is non-zero. */ unsigned int busy_rt_queues; + unsigned int sub_busy_rt_queues; int deleting; unsigned short iocg_id;