All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] block : Patches related to io_polling
@ 2016-09-13 18:23 Stephen Bates
  2016-09-13 18:23 ` [PATCH 1/2] Add poll_considered statistic Stephen Bates
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Bates @ 2016-09-13 18:23 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch

While profiling the performance of the io_poll feature of the blk-mq
section of the block layer I found it useful to add another entry to
the io_poll stats counters. I also found it really useful to be able
to zero the stats counters by echoing into the relevant sysfs entry.

These two patches are based off commit 0eadf37afc in Jen's
for-4.9/block. I am not sure if that is the right repo and can rebase
if necessary.

In full disclosure the zeroing patch is based heavily on a code
snippet Jens send me a few months ago.

Stephen Bates (2):
  Add poll_considered statistic
  Enable zeroing of io_poll statistics

 block/blk-core.c       |  8 ++++++--
 block/blk-mq-sysfs.c   | 15 +++++++++++++--
 include/linux/blk-mq.h |  1 +
 3 files changed, 20 insertions(+), 4 deletions(-)

--
2.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Add poll_considered statistic
  2016-09-13 18:23 [PATCH 0/2] block : Patches related to io_polling Stephen Bates
@ 2016-09-13 18:23 ` Stephen Bates
  2016-09-13 18:23 ` [PATCH 2/2] Enable zeroing of io_poll statistics Stephen Bates
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Bates @ 2016-09-13 18:23 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch

In order to help determine the effectiveness of polling in a running
system it is usful to determine the ratio of how often the poll
function is called vs how often the completion is checked. For this
reason we add a poll_considered variable and add it to the sysfs entry
for io_poll.

Signed-off-by: Stephen Bates <sbates@raithlin.com>
---
 block/blk-core.c       | 8 ++++++--
 block/blk-mq-sysfs.c   | 4 +++-
 include/linux/blk-mq.h | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 34ff808..14d7c07 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3307,19 +3307,23 @@ bool blk_poll(struct request_queue *q, blk_qc_t cookie)
 {
 	struct blk_plug *plug;
 	long state;
+	unsigned int queue_num;
+	struct blk_mq_hw_ctx *hctx;
 
 	if (!q->mq_ops || !q->mq_ops->poll || !blk_qc_t_valid(cookie) ||
 	    !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
 		return false;
 
+	queue_num = blk_qc_t_to_queue_num(cookie);
+	hctx = q->queue_hw_ctx[queue_num];
+	hctx->poll_considered++;
+
 	plug = current->plug;
 	if (plug)
 		blk_flush_plug_list(plug, false);
 
 	state = current->state;
 	while (!need_resched()) {
-		unsigned int queue_num = blk_qc_t_to_queue_num(cookie);
-		struct blk_mq_hw_ctx *hctx = q->queue_hw_ctx[queue_num];
 		int ret;
 
 		hctx->poll_invoked++;
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index fe822aa..ea8c3f5 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -176,7 +176,9 @@ static ssize_t blk_mq_sysfs_rq_list_show(struct blk_mq_ctx *ctx, char *page)
 
 static ssize_t blk_mq_hw_sysfs_poll_show(struct blk_mq_hw_ctx *hctx, char *page)
 {
-	return sprintf(page, "invoked=%lu, success=%lu\n", hctx->poll_invoked, hctx->poll_success);
+	return sprintf(page, "considered=%lu, invoked=%lu, success=%lu\n",
+		       hctx->poll_considered, hctx->poll_invoked,
+		       hctx->poll_success);
 }
 
 static ssize_t blk_mq_hw_sysfs_queued_show(struct blk_mq_hw_ctx *hctx,
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index e1544f0..7710f79 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -61,6 +61,7 @@ struct blk_mq_hw_ctx {
 	struct blk_mq_cpu_notifier	cpu_notifier;
 	struct kobject		kobj;
 
+	unsigned long		poll_considered;
 	unsigned long		poll_invoked;
 	unsigned long		poll_success;
 };
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Enable zeroing of io_poll statistics
  2016-09-13 18:23 [PATCH 0/2] block : Patches related to io_polling Stephen Bates
  2016-09-13 18:23 ` [PATCH 1/2] Add poll_considered statistic Stephen Bates
