All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lin Ming <ming.m.lin@intel.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Shaohua Li <shli@fusionio.com>, lkml <linux-kernel@vger.kernel.org>
Subject: number of block requests added and completed
Date: Fri, 11 May 2012 15:59:56 +0800	[thread overview]
Message-ID: <1336723196.8260.115.camel@minggr> (raw)

Hi,

I use below debug patch to check how many requests are added and
completed.

But I always got nr_added < nr_completed, for example

nr_added: 0x9e66
nr_completed: 0x9e76

So I think there are other paths except than __elv_add_request which
adds the request to queue.

Could anybody give me some hint?

Thanks.

diff --git a/block/blk-settings.c b/block/blk-settings.c
index d3234fc..4dc1746 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -181,6 +181,8 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn)
 	blk_queue_dma_alignment(q, 511);
 	blk_queue_congestion_threshold(q);
 	q->nr_batching = BLK_BATCH_REQ;
+	q->nr_added = 0;
+	q->nr_completed = 0;
 
 	blk_set_default_limits(&q->limits);
 
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index cf15001..b1d3586 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -19,7 +19,7 @@ struct queue_sysfs_entry {
 static ssize_t
 queue_var_show(unsigned long var, char *page)
 {
-	return sprintf(page, "%lu\n", var);
+	return sprintf(page, "0x%lx\n", var);
 }
 
 static ssize_t
@@ -36,6 +36,16 @@ static ssize_t queue_requests_show(struct request_queue *q, char *page)
 	return queue_var_show(q->nr_requests, (page));
 }
 
+static ssize_t nr_added_show(struct request_queue *q, char *page)
+{
+	return queue_var_show(q->nr_added, (page));
+}
+
+static ssize_t nr_completed_show(struct request_queue *q, char *page)
+{
+	return queue_var_show(q->nr_completed, (page));
+}
+
 static ssize_t
 queue_requests_store(struct request_queue *q, const char *page, size_t count)
 {
@@ -273,6 +283,16 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
 	return ret;
 }
 
+static struct queue_sysfs_entry nr_added_entry = {
+	.attr = {.name = "nr_added", .mode = S_IRUGO | S_IWUSR },
+	.show = nr_added_show,
+};
+
+static struct queue_sysfs_entry nr_completed_entry = {
+	.attr = {.name = "nr_completed", .mode = S_IRUGO | S_IWUSR },
+	.show = nr_completed_show,
+};
+
 static struct queue_sysfs_entry queue_requests_entry = {
 	.attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
 	.show = queue_requests_show,
@@ -388,6 +408,8 @@ static struct queue_sysfs_entry queue_random_entry = {
 };
 
 static struct attribute *default_attrs[] = {
+	&nr_added_entry.attr,
+	&nr_completed_entry.attr,
 	&queue_requests_entry.attr,
 	&queue_ra_entry.attr,
 	&queue_max_hw_sectors_entry.attr,
diff --git a/block/elevator.c b/block/elevator.c
index f016855..c684e18 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -587,6 +587,8 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)
 {
 	trace_block_rq_insert(q, rq);
 
+	q->nr_added++;
+
 	rq->q = q;
 
 	if (rq->cmd_flags & REQ_SOFTBARRIER) {
@@ -743,6 +745,8 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
 {
 	struct elevator_queue *e = q->elevator;
 
+	q->nr_completed++;
+
 	/*
 	 * request is released from the driver, io must be done
 	 */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2aa2466..746924f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -345,6 +345,8 @@ struct request_queue {
 	unsigned int		nr_congestion_on;
 	unsigned int		nr_congestion_off;
 	unsigned int		nr_batching;
+	unsigned long		nr_added;
+	unsigned long		nr_completed;
 
 	unsigned int		dma_drain_size;
 	void			*dma_drain_buffer;



                 reply	other threads:[~2012-05-11  8:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1336723196.8260.115.camel@minggr \
    --to=ming.m.lin@intel.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shli@fusionio.com \
    /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: link
Be 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.