From patchwork Mon Oct 30 22:42:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10033381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E73906039A for ; Mon, 30 Oct 2017 22:42:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4C92898D for ; Mon, 30 Oct 2017 22:42:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF0042898F; Mon, 30 Oct 2017 22:42:22 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 5EC7028992 for ; Mon, 30 Oct 2017 22:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752734AbdJ3WmU (ORCPT ); Mon, 30 Oct 2017 18:42:20 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:50774 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521AbdJ3WmJ (ORCPT ); Mon, 30 Oct 2017 18:42:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1509403330; x=1540939330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ZbWXXSK5rIx7gyeOrzGCEebJ5Z/G9uXj7MtCvy7Bl9c=; b=d3FYHOok9w/bY1KxBi4a7i59wR+Ff9I4ukojxGUmgxenT/v4qSK7Xvux Jlkx9ay8zU/jbc96zfA4hW7kaGU1qHJG5CUT0QTKNaAJq7/q0j7SI/PkI RTOOXq0RKl/Ur2rTgw+zJkLHo6pm1+t8MLhenOtK5P4jTVARZmvDEEoFQ HE7Sw6SrxI4PB1icbIvmZE/Kgx5O2cDssWf97KOJlAlCCkugotPb3PfZo SweNzeVWKMJeFWIgYQ2IniM/7a+ksHZZpKQ41d5a63AlYRZgU7CT9LwKk GtW5wF4FVo8WtF6Fh0bre0Ws4HZEirimVY+KGjXRCAZ5+qjO2vJwqFQbk w==; X-IronPort-AV: E=Sophos;i="5.44,321,1505750400"; d="scan'208";a="60181976" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 31 Oct 2017 06:42:09 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 30 Oct 2017 15:40:17 -0700 Received: from unknown (HELO MILHUBIP04.sdcorp.global.sandisk.com) ([10.177.9.97]) by uls-op-cesaip02.wdc.com with ESMTP; 30 Oct 2017 15:42:08 -0700 Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Mon, 30 Oct 2017 15:42:07 -0700 X-AuditID: 0ab10959-41c5898000002c97-93-59f7aabf8391 Received: from thinkpad-bart.int.fusionio.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 41.BD.11415.FBAA7F95; Mon, 30 Oct 2017 15:42:07 -0700 (PDT) From: Bart Van Assche To: Jens Axboe CC: , , "Christoph Hellwig" , "Martin K . Petersen" , Oleksandr Natalenko , Ming Lei , Martin Steigerwald , "Bart Van Assche" , Johannes Thumshirn Subject: [PATCH v11 3/7] block: Introduce BLK_MQ_REQ_PREEMPT Date: Mon, 30 Oct 2017 15:42:01 -0700 Message-ID: <20171030224205.25212-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030224205.25212-1-bart.vanassche@wdc.com> References: <20171030224205.25212-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHJMWRmVeSWpSXmKPExsXCtZEjRXf/qu+RBssfq1usvtvPZnHpzxdG i5WrjzJZPO6awWqx95a2Rff1HWwWy4//Y7JYMquZyeLQZCCx8MUmZgcuj8tnSz0mrufz2H2z gc3j5SUOj49Pb7F4vN93lc1j8+lqj8+b5DzaD3QzBXBGcdmkpOZklqUW6dslcGVcP/CBvWCv UEXTw8WsDYwr+LsYOTkkBEwkZh3ZztbFyMUhJLCaUWJl32lGkASbgJ7EqXn7mEBsEQEFiZ7f K9lAbGaBN0wSD79JgtjCAjYS894+ZQWxWQRUJY6+bWEGsXkFrCVm3bjMDrFAXuL9gvtgMzmB 6hdt+g4WFwKq2TVxOtMERu4FjAyrGMVyM3OKc9MzCwwN9YoT81Iyi7P1kvNzNzGCQ4wzcgfj 04nmhxiZODilGhi33FvRavdtKcPDkE1cDW5TNouaaexI83g2c/ej51MM2hqENmb97H3LsyrS PET00uGX097tX8I0vf7mgXW5N190dfXNyjo+J2nXhwmVHYsCVY9uW3U6MrR16qJLH5dlbHp6 uOpR/MzdO2VNM8pVBbZ1iz0/vua0PNvpNcJ/JxTyZXMur5V+mrBfVYmlOCPRUIu5qDgRAE8Z Pd7hAQAA 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 Set RQF_PREEMPT if BLK_MQ_REQ_PREEMPT is passed to blk_get_request_flags(). Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Tested-by: Martin Steigerwald Cc: Christoph Hellwig Cc: Ming Lei Cc: Johannes Thumshirn --- block/blk-core.c | 4 +++- block/blk-mq.c | 2 ++ include/linux/blk-mq.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 396104c05b38..48f18f5e2e16 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1262,6 +1262,8 @@ static struct request *__get_request(struct request_list *rl, unsigned int op, blk_rq_set_rl(rq, rl); rq->cmd_flags = op; rq->rq_flags = rq_flags; + if (flags & BLK_MQ_REQ_PREEMPT) + rq->rq_flags |= RQF_PREEMPT; /* init elvpriv */ if (rq_flags & RQF_ELVPRIV) { @@ -1443,7 +1445,7 @@ struct request *blk_get_request_flags(struct request_queue *q, unsigned int op, struct request *req; WARN_ON_ONCE(op & REQ_NOWAIT); - WARN_ON_ONCE(flags & ~BLK_MQ_REQ_NOWAIT); + WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PREEMPT)); if (q->mq_ops) { req = blk_mq_alloc_request(q, op, flags); diff --git a/block/blk-mq.c b/block/blk-mq.c index 59b7de6b616b..6a025b17caac 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -290,6 +290,8 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, rq->q = data->q; rq->mq_ctx = data->ctx; rq->cmd_flags = op; + if (data->flags & BLK_MQ_REQ_PREEMPT) + rq->rq_flags |= RQF_PREEMPT; if (blk_queue_io_stat(data->q)) rq->rq_flags |= RQF_IO_STAT; /* do not touch atomic flags, it needs atomic ops against the timer */ diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index e5e6becd57d3..22c7f36745fc 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -213,6 +213,7 @@ enum { BLK_MQ_REQ_NOWAIT = (1 << 0), /* return when out of requests */ BLK_MQ_REQ_RESERVED = (1 << 1), /* allocate from reserved pool */ BLK_MQ_REQ_INTERNAL = (1 << 2), /* allocate internal/sched tag */ + BLK_MQ_REQ_PREEMPT = (1 << 3), /* set RQF_PREEMPT */ }; struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,