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 v3 1/2] blk-stat: convert blk-stat bucket callback to signed Date: Fri, 7 Apr 2017 06:24:02 -0600 [thread overview] Message-ID: <1491567843-26190-2-git-send-email-sbates@raithlin.com> (raw) In-Reply-To: <1491567843-26190-1-git-send-email-sbates@raithlin.com> From: Stephen Bates <sbates@raithlin.com> 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 <sbates@raithlin.com> --- 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); /** -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: sbates@raithlin.com (sbates@raithlin.com) Subject: [PATCH v3 1/2] blk-stat: convert blk-stat bucket callback to signed Date: Fri, 7 Apr 2017 06:24:02 -0600 [thread overview] Message-ID: <1491567843-26190-2-git-send-email-sbates@raithlin.com> (raw) In-Reply-To: <1491567843-26190-1-git-send-email-sbates@raithlin.com> From: Stephen Bates <sbates@raithlin.com> 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 <sbates at raithlin.com> --- 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); /** -- 2.7.4
next prev parent reply other threads:[~2017-04-07 12:24 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-04-07 12:24 [PATCH v3 0/2] blk-stat: Add ability to not bucket IO; improve IO polling sbates 2017-04-07 12:24 ` sbates 2017-04-07 12:24 ` sbates [this message] 2017-04-07 12:24 ` [PATCH v3 1/2] blk-stat: convert blk-stat bucket callback to signed sbates 2017-04-07 12:24 ` [PATCH v3 2/2] blk-mq: Add a polling specific stats function sbates 2017-04-07 12:24 ` sbates 2017-04-20 20:07 ` Omar Sandoval 2017-04-20 20:07 ` Omar Sandoval 2017-04-20 20:16 ` Jens Axboe 2017-04-20 20:16 ` Jens Axboe 2017-04-20 20:20 ` Omar Sandoval 2017-04-20 20:20 ` Omar Sandoval 2017-04-20 20:22 ` Jens Axboe 2017-04-20 20:22 ` Jens Axboe 2017-04-20 20:33 ` Stephen Bates 2017-04-20 20:33 ` Stephen Bates 2017-04-20 20:34 ` Jens Axboe 2017-04-20 20:34 ` Jens Axboe 2017-04-20 20:47 ` Stephen Bates 2017-04-20 20:47 ` Stephen Bates 2017-04-20 20:53 ` Jens Axboe 2017-04-20 20:53 ` Jens Axboe 2017-04-20 21:08 ` Stephen Bates 2017-04-20 21:08 ` Stephen Bates 2017-04-20 21:14 ` Jens Axboe 2017-04-20 21:14 ` Jens Axboe 2017-04-20 21:41 ` Stephen Bates 2017-04-20 21:41 ` Stephen Bates 2017-04-20 21:42 ` Jens Axboe 2017-04-20 21:42 ` Jens Axboe 2017-04-20 21:45 ` Stephen Bates 2017-04-20 21:45 ` Stephen Bates 2017-04-20 22:05 ` Stephen Bates 2017-04-20 22:05 ` Stephen Bates 2017-04-20 22:06 ` Jens Axboe 2017-04-20 22:06 ` Jens Axboe
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1491567843-26190-2-git-send-email-sbates@raithlin.com \ --to=sbates@raithlin.com \ --cc=Damien.LeMoal@wdc.com \ --cc=axboe@kernel.dk \ --cc=linux-block@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=osandov@osandov.com \ --cc=sagi@grimberg.me \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.