From patchwork Thu Mar 9 13:16:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9613393 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 EFC11604DD for ; Thu, 9 Mar 2017 13:42:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD99A285E4 for ; Thu, 9 Mar 2017 13:42:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D290D28604; Thu, 9 Mar 2017 13:42:32 +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=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 8949D285E4 for ; Thu, 9 Mar 2017 13:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754762AbdCINmb (ORCPT ); Thu, 9 Mar 2017 08:42:31 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:44573 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753753AbdCINmb (ORCPT ); Thu, 9 Mar 2017 08:42:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MKMFY50qfGDsM3tj10Si2er1hl+50FYfTHmeWOULu/s=; b=XFQaK+ez2UgFQpZS2K0WpJdNR FgPmspcqQNjiaHvr8SxIlpRlVDP6TZk6rBJ1+2RKAlGPu7RqQCmPOM6d6KQLSyUEhJVCmn2nD9HqN N8Nq5AP1Eovk47IQ80lkJ+lUvzDEnBN6dfwM6IDPnWubhQti8Is1aURrikvPjmLyEwa+1i9E4pCRV GFfh/RpRSmTl86zarWkOSfxMKv3hosXu+AdMGztc3vBtxdwzkOZCgFEjVTwOct4TIYbD32M1C5slx KTJoOLDi8XdCRKJq16uizUdNvaXcuw28LlGFD+JD/ZPHtmm8AYjazWc4oRD/0ctc2fijjkuosAwqg jvTmvUY8A==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1clxwN-0001My-Eh; Thu, 09 Mar 2017 13:17:13 +0000 From: Sagi Grimberg To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH rfc 04/10] block: Add a non-selective polling interface Date: Thu, 9 Mar 2017 15:16:36 +0200 Message-Id: <1489065402-14757-5-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489065402-14757-1-git-send-email-sagi@grimberg.me> References: <1489065402-14757-1-git-send-email-sagi@grimberg.me> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For a server/target appliance mode where we don't necessarily care about specific IOs but rather want to poll opportunisticly, it is useful to have a non-selective polling interface. Expose a blk_poll_batch for a batched blkdev polling interface so our nvme target (and others) can use. Signed-off-by: Sagi Grimberg Reviewed-by: Johannes Thumshirn --- block/blk-mq.c | 14 ++++++++++++++ include/linux/blk-mq.h | 2 ++ include/linux/blkdev.h | 1 + 3 files changed, 17 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index b2fd175e84d7..1962785b571a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2911,6 +2911,20 @@ bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie) } EXPORT_SYMBOL_GPL(blk_mq_poll); +int blk_mq_poll_batch(struct request_queue *q, unsigned int batch) +{ + struct blk_mq_hw_ctx *hctx; + + if (!q->mq_ops || !q->mq_ops->poll_batch) + return 0; + + hctx = blk_mq_map_queue(q, smp_processor_id()); + return q->mq_ops->poll_batch(hctx, batch); +} +EXPORT_SYMBOL_GPL(blk_mq_poll_batch); + + + void blk_mq_disable_hotplug(void) { mutex_lock(&all_q_mutex); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index b296a9006117..e1f33cad3067 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -100,6 +100,7 @@ typedef void (busy_iter_fn)(struct blk_mq_hw_ctx *, struct request *, void *, typedef void (busy_tag_iter_fn)(struct request *, void *, bool); typedef int (poll_fn)(struct blk_mq_hw_ctx *, unsigned int); typedef int (map_queues_fn)(struct blk_mq_tag_set *set); +typedef int (poll_batch_fn)(struct blk_mq_hw_ctx *, unsigned int); struct blk_mq_ops { @@ -117,6 +118,7 @@ struct blk_mq_ops { * Called to poll for completion of a specific tag. */ poll_fn *poll; + poll_batch_fn *poll_batch; softirq_done_fn *complete; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 796016e63c1d..a93507e61a57 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -971,6 +971,7 @@ extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, struct request *, int, rq_end_io_fn *); bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie); +int blk_mq_poll_batch(struct request_queue *q, unsigned int batch); static inline struct request_queue *bdev_get_queue(struct block_device *bdev) {