From patchwork Tue Nov 20 01:52:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10689765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC27D13B5 for ; Tue, 20 Nov 2018 01:52:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DEFD29FFD for ; Tue, 20 Nov 2018 01:52:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91FF22A031; Tue, 20 Nov 2018 01:52:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CCC429FF6 for ; Tue, 20 Nov 2018 01:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732645AbeKTMTV (ORCPT ); Tue, 20 Nov 2018 07:19:21 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:40409 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbeKTMTV (ORCPT ); Tue, 20 Nov 2018 07:19:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1542678765; x=1574214765; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KdPQ51DBHO9uAZOn50XLl5Jxrk4reQVutmFr+jpaWRY=; b=XLigWByWi6R6QckkB7I4NPSywBCM9DhKPNF0AjEiMOHncR1yZqK3YzgE HxN76zEDxmMeMItljF+YnwGCqYBZ120ZKblEs6uwLV+x3VNIKIzRT/Jx/ tnYVLyFDK3YTO9tfw9Xwmx3M5K6Sr/FEprAyZYmTxPp6KvD2dHIEoACIB i3HRay5q7si71/qwXTDtAgZXj2MMQfMSjNx700ricoMRa1+qOfXZpHYEK pZfcqtPVpBhUSUuL/pPOFWpZHtZ6Tta6Gn2EwMS69jNhHb05OlGFKDmy9 lhdm6o/iXsOHYpw9Np3si7uPqcYrfqBxin347/chLOUzpvKtxRYAuzOSS A==; X-IronPort-AV: E=Sophos;i="5.56,255,1539619200"; d="scan'208";a="95813256" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Nov 2018 09:52:44 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Nov 2018 17:35:59 -0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Nov 2018 17:52:42 -0800 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe Cc: Adam Manzanares , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 1/6] aio: Comment use of IOCB_FLAG_IOPRIO aio flag Date: Tue, 20 Nov 2018 10:52:33 +0900 Message-Id: <20181120015238.26467-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120015238.26467-1-damien.lemoal@wdc.com> References: <20181120015238.26467-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Comment the use of the IOCB_FLAG_IOPRIO aio flag similarly to the IOCB_FLAG_RESFD flag. Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Signed-off-by: Damien Le Moal --- include/uapi/linux/aio_abi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h index ce43d340f010..8387e0af0f76 100644 --- a/include/uapi/linux/aio_abi.h +++ b/include/uapi/linux/aio_abi.h @@ -50,6 +50,8 @@ enum { * * IOCB_FLAG_RESFD - Set if the "aio_resfd" member of the "struct iocb" * is valid. + * IOCB_FLAG_IOPRIO - Set if the "aio_reqprio" member of the "struct iocb" + * is valid. */ #define IOCB_FLAG_RESFD (1 << 0) #define IOCB_FLAG_IOPRIO (1 << 1) From patchwork Tue Nov 20 01:52:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10689769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A12865A4 for ; Tue, 20 Nov 2018 01:52:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93F0729FF6 for ; Tue, 20 Nov 2018 01:52:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8805129FFD; Tue, 20 Nov 2018 01:52:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1017229FB9 for ; Tue, 20 Nov 2018 01:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732676AbeKTMTY (ORCPT ); Tue, 20 Nov 2018 07:19:24 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:40409 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbeKTMTY (ORCPT ); Tue, 20 Nov 2018 07:19:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1542678767; x=1574214767; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8u6/urnTFpqshHyKlRjyPTXdhxYafyiTOsIsLu1oEtY=; b=owcZLdMVzZmYQ5+JPp16JeQszS+FB9BcgtcWN5C8uKZI/BevQFAmSO5q dHdyNIhQszVaQ0iqv/vCiJltrCeDHKjRa7maRu6QqBCUnRcc+/lAululd dV4D4lMLjO3f/Mt4/x4H4c5wMSSetjwEgiPOgk1GUDtZtyp/i5H6oWHVj /6AAJI4m2PldWg6qf/tGI9DshHg5KXSgpD/hADauWOABZovYDDgy6aftR AkDfSJ1/4hZfuJz2GuGggLqXoOFE3bE+3Xp+tSkT2J94W6yLksPNbhhSD IjkhGWuMREQWHyC2zRylcHtxl79H/mpLO6UaCvoS8FFauz1/nFEiha/tB w==; X-IronPort-AV: E=Sophos;i="5.56,255,1539619200"; d="scan'208";a="95813259" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Nov 2018 09:52:47 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Nov 2018 17:36:02 -0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Nov 2018 17:52:45 -0800 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe Cc: Adam Manzanares , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 2/6] block: Remove bio->bi_ioc Date: Tue, 20 Nov 2018 10:52:34 +0900 Message-Id: <20181120015238.26467-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120015238.26467-1-damien.lemoal@wdc.com> References: <20181120015238.26467-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP bio->bi_ioc is never set so always NULL. Remove references to it in bio_disassociate_task() and in rq_ioc() and delete this field from struct bio. With this change, rq_ioc() always returns current->io_context without the need for a bio argument. Further simplify the code and make it more readable by also removing this helper, which also allows to simplify blk_mq_sched_assign_ioc() by removing its bio argument. Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Adam Manzanares Signed-off-by: Damien Le Moal --- block/bio.c | 4 ---- block/blk-core.c | 2 +- block/blk-mq-sched.c | 4 ++-- block/blk-mq-sched.h | 2 +- block/blk-mq.c | 4 ++-- block/blk.h | 16 ---------------- include/linux/blk_types.h | 3 +-- 7 files changed, 7 insertions(+), 28 deletions(-) diff --git a/block/bio.c b/block/bio.c index 4f4d9884443b..03895cc0d74a 100644 --- a/block/bio.c +++ b/block/bio.c @@ -2027,10 +2027,6 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg) */ void bio_disassociate_task(struct bio *bio) { - if (bio->bi_ioc) { - put_io_context(bio->bi_ioc); - bio->bi_ioc = NULL; - } if (bio->bi_css) { css_put(bio->bi_css); bio->bi_css = NULL; diff --git a/block/blk-core.c b/block/blk-core.c index d6e8ab9ca99d..492648c96992 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -813,7 +813,7 @@ unsigned int blk_plug_queued_count(struct request_queue *q) void blk_init_request_from_bio(struct request *req, struct bio *bio) { - struct io_context *ioc = rq_ioc(bio); + struct io_context *ioc = current->io_context; if (bio->bi_opf & REQ_RAHEAD) req->cmd_flags |= REQ_FAILFAST_MASK; diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index d084f731d104..13b8dc332541 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -31,10 +31,10 @@ void blk_mq_sched_free_hctx_data(struct request_queue *q, } EXPORT_SYMBOL_GPL(blk_mq_sched_free_hctx_data); -void blk_mq_sched_assign_ioc(struct request *rq, struct bio *bio) +void blk_mq_sched_assign_ioc(struct request *rq) { struct request_queue *q = rq->q; - struct io_context *ioc = rq_ioc(bio); + struct io_context *ioc = current->io_context; struct io_cq *icq; spin_lock_irq(&q->queue_lock); diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 7ff5671bf128..0f719c8532ae 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -8,7 +8,7 @@ void blk_mq_sched_free_hctx_data(struct request_queue *q, void (*exit)(struct blk_mq_hw_ctx *)); -void blk_mq_sched_assign_ioc(struct request *rq, struct bio *bio); +void blk_mq_sched_assign_ioc(struct request *rq); void blk_mq_sched_request_inserted(struct request *rq); bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, diff --git a/block/blk-mq.c b/block/blk-mq.c index 32b246ed44c0..636f80b96fa6 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -389,8 +389,8 @@ static struct request *blk_mq_get_request(struct request_queue *q, if (!op_is_flush(data->cmd_flags)) { rq->elv.icq = NULL; if (e && e->type->ops.prepare_request) { - if (e->type->icq_cache && rq_ioc(bio)) - blk_mq_sched_assign_ioc(rq, bio); + if (e->type->icq_cache) + blk_mq_sched_assign_ioc(rq); e->type->ops.prepare_request(rq, bio); rq->rq_flags |= RQF_ELVPRIV; diff --git a/block/blk.h b/block/blk.h index 816a9abb87cd..610948157a5b 100644 --- a/block/blk.h +++ b/block/blk.h @@ -254,22 +254,6 @@ void ioc_clear_queue(struct request_queue *q); int create_task_io_context(struct task_struct *task, gfp_t gfp_mask, int node); -/** - * rq_ioc - determine io_context for request allocation - * @bio: request being allocated is for this bio (can be %NULL) - * - * Determine io_context to use for request allocation for @bio. May return - * %NULL if %current->io_context doesn't exist. - */ -static inline struct io_context *rq_ioc(struct bio *bio) -{ -#ifdef CONFIG_BLK_CGROUP - if (bio && bio->bi_ioc) - return bio->bi_ioc; -#endif - return current->io_context; -} - /** * create_io_context - try to create task->io_context * @gfp_mask: allocation mask diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index dbdbfbd6a987..c0ba1a038ff3 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -174,10 +174,9 @@ struct bio { void *bi_private; #ifdef CONFIG_BLK_CGROUP /* - * Optional ioc and css associated with this bio. Put on bio + * Optional css associated with this bio. Put on bio * release. Read comment on top of bio_associate_current(). */ - struct io_context *bi_ioc; struct cgroup_subsys_state *bi_css; struct blkcg_gq *bi_blkg; struct bio_issue bi_issue; From patchwork Tue Nov 20 01:52:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10689775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E3DA13B5 for ; Tue, 20 Nov 2018 01:52:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0278829FB9 for ; Tue, 20 Nov 2018 01:52:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAE6429FFD; Tue, 20 Nov 2018 01:52:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9837729FB9 for ; Tue, 20 Nov 2018 01:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732688AbeKTMT0 (ORCPT ); Tue, 20 Nov 2018 07:19:26 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:40409 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbeKTMT0 (ORCPT ); Tue, 20 Nov 2018 07:19:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1542678769; x=1574214769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vuBdbepM0Yy0VdI3VUb8R1S5fsJ4V8LQf3FXWW4S2LI=; b=SroPo51zcw3cZ9BXtDcy8QL3asY6Z7E6C6bWFwBV1Gs3uFItKUjKo4CG y2VlBYyw665iqB0g9CQBQPbbtLZKSTXNP+NKnP1zvYIOSFEwVfnN4Rw7w VSbu+Qe/GmZxUHLz++TZmSWfUpmCpC2/tqV66QjLQX5ErfJKQHCIRt5oD Va4mnGZqaXcG/EmxqG2AzkPwNcfuRYAu+DIANV8pz0y4YLOZEPJxcE/mi srqjI9XGdFGCh2bMPryu78YQd5wU1wGBKQNNHxqg1qmBlUWpl2vSKPTLA HUJktxlr5P4rFxQ84yrVoxfv0gluBO+68I+NvxLiGMaE8SR2Tq91TWwfH Q==; X-IronPort-AV: E=Sophos;i="5.56,255,1539619200"; d="scan'208";a="95813269" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Nov 2018 09:52:49 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Nov 2018 17:36:04 -0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Nov 2018 17:52:47 -0800 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe Cc: Adam Manzanares , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 3/6] block: Introduce get_current_ioprio() Date: Tue, 20 Nov 2018 10:52:35 +0900 Message-Id: <20181120015238.26467-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120015238.26467-1-damien.lemoal@wdc.com> References: <20181120015238.26467-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define get_current_ioprio() as an inline helper to obtain the caller I/O priority from its task I/O context. Use this helper in blk_init_request_from_bio() to set a request ioprio. Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Signed-off-by: Damien Le Moal --- block/blk-core.c | 6 +----- include/linux/ioprio.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 492648c96992..4450d3c08f25 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -813,18 +813,14 @@ unsigned int blk_plug_queued_count(struct request_queue *q) void blk_init_request_from_bio(struct request *req, struct bio *bio) { - struct io_context *ioc = current->io_context; - if (bio->bi_opf & REQ_RAHEAD) req->cmd_flags |= REQ_FAILFAST_MASK; req->__sector = bio->bi_iter.bi_sector; if (ioprio_valid(bio_prio(bio))) req->ioprio = bio_prio(bio); - else if (ioc) - req->ioprio = ioc->ioprio; else - req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); + req->ioprio = get_current_ioprio(); req->write_hint = bio->bi_write_hint; blk_rq_bio_prep(req->q, req, bio); } diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 9e30ed6443db..e9bfe6972aed 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -70,6 +70,19 @@ static inline int task_nice_ioclass(struct task_struct *task) return IOPRIO_CLASS_BE; } +/* + * If the calling process has set an I/O priority, use that. Otherwise, return + * the default I/O priority. + */ +static inline int get_current_ioprio(void) +{ + struct io_context *ioc = current->io_context; + + if (ioc) + return ioc->ioprio; + return IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); +} + /* * For inheritance, return the highest of the two given priorities */ From patchwork Tue Nov 20 01:52:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10689779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01C2F16B1 for ; Tue, 20 Nov 2018 01:52:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB14A29FB9 for ; Tue, 20 Nov 2018 01:52:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFE1429FFD; Tue, 20 Nov 2018 01:52:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BFBD29FB9 for ; Tue, 20 Nov 2018 01:52:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732696AbeKTMT3 (ORCPT ); Tue, 20 Nov 2018 07:19:29 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:40409 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbeKTMT3 (ORCPT ); Tue, 20 Nov 2018 07:19:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1542678772; x=1574214772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PqsRyv7c9EpA5+rWoMDfypmdvWAN47Krw7kw/Y2Oin8=; b=ELHz3zVqv5vbsqKH49vDhVmA71FICkhPBWdjg2SAPGLDU0lAqb3jHvsf hQ99k36B9lxxMwvyJWg4/MYmEHO1RAWG30T8VwYOFghbENmMfPMQVNtaG rjhMQWeS21UPRNOtf7QrSETXOpf0l33HznbFamYzOc3COns53OiHTPAUp 0X4YepeWYbLIkRsVMMJbzlcdozkaW9HDoufNWUXgbfOD5YUrs7kFnAANL kLNmXi88cPS89Q2QLN2rSq3LQuJYFab1VDRIW2k8UYpD6TQ4IPFSEYyOU hUW/upYmAv6GYPCfzDSJ8h6SIRLf2ENrsyUcZBVcMYzYygiAPGpsW4RJN g==; X-IronPort-AV: E=Sophos;i="5.56,255,1539619200"; d="scan'208";a="95813285" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Nov 2018 09:52:52 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Nov 2018 17:36:07 -0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Nov 2018 17:52:50 -0800 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe Cc: Adam Manzanares , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 4/6] aio: Fix fallback I/O priority value Date: Tue, 20 Nov 2018 10:52:36 +0900 Message-Id: <20181120015238.26467-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120015238.26467-1-damien.lemoal@wdc.com> References: <20181120015238.26467-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For cases when the application does not specify aio_reqprio for an aio, fallback to use get_current_ioprio() to obtain the task I/O priority last set using ioprio_set() rather than the hardcoded IOPRIO_CLASS_NONE value. Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Adam Manzanares Signed-off-by: Damien Le Moal --- fs/aio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/aio.c b/fs/aio.c index 301e6314183b..b984918be4b7 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1441,7 +1441,7 @@ static int aio_prep_rw(struct kiocb *req, struct iocb *iocb) req->ki_ioprio = iocb->aio_reqprio; } else - req->ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); + req->ki_ioprio = get_current_ioprio(); ret = kiocb_set_rw_flags(req, iocb->aio_rw_flags); if (unlikely(ret)) From patchwork Tue Nov 20 01:52:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10689781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A44255A4 for ; Tue, 20 Nov 2018 01:52:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9692229FFD for ; Tue, 20 Nov 2018 01:52:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89F842A048; Tue, 20 Nov 2018 01:52:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CB3029FFD for ; Tue, 20 Nov 2018 01:52:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732697AbeKTMTb (ORCPT ); Tue, 20 Nov 2018 07:19:31 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:40409 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbeKTMTb (ORCPT ); Tue, 20 Nov 2018 07:19:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1542678774; x=1574214774; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vWI5hiLR1Vd86YclP29pJ4JZOvyQnFq+3CxVZMtcm9I=; b=aFcAAINqumMST8C/o3iE6ZYwRbvIDzpHJbbbTYnaMUC1Z+D5h/YVd7Jd TZyTz9F0ehhI0Bs516CU/DoMYNCUPH4+NGfMB2s7RivxMtw5WXMDsFakQ QFTHDPNgE9lLHnqN1voCzen5q1Kut3TkgM/7SVp2qgdYTPWdVLbeSzmaj wMb236/xMNT1uzqC9VkpM+Xl9iPs6Vndv+Pf67zpNBpyKeMG0t+yHKSEC 76qidQVvrwN2xR7pZenjfIM8pTN14uKGEqA61Oai1nrBX96kFIz7gL2+Y Xhtf6lCw5RLX6D4XHc2EUrSPMFHKuhpBRsWIP4lwzhzQxWlM3zXGjh2JU g==; X-IronPort-AV: E=Sophos;i="5.56,255,1539619200"; d="scan'208";a="95813294" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Nov 2018 09:52:54 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Nov 2018 17:36:09 -0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Nov 2018 17:52:52 -0800 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe Cc: Adam Manzanares , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 5/6] block: prevent merging of requests with different priorities Date: Tue, 20 Nov 2018 10:52:37 +0900 Message-Id: <20181120015238.26467-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120015238.26467-1-damien.lemoal@wdc.com> References: <20181120015238.26467-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Growing in size a high priority request by merging it with a lower priority BIO or request will increase the request execution time. This is the opposite result of the desired effect of high I/O priorities, namely getting low I/O latencies. Prevent merging of requests and BIOs that have different I/O priorities to fix this. Signed-off-by: Damien Le Moal --- block/blk-core.c | 3 --- block/blk-merge.c | 8 ++++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 4450d3c08f25..dde30b08aa14 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -662,7 +662,6 @@ bool bio_attempt_back_merge(struct request_queue *q, struct request *req, req->biotail->bi_next = bio; req->biotail = bio; req->__data_len += bio->bi_iter.bi_size; - req->ioprio = ioprio_best(req->ioprio, bio_prio(bio)); blk_account_io_start(req, false); return true; @@ -686,7 +685,6 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req, req->__sector = bio->bi_iter.bi_sector; req->__data_len += bio->bi_iter.bi_size; - req->ioprio = ioprio_best(req->ioprio, bio_prio(bio)); blk_account_io_start(req, false); return true; @@ -706,7 +704,6 @@ bool bio_attempt_discard_merge(struct request_queue *q, struct request *req, req->biotail->bi_next = bio; req->biotail = bio; req->__data_len += bio->bi_iter.bi_size; - req->ioprio = ioprio_best(req->ioprio, bio_prio(bio)); req->nr_phys_segments = segments + 1; blk_account_io_start(req, false); diff --git a/block/blk-merge.c b/block/blk-merge.c index b1df622cbd85..6be04ef8da5b 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -752,6 +752,9 @@ static struct request *attempt_merge(struct request_queue *q, if (req->write_hint != next->write_hint) return NULL; + if (req->ioprio != next->ioprio) + return NULL; + /* * If we are allowed to merge, then append bio list * from next to rq and release next. merge_requests_fn @@ -807,8 +810,6 @@ static struct request *attempt_merge(struct request_queue *q, */ blk_account_io_merge(next); - req->ioprio = ioprio_best(req->ioprio, next->ioprio); - /* * ownership of bio passed from next to req, return 'next' for * the caller to free @@ -883,6 +884,9 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) if (rq->write_hint != bio->bi_write_hint) return false; + if (rq->ioprio != bio_prio(bio)) + return false; + return true; } From patchwork Tue Nov 20 01:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 10689785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B818F13B5 for ; Tue, 20 Nov 2018 01:52:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9A8D2A031 for ; Tue, 20 Nov 2018 01:52:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CB1D2A048; Tue, 20 Nov 2018 01:52:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D54829FFD for ; Tue, 20 Nov 2018 01:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732700AbeKTMTd (ORCPT ); Tue, 20 Nov 2018 07:19:33 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:40409 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730379AbeKTMTd (ORCPT ); Tue, 20 Nov 2018 07:19:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1542678777; x=1574214777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5eQNOqIzW2mPuqeCDTvKL8q4KeDRbXvNiXn6QDbW7w4=; b=YPr++mYl5L3r9pTKArNvdVG3684K9C0xTIAjjEZjeXyD852FqpKxbP1u 1jgVswlH7RrjaiRcFb4+3mN+EvXFCr6xSjMnnUj1lfQEdQTcAtJzZb5sA 44qyru1CTM1O/PCI9ulZvY7WyVvGrgp3jVsTO959PLiQGvPyM5IxlA6E0 3WIdxfUcvg9O8zJAzI7rB5Vwt2/wDNsNZ6ZFDlgqLxQbO+r+UwEb2i8jP 09wNpiCSbt0L1MgGKaGmpfngbniMhb1mo+Jd7BhIVStSEmhhL78xwPWqV Zrlut2tFIorwiNHqp/xq/bvCGLKceuh5KjGGFF3juVVFWVJAcbE1zw2Fq Q==; X-IronPort-AV: E=Sophos;i="5.56,255,1539619200"; d="scan'208";a="95813298" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Nov 2018 09:52:56 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 19 Nov 2018 17:36:11 -0800 Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 19 Nov 2018 17:52:54 -0800 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe Cc: Adam Manzanares , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 6/6] block: Initialize BIO I/O priority early Date: Tue, 20 Nov 2018 10:52:38 +0900 Message-Id: <20181120015238.26467-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120015238.26467-1-damien.lemoal@wdc.com> References: <20181120015238.26467-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For the synchronous I/O path case (read(), write() etc system calls), a BIO I/O priority is not initialized until the execution of blk_init_request_from_bio() when the BIO is submitted and a request initialized for the BIO execution. This is due to the ki_ioprio field of the struct kiocb defined on stack being always initialized to IOPRIO_CLASS_NONE, regardless of the calling process I/O context ioprio value set with ioprio_set(). This late initialization can result in the BIO being merged to pending requests even when the I/O priorities differ. Fix this by initializing the ki_iopriority field of on stack struct kiocb using the get_current_ioprio() helper, ensuring that all BIOs allocated and submitted for the system call execution see the correct intended I/O priority early. With this, since a BIO I/O priority is always set to the intended effective value for both the sync and async path, blk_init_request_from_bio() can be simplified. Reviewed-by: Christoph Hellwig Reviewed-by: Adam Manzanares Signed-off-by: Damien Le Moal --- block/blk-core.c | 5 +---- include/linux/fs.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index dde30b08aa14..04f5be473638 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -814,10 +814,7 @@ void blk_init_request_from_bio(struct request *req, struct bio *bio) req->cmd_flags |= REQ_FAILFAST_MASK; req->__sector = bio->bi_iter.bi_sector; - if (ioprio_valid(bio_prio(bio))) - req->ioprio = bio_prio(bio); - else - req->ioprio = get_current_ioprio(); + req->ioprio = bio_prio(bio); req->write_hint = bio->bi_write_hint; blk_rq_bio_prep(req->q, req, bio); } diff --git a/include/linux/fs.h b/include/linux/fs.h index c95c0807471f..a1ab233e6469 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2021,7 +2021,7 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) .ki_filp = filp, .ki_flags = iocb_flags(filp), .ki_hint = ki_hint_validate(file_write_hint(filp)), - .ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0), + .ki_ioprio = get_current_ioprio(), }; }