From patchwork Wed Apr 5 17:39:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Bates X-Patchwork-Id: 9665341 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 E084D60364 for ; Wed, 5 Apr 2017 17:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6C2C2817F for ; Wed, 5 Apr 2017 17:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBAF2284BC; Wed, 5 Apr 2017 17:39:34 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 7451728285 for ; Wed, 5 Apr 2017 17:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755193AbdDERj3 (ORCPT ); Wed, 5 Apr 2017 13:39:29 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33017 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754055AbdDERjX (ORCPT ); Wed, 5 Apr 2017 13:39:23 -0400 Received: by mail-wr0-f196.google.com with SMTP id g19so4709359wrb.0 for ; Wed, 05 Apr 2017 10:39: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=duYqU2KVKJPgjrGfaNqDBsbjy+LVtRv+lsyMAuj91Hg=; b=AH8YGolhYlqWtDPUzL0antqRicpFXAJL1ywBmv6PSlDuN5vhG3g6l9QGQXvt8aNx6D 6gPCuSklJRrrTGxBgJO9eZ+/zigKwKvxPvOdWkXEgSleqT8N5zoM8tMuMsBsxiaO8cGI vbvBBX8MisGRDupgZWe75Y+kRt2a4q7Xq5GrTsh855ATlu7mbLJPdlI/PRyee5cXrom7 x/YD+bkd9UIdjWL8QshxZazidGXPd62ZTSArLu343Z67xAq8wpUWIKjkKXXkd9W2LBwX fMNKzZdQgIYfsZX4QpaM3sht5GwuD9f4MeAGmigd+gsMuapnKYZIuX3Z61OaSTzXN7IY 0y6w== X-Gm-Message-State: AFeK/H18xc9MNQpLL4KAi5azOt19GUQT1KwIahFB7ZOFc21w4w4X+OPK C40elQ/OpkYNes+T6FU= X-Received: by 10.28.181.69 with SMTP id e66mr10084047wmf.33.1491413961897; Wed, 05 Apr 2017 10:39:21 -0700 (PDT) Received: from localhost.localdomain (51-171-151-230-dynamic.agg2.lky.bge-rtd.eircom.net. [51.171.151.230]) by smtp.gmail.com with ESMTPSA id 134sm23074375wmj.6.2017.04.05.10.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 10:39: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, sagi@grimberg.me Subject: [PATCH v2 1/2] blk-stat: convert blk-stat bucket callback to signed Date: Wed, 5 Apr 2017 11:39:16 -0600 Message-Id: <1491413957-30885-2-git-send-email-sbates@raithlin.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491413957-30885-1-git-send-email-sbates@raithlin.com> References: <1491413957-30885-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 allow for filtering of IO based on some other properties of the request than direction we allow the bucket function to return an int. If the bucket callback returns a negative do no count it in the stats accumulation. Signed-off-by: Stephen Bates --- block/blk-stat.c | 6 ++++-- block/blk-stat.h | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/block/blk-stat.c b/block/blk-stat.c index e77ec52..dde9d39 100644 --- a/block/blk-stat.c +++ b/block/blk-stat.c @@ -19,7 +19,7 @@ struct blk_queue_stats { bool enable_accounting; }; -unsigned int blk_stat_rq_ddir(const struct request *rq) +int blk_stat_rq_ddir(const struct request *rq) { return rq_data_dir(rq); } @@ -104,6 +104,8 @@ void blk_stat_add(struct request *rq) list_for_each_entry_rcu(cb, &q->stats->callbacks, list) { if (blk_stat_is_active(cb)) { bucket = cb->bucket_fn(rq); + if (bucket < 0) + continue; stat = &this_cpu_ptr(cb->cpu_stat)[bucket]; __blk_stat_add(stat, value); } @@ -135,7 +137,7 @@ static void blk_stat_timer_fn(unsigned long data) struct blk_stat_callback * blk_stat_alloc_callback(void (*timer_fn)(struct blk_stat_callback *), - unsigned int (*bucket_fn)(const struct request *), + int (*bucket_fn)(const struct request *), unsigned int buckets, void *data) { struct blk_stat_callback *cb; diff --git a/block/blk-stat.h b/block/blk-stat.h index 53f08a6..622a62c 100644 --- a/block/blk-stat.h +++ b/block/blk-stat.h @@ -48,9 +48,10 @@ struct blk_stat_callback { /** * @bucket_fn: Given a request, returns which statistics bucket it - * should be accounted under. + * should be accounted under. Return -1 for no bucket for this + * request. */ - unsigned int (*bucket_fn)(const struct request *); + int (*bucket_fn)(const struct request *); /** * @buckets: Number of statistics buckets. @@ -120,7 +121,7 @@ void blk_stat_enable_accounting(struct request_queue *q); * * Return: Data direction of the request, either READ or WRITE. */ -unsigned int blk_stat_rq_ddir(const struct request *rq); +int blk_stat_rq_ddir(const struct request *rq); /** * blk_stat_alloc_callback() - Allocate a block statistics callback. @@ -135,7 +136,7 @@ unsigned int blk_stat_rq_ddir(const struct request *rq); */ struct blk_stat_callback * blk_stat_alloc_callback(void (*timer_fn)(struct blk_stat_callback *), - unsigned int (*bucket_fn)(const struct request *), + int (*bucket_fn)(const struct request *), unsigned int buckets, void *data); /**