From patchwork Thu Nov 9 18:49:55 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: 10051669 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 3535760631 for ; Thu, 9 Nov 2017 18:50:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28E5D2B064 for ; Thu, 9 Nov 2017 18:50:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D8EF29AA1; Thu, 9 Nov 2017 18:50:08 +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 B30F429AA1 for ; Thu, 9 Nov 2017 18:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752867AbdKISuG (ORCPT ); Thu, 9 Nov 2017 13:50:06 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:7504 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752790AbdKISuE (ORCPT ); Thu, 9 Nov 2017 13:50:04 -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=1510253405; x=1541789405; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ePfnQWdygiAEx5tRihC2z9fikv25Vrv8xzYXtPD1NC8=; b=QTECS+nPCflZ1rzyIlvkhGqbhAjR9/yB0ydyGbmMyxvPLBkpCWTpG+pB JvrlUTVNR7KAXXB2CjsHG3ito33B9z49524j47b5BULpGV+rVoVnHITZT aAGKaPs502JvP+5jtM0OCwORJiKL29hbY5bQs3in5BIRbyD19HNFOX/7s ZaTnlh8aY75qoTkMrufJqKfcoj5+HPWMu0xIreTa8ggXWqkI6bnx9SpCO c2w+FV7ycgInj8fsOtZ9mvwGjZRbbzJNT+ODoIGj43Z2mq0+M+m+4JxZN lNy+SxQL/LcDVQIcdJkRHQZzidOu+gkMiJyynv19Jk2joYlHekpkfGJ3L A==; X-IronPort-AV: E=Sophos;i="5.44,370,1505750400"; d="scan'208";a="61801481" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Nov 2017 02:50:04 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 09 Nov 2017 10:47:26 -0800 Received: from unknown (HELO MILHUBIP03.sdcorp.global.sandisk.com) ([10.177.9.96]) by uls-op-cesaip02.wdc.com with ESMTP; 09 Nov 2017 10:50:03 -0800 Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Thu, 9 Nov 2017 10:50:02 -0800 X-AuditID: 0ab10959-41c5898000002c97-f3-5a04a359c7ec Received: from thinkpad-bart.int.fusionio.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 23.AE.11415.953A40A5; Thu, 9 Nov 2017 10:50:01 -0800 (PST) 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 v12 3/7] block: Introduce BLK_MQ_REQ_PREEMPT Date: Thu, 9 Nov 2017 10:49:55 -0800 Message-ID: <20171109184959.4617-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171109184959.4617-1-bart.vanassche@wdc.com> References: <20171109184959.4617-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLJMWRmVeSWpSXmKPExsXCtZGTTTdyMUuUwY53Ghar7/azWVz684XR YuXqo0wWj7tmsFrsvaVt0X19B5vF8uP/mCyWzGpmsjg0GUgsfLGJ2YHL4/LZUo+J6/k8dt9s YPN4eYnD4+PTWywe7/ddZfPYfLra4/MmOY/2A91MAZxRXDYpqTmZZalF+nYJXBmvVu9kK/gh VNG75zpLA+M9/i5GTg4JAROJ9j0NjF2MXBxCAisZJTYs2M8EkmAT0JM4NW8fmC0ioCDR83sl G4jNLPCGSeLhN0kQW1jARuLKw4msIDaLgKrEupY/7CA2r4CVxLx/PUwQC+Ql1r69xwhicwpY S/zdMxdoDgfQMiuJ3fd5JjByL2BkWMUolpuZU5ybnllgaKhXnJiXklmcrZecn7uJERJgkTsY n040P8TIxMEp1cBos9Xm0x8mz4M7Lj9W/lkqe1Fo19esJNt1Z8p6jJftq9FqLXwTvXPtp3mX +HZ80z/uxntf4/abAxXiqizy8o56m1x2fXpp/nVKUvT0aVezbtmZs/Nf+d+W0ypUvPHI/sj8 u9YLdig/mvyWnyGTs2ZHXFF+gLJnHOsNbb+CzLns9dwd/rE7GY8osRRnJBpqMRcVJwIA18Mv VOABAAA= 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 Tested-by: Oleksandr Natalenko 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 0f7093dfc010..17eed16a6e04 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1263,6 +1263,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) { @@ -1444,7 +1446,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 2b7d95b2cdfb..2c7ceb34a016 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -291,6 +291,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 4ae987c2352c..82b56609736a 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -212,6 +212,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,