From patchwork Sun Mar 26 02:18:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Bates X-Patchwork-Id: 9644929 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 4A69C6020B for ; Sun, 26 Mar 2017 02:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44100205F6 for ; Sun, 26 Mar 2017 02:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38B5320700; Sun, 26 Mar 2017 02:18:27 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 D0BD3205FD for ; Sun, 26 Mar 2017 02:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751257AbdCZCSX (ORCPT ); Sat, 25 Mar 2017 22:18:23 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34002 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbdCZCSX (ORCPT ); Sat, 25 Mar 2017 22:18:23 -0400 Received: by mail-it0-f67.google.com with SMTP id z70so5174681itb.1 for ; Sat, 25 Mar 2017 19:18:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wLS0BijeWbFMXfpMTa80HWEhjzb/5PaCIB5ROdRlhz0=; b=s5K4i8QNavdwagOoGcEPhwKbJhi4uD+beZTMX4JHjmi2vZVBgjPeZINcvgEH6k132F 9utkbvglDHbRnspyzLyt3YCmi5N2AnYGj5Y9FJGkqDlao6D6rhd4ztkuAFn/IdQ82oiV qV4a4rGzXz5NzuCW89cTe+l/y0pEcKPXtdHy5zb2Pgm/H/cUVNbtG5vDTte8NETOt8hZ OeWF5CYsWyw//ET1X9q6uWhdnho4+rMPu0eExWFkY0p/IEDaP6Zi36Xj+Rf445AbzDwU UsAw5EVDdfUjaOCNhNg61fMdZd9AJE1LUrjvC1OWxZiLUrJOfEDsf7ozcs+V+e1mo58+ rF6Q== X-Gm-Message-State: AFeK/H3Cqrq/47APwbhwOVZQAoPgff0BcDEkiHDzkSbAruvt1ueSfAIpFDH23rCSZ5g0ow== X-Received: by 10.107.183.66 with SMTP id h63mr15339937iof.60.1490494701725; Sat, 25 Mar 2017 19:18:21 -0700 (PDT) Received: from ubuntu64-batesste.cn.shawcable.net (S0106001cf0c4cfac.cn.shawcable.net. [70.65.242.90]) by smtp.gmail.com with ESMTPSA id p6sm3533797iof.12.2017.03.25.19.18.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Mar 2017 19:18:21 -0700 (PDT) From: sbates@raithlin.com To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Damien.LeMoal@wdc.com, osandov@osandov.com, sbates@raithlin.com Subject: [PATCH 2/2] blk-stat: add a poll_size value to the request_queue struct Date: Sat, 25 Mar 2017 20:18:12 -0600 Message-Id: <1490494692-2416-3-git-send-email-sbates@raithlin.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490494692-2416-1-git-send-email-sbates@raithlin.com> References: <1490494692-2416-1-git-send-email-sbates@raithlin.com> 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 From: Stephen Bates In order to bucket IO for the polling algorithm we use a sysfs entry to set the filter value. It is signed and we will use that as follows: 0 : No filtering. All IO are considered in stat generation > 0 : Filtering based on IO of exactly this size only. < 0 : Filtering based on IO less than or equal to -1 time this value. Use this member to implement a new bucket function for the io polling stats. Signed-off-by: Stephen Bates --- block/blk-mq.c | 17 +++++++++++++++-- block/blk-sysfs.c | 30 ++++++++++++++++++++++++++++++ include/linux/blkdev.h | 1 + 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 5ff66f2..5ea9481 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2327,6 +2327,18 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set, blk_mq_sysfs_register(q); } +int blk_mq_poll_stats_bucket(const struct request *rq) +{ + int val = rq->q->poll_size; + + if ((val == 0) || + (val > 0 && blk_rq_bytes(rq) == val) || + (val < 0 && blk_rq_bytes(rq) <= -val)) + return (int)rq_data_dir(rq); + + return -1; +} + struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, struct request_queue *q) { @@ -2338,7 +2350,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, goto err_exit; q->poll_cb = blk_stat_alloc_callback(blk_mq_poll_stats_fn, - blk_stat_rq_ddir, 2, q); + blk_mq_poll_stats_bucket, 2, q); if (!q->poll_cb) goto err_exit; @@ -2387,9 +2399,10 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->nr_requests = set->queue_depth; /* - * Default to classic polling + * Default to classic polling. Default to considering all IO. */ q->poll_nsec = -1; + q->poll_size = 0; if (set->ops->complete) blk_queue_softirq_done(q, set->ops->complete); diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index fa831cb..000d5db 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -394,6 +394,29 @@ static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page, return count; } +static ssize_t queue_poll_size_show(struct request_queue *q, char *page) +{ + return sprintf(page, "%d\n", q->poll_size); +} + +static ssize_t queue_poll_size_store(struct request_queue *q, const char *page, + size_t count) +{ + int err, val; + + if (!q->mq_ops || !q->mq_ops->poll) + return -EINVAL; + + err = kstrtoint(page, 10, &val); + if (err < 0) + return err; + + q->poll_size = val; + + return count; +} + + static ssize_t queue_poll_show(struct request_queue *q, char *page) { return queue_var_show(test_bit(QUEUE_FLAG_POLL, &q->queue_flags), page); @@ -654,6 +677,12 @@ static struct queue_sysfs_entry queue_poll_entry = { .store = queue_poll_store, }; +static struct queue_sysfs_entry queue_poll_size_entry = { + .attr = {.name = "io_poll_size", .mode = S_IRUGO | S_IWUSR }, + .show = queue_poll_size_show, + .store = queue_poll_size_store, +}; + static struct queue_sysfs_entry queue_poll_delay_entry = { .attr = {.name = "io_poll_delay", .mode = S_IRUGO | S_IWUSR }, .show = queue_poll_delay_show, @@ -710,6 +739,7 @@ static struct attribute *default_attrs[] = { &queue_dax_entry.attr, &queue_wb_lat_entry.attr, &queue_poll_delay_entry.attr, + &queue_poll_size_entry.attr, NULL, }; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1a7dc42..7ff5388 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -517,6 +517,7 @@ struct request_queue { unsigned int rq_timeout; int poll_nsec; + int poll_size; struct blk_stat_callback *poll_cb; struct blk_rq_stat poll_stat[2];