From patchwork Sat Mar 18 23:58:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 9632357 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 25F4B602D7 for ; Sun, 19 Mar 2017 00:09:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1701728339 for ; Sun, 19 Mar 2017 00:09:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B5B228346; Sun, 19 Mar 2017 00:09:36 +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 45C8028339 for ; Sun, 19 Mar 2017 00:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751275AbdCSAJL (ORCPT ); Sat, 18 Mar 2017 20:09:11 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:41625 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbdCSAJI (ORCPT ); Sat, 18 Mar 2017 20:09:08 -0400 Received: from [172.16.2.183] (50-225-59-10-static.hfc.comcastbusiness.net [50.225.59.10]) (using SSLv3 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nab) by linux-iscsi.org (Postfix) with ESMTPSA id 0D7E840B05; Sat, 18 Mar 2017 23:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1489881512; bh=3N5iQU9fcF9AbFnCgs2FbVbY+4J8B/R hlt6rTu382qY=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To: References:Content-Type:Mime-Version:Content-Transfer-Encoding; b=L1yYTiLqiAdjM2HPvLsjpMuSLrZQLTqSYu1XYO5tE50PeAQOdFSrSvSXO9Gd/Nv2Z nszgpDDKmSDVlXxgVnmbJZeREIMhzDyr3bcXapojjM9Z/aLF8unbliWUh6V+evllaI9 nSynTrl65zmJ11DfACLSpeyriXgAfGMQbMjPyfo= Message-ID: <1489881481.27336.23.camel@haakon3.risingtidesystems.com> Subject: Re: [PATCH rfc 10/10] target: Use non-selective polling From: "Nicholas A. Bellinger" To: Sagi Grimberg Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, target-devel@vger.kernel.org Date: Sat, 18 Mar 2017 16:58:01 -0700 In-Reply-To: <1489065402-14757-11-git-send-email-sagi@grimberg.me> References: <1489065402-14757-1-git-send-email-sagi@grimberg.me> <1489065402-14757-11-git-send-email-sagi@grimberg.me> X-Mailer: Evolution 3.4.4-1 Mime-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hey Sagi, On Thu, 2017-03-09 at 15:16 +0200, Sagi Grimberg wrote: > It doesn't really make sense to do selective polling > because we never care about specific IOs. Non selective > polling can actually help by doing some useful work > while we're submitting a command. > > We ask for a batch of (magic) 4 completions which looks > like a decent network<->backend proportion, if less are > available we'll see less. > > Signed-off-by: Sagi Grimberg > --- > drivers/target/target_core_iblock.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c > index d316ed537d59..00726b6e51c4 100644 > --- a/drivers/target/target_core_iblock.c > +++ b/drivers/target/target_core_iblock.c > @@ -757,6 +757,7 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, > } > > iblock_submit_bios(&list); > + blk_mq_poll_batch(bdev_get_queue(IBLOCK_DEV(dev)->ibd_bd), 4); > iblock_complete_cmd(cmd); > return 0; > Let's make 'batch' into a backend specific attribute so it can be changed on-the-fly per device, instead of a hard-coded value. Here's a quick patch to that end. Feel free to fold it into your series. Beyond that: Acked-by: Nicholas Bellinger From c2c2a6185fc92132f61beb1708adbef9ea3995e9 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Sat, 18 Mar 2017 20:29:05 +0000 Subject: [PATCH] target/iblock: Add poll_batch attribute Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_iblock.c | 65 ++++++++++++++++++++++++++++++++--- drivers/target/target_core_iblock.h | 2 ++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 00726b6..9396a60 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -114,6 +115,7 @@ static int iblock_configure_device(struct se_device *dev) goto out_free_bioset; } ib_dev->ibd_bd = bd; + ib_dev->poll_batch = IBLOCK_POLL_BATCH; q = bdev_get_queue(bd); @@ -757,7 +759,8 @@ static ssize_t iblock_show_configfs_dev_params(struct se_device *dev, char *b) } iblock_submit_bios(&list); - blk_mq_poll_batch(bdev_get_queue(IBLOCK_DEV(dev)->ibd_bd), 4); + blk_mq_poll_batch(bdev_get_queue(IBLOCK_DEV(dev)->ibd_bd), + IBLOCK_DEV(dev)->poll_batch); iblock_complete_cmd(cmd); return 0; @@ -840,7 +843,38 @@ static bool iblock_get_write_cache(struct se_device *dev) return test_bit(QUEUE_FLAG_WC, &q->queue_flags); } -static const struct target_backend_ops iblock_ops = { +static ssize_t iblock_poll_batch_show(struct config_item *item, char *page) +{ + struct se_dev_attrib *da = container_of(to_config_group(item), + struct se_dev_attrib, da_group); + struct iblock_dev *ibd = container_of(da->da_dev, + struct iblock_dev, dev); + + return snprintf(page, PAGE_SIZE, "%u\n", ibd->poll_batch); +} + +static ssize_t iblock_poll_batch_store(struct config_item *item, const char *page, + size_t count) +{ + struct se_dev_attrib *da = container_of(to_config_group(item), + struct se_dev_attrib, da_group); + struct iblock_dev *ibd = container_of(da->da_dev, + struct iblock_dev, dev); + u32 val; + int ret; + + ret = kstrtou32(page, 0, &val); + if (ret < 0) + return ret; + + ibd->poll_batch = val; + return count; +} +CONFIGFS_ATTR(iblock_, poll_batch); + +static struct configfs_attribute **iblock_attrs; + +static struct target_backend_ops iblock_ops = { .name = "iblock", .inquiry_prod = "IBLOCK", .inquiry_rev = IBLOCK_VERSION, @@ -860,17 +894,40 @@ static bool iblock_get_write_cache(struct se_device *dev) .get_io_min = iblock_get_io_min, .get_io_opt = iblock_get_io_opt, .get_write_cache = iblock_get_write_cache, - .tb_dev_attrib_attrs = sbc_attrib_attrs, + .tb_dev_attrib_attrs = NULL, }; static int __init iblock_module_init(void) { - return transport_backend_register(&iblock_ops); + int rc, i, len = 0; + + for (i = 0; sbc_attrib_attrs[i] != NULL; i++) { + len += sizeof(struct configfs_attribute *); + } + len += sizeof(struct configfs_attribute *) * 2; + + iblock_attrs = kzalloc(len, GFP_KERNEL); + if (!iblock_attrs) + return -ENOMEM; + + for (i = 0; sbc_attrib_attrs[i] != NULL; i++) { + iblock_attrs[i] = sbc_attrib_attrs[i]; + } + iblock_attrs[i] = &iblock_attr_poll_batch; + iblock_ops.tb_dev_attrib_attrs = iblock_attrs; + + rc = transport_backend_register(&iblock_ops); + if (rc) { + kfree(iblock_attrs); + return rc; + } + return 0; } static void __exit iblock_module_exit(void) { target_backend_unregister(&iblock_ops); + kfree(iblock_attrs); } MODULE_DESCRIPTION("TCM IBLOCK subsystem plugin"); diff --git a/drivers/target/target_core_iblock.h b/drivers/target/target_core_iblock.h index 718d3fc..308b5c2 100644 --- a/drivers/target/target_core_iblock.h +++ b/drivers/target/target_core_iblock.h @@ -8,6 +8,7 @@ #define IBLOCK_MAX_CDBS 16 #define IBLOCK_LBA_SHIFT 9 +#define IBLOCK_POLL_BATCH 4 struct iblock_req { atomic_t pending; @@ -23,6 +24,7 @@ struct iblock_dev { struct bio_set *ibd_bio_set; struct block_device *ibd_bd; bool ibd_readonly; + unsigned int poll_batch; } ____cacheline_aligned; #endif /* TARGET_CORE_IBLOCK_H */