block: document blk_plug
PATCH 1/1 block: document blk_plug
Andrew Morton is asking to document blk_plug, so here is my attempt.
--- include/linux/blkdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/blkdev.h +11 -0
@@ -858,6 +858,17 @@ struct request_queue *blk_alloc_queue_noextern void blk_put_queue (struct request_queue *);/* +* blk_plug gives each task a request list. Since blk_start_plug() called, +* requests from the task will be added to the per-task list and then moved +* to global request_queue in a batch way at appropriate time(either +* blk_finish_plug() is called or task goes to sleep). blk_plug has some +* advantages: +* 1. Better request merge. The assumption here is requests from a task have +* better chances to be merged. +* 2. Better scalability. Requests are moved from per-task list to global +* request_queue in a batch way, so the total times grabing global +* request_queue lock are reduced. +* * Note: Code in between changing the blk_plug list/cb_list or element of such * lists is preemptable, but such code can't do sleep (or be very careful), * otherwise data is corrupted. For details, please check schedule() where
Quoted 16 lines · Shaohua Li
Andrew Morton is asking to document
blk_plug, so here is my attempt.Signed-off-by Shaohua Li <[email protected]>--- include/linux/blkdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+)Index:
linux/include/linux/blkdev.h
===================================================================include/linux/blkdev.h +1
-0@@ -858,6 +858,17 @@ struct request_queue *blk_alloc_queue_noextern void blk_put_queue (struct request_queue *);/* +* blk_plug gives each task a request list. Since blk_start_plug() called,
include/linux/blkdev.h struct request_queue *blk_alloc_queue_no · line 871
Quoted 10 lines
include/linux/blkdev.h +10
-0+* requests from the task will be added to the per-task list and then moved +* to global request_queue in a batch way at appropriate time(either +* blk_finish_plug() is called or task goes to sleep). blk_plug has some +* advantages: +* 1. Better request merge. The assumption here is requests from a task have +* better chances to be merged. +* 2. Better scalability. Requests are moved from per-task list to global +* request_queue in a batch way, so the total times grabing global +* request_queue lock are reduced. +*
Hi Shaohua,
This seems too brief atleast for someone like me who has not spent much time with the code and also is not in kerneldoc format. Here's my attempt:
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] block: document blk-plug
Thus spake Andrew Morton:
"And I have the usual maintainability whine. If someone comes up to vmscan.c and sees it calling blk_start_plug(), how are they supposed to work out why that call is there? They go look at the blk_start_plug() definition and it is undocumented. I think we can do better than this?"
Shaohua Li attempted to document it. But, I think it was too brief and was not in kerneldoc format. Here's my attempt to document it.
---
block/blk-core.c | 10 ++++++++++ include/linux/blkdev.h | 13 ++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-)
block/blk-core.c +10 -0
@@ -2620,6 +2620,16 @@ EXPORT_SYMBOL(kblockd_schedule_delayed_work);#define PLUG_MAGIC 0x91827364 +/** +* blk_start_plug - initialize blk_plug and track it inside the task_struct +* @plug: The &struct blk_plug that needs to be initialized +* +* Description: +* Tracking blk_plug inside the task_struct will help with flushing the +* pending I/O should the task end up blocking between blk_start_plug() and +* blk_finish_plug() and is important for deadlock avoidance and for the +* performance. +*/ void blk_start_plug (struct blk_plug *plug) {struct task_struct *tsk = current;
include/linux/blkdev.h +8 -5
@@ -858,17 +858,20 @@ struct request_queue *blk_alloc_queue_node(gfp_t, int);extern void blk_put_queue (struct request_queue *);/* +* blk_plug allows for build up of queue of related requests by holding the I/O +* fragments for a short period. +* * Note: Code in between changing the blk_plug list/cb_list or element of such * lists is preemptable, but such code can't do sleep (or be very careful), * otherwise data is corrupted. For details, please check schedule() where * blk_schedule_flush_plug() is called. */ struct blk_plug { -unsigned long magic; -struct list_head list; -struct list_head cb_list; -unsigned int should_sort; -unsigned int count; +unsigned long magic;/* detect uninitialized cases */ +struct list_head list;/* requests */ +struct list_head cb_list;/* support callbacks */ +unsigned int should_sort;/*list to be sorted before flushing? */ +unsigned int count;/* request count to avoid list getting too big */ };#define BLK_MAX_REQUEST_COUNT 16
Quoted 30 lines · Suresh Jayaraman
Quoted 16 lines · Shaohua Li
Andrew Morton is asking to document
blk_plug, so here is my attempt.Signed-off-by Shaohua Li <[email protected]>--- include/linux/blkdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+)Index:
linux/include/linux/blkdev.h
===================================================================include/linux/blkdev.h +1
-0@@ -858,6 +858,17 @@ struct request_queue *blk_alloc_queue_noextern void blk_put_queue (struct request_queue *);/* +* blk_plug gives each task a request list. Since blk_start_plug() called, include/linux/blkdev.h struct request_queue *blk_alloc_queue_no · line 871
Quoted 10 lines
include/linux/blkdev.h +10
-0+* requests from the task will be added to the per-task list and then moved +* to global request_queue in a batch way at appropriate time(either +* blk_finish_plug() is called or task goes to sleep). blk_plug has some +* advantages: +* 1. Better request merge. The assumption here is requests from a task have +* better chances to be merged. +* 2. Better scalability. Requests are moved from per-task list to global +* request_queue in a batch way, so the total times grabing global +* request_queue lock are reduced. +* Hi Shaohua,
Quoted 2 lines
This seems too brief atleast for someone like me who has not spent much time with the code and also is not in kerneldoc format. Here's my attempt:
Hi Suresh,
I like the blk_start_plug part below. The blk_plug part needs more description to explain why we need it.
Quoted 28 lines
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] block: document blk-plugThus spake Andrew Morton:
"And I have the usual maintainability whine. If someone comes up to
vmscan.cand sees it callingblk_start_plug(), how are they supposed to work out why that call is there? They go look at theblk_start_plug()definition and it is undocumented. I think we can do better than this?"Shaohua Li attempted to document it. But, I think it was too brief and was not in kerneldoc format. Here's my attempt to document it.
Signed-off-by Suresh Jayaraman <[email protected]>---
block/blk-core.c | 10 ++++++++++ include/linux/blkdev.h | 13 ++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-)block/blk-core.c +0
-0@@ -2620,6 +2620,16 @@ EXPORT_SYMBOL(kblockd_schedule_delayed_work);#define PLUG_MAGIC 0x91827364
block/blk-core.c EXPORT_SYMBOL(kblockd_schedule_delayed_work); · line 2632
Quoted 10 lines
block/blk-core.c +10
-0+/** +* blk_start_plug - initialize blk_plug and track it inside the task_struct +* @plug: The &struct blk_plug that needs to be initialized +* +* Description: +* Tracking blk_plug inside the task_struct will help with flushing the +* pending I/O should the task end up blocking between blk_start_plug() and +* blk_finish_plug() and is important for deadlock avoidance and for the +* performance. +*/
I'm not aware blk_plug is to avoid deadlock. It's most for performance to me. Jens, any idea?
Thanks,
Shaohua
Quoted 31 lines · On Tue, 02 Aug 2011 08:46:10 +0800 Shaohua Li <[email protected]> wrote:
Quoted 30 lines · Suresh Jayaraman
Quoted 16 lines · Shaohua Li
Andrew Morton is asking to document
blk_plug, so here is my attempt.Signed-off-by Shaohua Li <[email protected]>--- include/linux/blkdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+)Index:
linux/include/linux/blkdev.h
===================================================================include/linux/blkdev.h +1
-0@@ -858,6 +858,17 @@ struct request_queue *blk_alloc_queue_noextern void blk_put_queue (struct request_queue *);/* +* blk_plug gives each task a request list. Since blk_start_plug() called, include/linux/blkdev.h struct request_queue *blk_alloc_queue_no · line 871
Quoted 10 lines
include/linux/blkdev.h +10
-0+* requests from the task will be added to the per-task list and then moved +* to global request_queue in a batch way at appropriate time(either +* blk_finish_plug() is called or task goes to sleep). blk_plug has some +* advantages: +* 1. Better request merge. The assumption here is requests from a task have +* better chances to be merged. +* 2. Better scalability. Requests are moved from per-task list to global +* request_queue in a batch way, so the total times grabing global +* request_queue lock are reduced. +* Hi Shaohua,
Quoted 6 lines
Quoted 2 lines
This seems too brief atleast for someone like me who has not spent much time with the code and also is not in kerneldoc format. Here's my attempt:
Hi Suresh,
I like theblk_start_plugpart below. Theblk_plugpart needs more description to explain why we need it.
I'm getting all excited about getting some blk_plug documentation!
Quoted 28 lines
Quoted 28 lines
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] block: document blk-plugThus spake Andrew Morton:
"And I have the usual maintainability whine. If someone comes up to
vmscan.cand sees it callingblk_start_plug(), how are they supposed to work out why that call is there? They go look at theblk_start_plug()definition and it is undocumented. I think we can do better than this?"Shaohua Li attempted to document it. But, I think it was too brief and was not in kerneldoc format. Here's my attempt to document it.
Signed-off-by Suresh Jayaraman <[email protected]>---
block/blk-core.c | 10 ++++++++++ include/linux/blkdev.h | 13 ++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-)block/blk-core.c +0
-0@@ -2620,6 +2620,16 @@ EXPORT_SYMBOL(kblockd_schedule_delayed_work);#define PLUG_MAGIC 0x91827364
Quoted 12 lines
block/blk-core.c EXPORT_SYMBOL(kblockd_schedule_delayed_work); · line 2632
Quoted 10 lines
block/blk-core.c +10
-0+/** +* blk_start_plug - initialize blk_plug and track it inside the task_struct +* @plug: The &struct blk_plug that needs to be initialized +* +* Description: +* Tracking blk_plug inside the task_struct will help with flushing the +* pending I/O should the task end up blocking between blk_start_plug() and +* blk_finish_plug() and is important for deadlock avoidance and for the +* performance. +*/ I'm not aware
blk_plugis to avoid deadlock. It's most for performance to me. Jens, any idea?
Only we can't document it because we don't understand it. Great.
c'mon Jens. Talk to us?
Quoted 5 lines · On Fri, 26 Aug 2011 15:25:18 -0700 Andrew Morton <[email protected]>…
I'm getting all excited about getting some
blk_plugdocumentation! [...]
Only we can't document it because we don't understand it. Great.c'mon Jens. Talk to us?
Jens did give us a bit of documentation here:
http://lwn.net/Articles/438256/
Not complete perhaps, but better than nothing...
jon
Jens Axboe
maintainerQuoted 84 lines · Andrew Morton
Quoted 31 lines · On Tue, 02 Aug 2011 08:46:10 +0800 Shaohua Li <[email protected]> wrote:
Quoted 30 lines · Suresh Jayaraman
Quoted 16 lines · Shaohua Li
Andrew Morton is asking to document
blk_plug, so here is my attempt.Signed-off-by Shaohua Li <[email protected]>--- include/linux/blkdev.h | 11 +++++++++++ 1 file changed, 11 insertions(+)Index:
linux/include/linux/blkdev.h
===================================================================include/linux/blkdev.h +1
-0@@ -858,6 +858,17 @@ struct request_queue *blk_alloc_queue_noextern void blk_put_queue (struct request_queue *);/* +* blk_plug gives each task a request list. Since blk_start_plug() called, include/linux/blkdev.h struct request_queue *blk_alloc_queue_no · line 871
Quoted 10 lines
include/linux/blkdev.h +10
-0+* requests from the task will be added to the per-task list and then moved +* to global request_queue in a batch way at appropriate time(either +* blk_finish_plug() is called or task goes to sleep). blk_plug has some +* advantages: +* 1. Better request merge. The assumption here is requests from a task have +* better chances to be merged. +* 2. Better scalability. Requests are moved from per-task list to global +* request_queue in a batch way, so the total times grabing global +* request_queue lock are reduced. +* Hi Shaohua,
Quoted 6 lines
Quoted 2 lines
This seems too brief atleast for someone like me who has not spent much time with the code and also is not in kerneldoc format. Here's my attempt:
Hi Suresh,
I like theblk_start_plugpart below. Theblk_plugpart needs more description to explain why we need it.I'm getting all excited about getting some
blk_plugdocumentation!Quoted 28 lines
Quoted 28 lines
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] block: document blk-plugThus spake Andrew Morton:
"And I have the usual maintainability whine. If someone comes up to
vmscan.cand sees it callingblk_start_plug(), how are they supposed to work out why that call is there? They go look at theblk_start_plug()definition and it is undocumented. I think we can do better than this?"Shaohua Li attempted to document it. But, I think it was too brief and was not in kerneldoc format. Here's my attempt to document it.
Signed-off-by Suresh Jayaraman <[email protected]>---
block/blk-core.c | 10 ++++++++++ include/linux/blkdev.h | 13 ++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-)block/blk-core.c +0
-0@@ -2620,6 +2620,16 @@ EXPORT_SYMBOL(kblockd_schedule_delayed_work);#define PLUG_MAGIC 0x91827364Quoted 12 lines
block/blk-core.c EXPORT_SYMBOL(kblockd_schedule_delayed_work); · line 2632
Quoted 10 lines
block/blk-core.c +10
-0+/** +* blk_start_plug - initialize blk_plug and track it inside the task_struct +* @plug: The &struct blk_plug that needs to be initialized +* +* Description: +* Tracking blk_plug inside the task_struct will help with flushing the +* pending I/O should the task end up blocking between blk_start_plug() and +* blk_finish_plug() and is important for deadlock avoidance and for the +* performance. +*/ I'm not aware
blk_plugis to avoid deadlock. It's most for performance to me. Jens, any idea?
Quoted 3 lines
Only we can't document it because we don't understand it. Great.
c'mon Jens. Talk to us?
The pointer in the task_struct is to be able to auto-flush the plug if the task inadvertently ends up scheduling with requests plugged. For instance, if we end up doing a wait for a page that is already plugged, then we must ensure that everything up to that point has been flushed out.
Signature · 1 line
Jens Axboe