@ 2016-09-13 18:23 ` Stephen Bates
  2016-09-14 14:24 ` [PATCH 0/2] block : Patches related to io_polling Christoph Hellwig
  2016-09-14 14:42 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Bates @ 2016-09-13 18:23 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, hch

Allow the io_poll statistics to be zeroed to make for easier logging
of polling event.

Signed-off-by: Stephen Bates <sbates@raithlin.com>
---
 block/blk-mq-sysfs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index ea8c3f5..ac5160e 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -181,6 +181,14 @@ static ssize_t blk_mq_hw_sysfs_poll_show(struct blk_mq_hw_ctx *hctx, char *page)
 		       hctx->poll_success);
 }
 
+static ssize_t blk_mq_hw_sysfs_poll_store(struct blk_mq_hw_ctx *hctx,
+					  const char *page, size_t size)
+{
+	hctx->poll_considered = hctx->poll_invoked = hctx->poll_success = 0;
+
+	return size;
+}
+
 static ssize_t blk_mq_hw_sysfs_queued_show(struct blk_mq_hw_ctx *hctx,
 					   char *page)
 {
@@ -303,8 +311,9 @@ static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = {
 	.show = blk_mq_hw_sysfs_cpus_show,
 };
 static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_poll = {
-	.attr = {.name = "io_poll", .mode = S_IRUGO },
+	.attr = {.name = "io_poll", .mode = S_IWUSR | S_IRUGO },
 	.show = blk_mq_hw_sysfs_poll_show,
+	.store = blk_mq_hw_sysfs_poll_store,
 };
 
 static struct attribute *default_hw_ctx_attrs[] = {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] block : Patches related to io_polling
  2016-09-13 18:23 [PATCH 0/2] block : Patches related to io_polling Stephen Bates
  2016-09-13 18:23 ` [PATCH 1/2] Add poll_considered statistic Stephen Bates
  2016-09-13 18:23 ` [PATCH 2/2] Enable zeroing of io_poll statistics Stephen Bates
@ 2016-09-14 14:24 ` Christoph Hellwig
  2016-09-14 14:42 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2016-09-14 14:24 UTC (permalink / raw)
  To: Stephen Bates; +Cc: linux-block, axboe, hch

Hi Stephen,

the series looks reasonable to me:

Acked-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] block : Patches related to io_polling
  2016-09-13 18:23 [PATCH 0/2] block : Patches related to io_polling Stephen Bates
                   ` (2 preceding siblings ...)
  2016-09-14 14:24 ` [PATCH 0/2] block : Patches related to io_polling Christoph Hellwig
@ 2016-09-14 14:42 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2016-09-14 14:42 UTC (permalink / raw)
  To: Stephen Bates, linux-block; +Cc: hch

On 09/13/2016 12:23 PM, Stephen Bates wrote:
> While profiling the performance of the io_poll feature of the blk-mq
> section of the block layer I found it useful to add another entry to
> the io_poll stats counters. I also found it really useful to be able
> to zero the stats counters by echoing into the relevant sysfs entry.
>
> These two patches are based off commit 0eadf37afc in Jen's
> for-4.9/block. I am not sure if that is the right repo and can rebase
> if necessary.
>
> In full disclosure the zeroing patch is based heavily on a code
> snippet Jens send me a few months ago.

Thanks Stephen, added for 4.9.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-14 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13 18:23 [PATCH 0/2] block : Patches related to io_polling Stephen Bates
2016-09-13 18:23 ` [PATCH 1/2] Add poll_considered statistic Stephen Bates
2016-09-13 18:23 ` [PATCH 2/2] Enable zeroing of io_poll statistics Stephen Bates
2016-09-14 14:24 ` [PATCH 0/2] block : Patches related to io_polling Christoph Hellwig
2016-09-14 14:42 ` Jens Axboe

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.