From patchwork Sun Mar 26 02:18:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Bates X-Patchwork-Id: 9644931 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 BCEFC6020B for ; Sun, 26 Mar 2017 02:18:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B45F2205F6 for ; Sun, 26 Mar 2017 02:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A51C920700; Sun, 26 Mar 2017 02:18:42 +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 243E1205F6 for ; Sun, 26 Mar 2017 02:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdCZCSb (ORCPT ); Sat, 25 Mar 2017 22:18:31 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:36667 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbdCZCSb (ORCPT ); Sat, 25 Mar 2017 22:18:31 -0400 Received: by mail-it0-f65.google.com with SMTP id 190so5155755itm.3 for ; Sat, 25 Mar 2017 19:18:30 -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=yCEA4G9bweWOwVj3e9BN3Qn8F50YgBsNAidDbPDSEjs=; b=o+ElF/9sKYV/sor2nR+4Hvz+8vFClJZSqOHjUJTC5AbKu7r8SB7DJu+lAiuIlScyiW kxkJFA8XIkSfWXtGblwn3ioA6G+dXEGuQp0TS+BAIBCFXEK2Km37zxPhZHhaeSf30gI2 F1ncagroqif9orHKgRZ7+scZJp+CZB/aFjkZqeOtCO0v0w7p8RLK0Xt5Dvr3NGa5ciZw SR89Y+TyuM4Idr2nIfW/1/POr2Wbsb/nXjsshg4pRUF1dcUE63C43t+Mvu2BDX6GFSzB B86D5Pd65+oi0pjCFRTUMzQs+JNFI3fOxcFuCAu2VysrzZ9uArnQyJ+gn1BsUhMveYEc DeZw== X-Gm-Message-State: AFeK/H31MaAQYQccRouGUi2wwXp3pxZ3Z/mdPrQKiLpuCeKN/7o8ZfnBYSqORD7f8bgMCQ== X-Received: by 10.107.8.85 with SMTP id 82mr14696986ioi.163.1490494699846; Sat, 25 Mar 2017 19:18:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Mar 2017 19:18:19 -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 1/2] blk-stat: convert blk-stat bucket callback to signed Date: Sat, 25 Mar 2017 20:18:11 -0600 Message-Id: <1490494692-2416-2-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 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 | 8 +++++--- block/blk-stat.h | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/block/blk-stat.c b/block/blk-stat.c index 188b535..936adfb 100644 --- a/block/blk-stat.c +++ b/block/blk-stat.c @@ -17,9 +17,9 @@ struct blk_queue_stats { spinlock_t lock; }; -unsigned int blk_stat_rq_ddir(const struct request *rq) +int blk_stat_rq_ddir(const struct request *rq) { - return rq_data_dir(rq); + return (int)rq_data_dir(rq); } EXPORT_SYMBOL_GPL(blk_stat_rq_ddir); @@ -100,6 +100,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); } @@ -131,7 +133,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 6ad5b8c..7417805 100644 --- a/block/blk-stat.h +++ b/block/blk-stat.h @@ -41,9 +41,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. @@ -98,7 +99,7 @@ static inline u64 blk_stat_time(struct blk_issue_stat *stat) * * 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. @@ -113,7 +114,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); /**