* [PATCH] block/null_blk: Fix completion processing from LIFO to FIFO
@ 2014-02-06 16:33 Shlomo Pongratz
2014-02-06 16:35 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Shlomo Pongratz @ 2014-02-06 16:33 UTC (permalink / raw)
To: axboe; +Cc: linux-scsi, Shlomo Pongratz
The completion queue is implemented using lockless list.
The llist_add is adds the events to the list head which is a push operation.
The processing of the completion elements is done by disconnecting all the
pushed elements and iterating over the disconnected list. The problem is
that the processing is done in reverse order w.r.t order of the insertion
i.e. LIFO processing. By reversing the disconnected list which is done in
linear time the desired FIFO processing is achieved.
Signed-off-by: Shlomo Pongratz <shlomop@mellanox.com>
---
drivers/block/null_blk.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 3107282..cc801cd 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -195,6 +195,7 @@ static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer)
cq = &per_cpu(completion_queues, smp_processor_id());
while ((entry = llist_del_all(&cq->list)) != NULL) {
+ entry = llist_reverse_order(entry);
do {
cmd = container_of(entry, struct nullb_cmd, ll_list);
end_cmd(cmd);
@@ -235,6 +236,7 @@ static void null_ipi_cmd_end_io(void *data)
cq = &per_cpu(completion_queues, smp_processor_id());
entry = llist_del_all(&cq->list);
+ entry = llist_reverse_order(entry);
while (entry) {
next = entry->next;
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block/null_blk: Fix completion processing from LIFO to FIFO
2014-02-06 16:33 [PATCH] block/null_blk: Fix completion processing from LIFO to FIFO Shlomo Pongratz
@ 2014-02-06 16:35 ` Christoph Hellwig
2014-02-06 19:23 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2014-02-06 16:35 UTC (permalink / raw)
To: Shlomo Pongratz; +Cc: axboe, linux-scsi
On Thu, Feb 06, 2014 at 06:33:17PM +0200, Shlomo Pongratz wrote:
> The completion queue is implemented using lockless list.
>
> The llist_add is adds the events to the list head which is a push operation.
> The processing of the completion elements is done by disconnecting all the
> pushed elements and iterating over the disconnected list. The problem is
> that the processing is done in reverse order w.r.t order of the insertion
> i.e. LIFO processing. By reversing the disconnected list which is done in
> linear time the desired FIFO processing is achieved.
I think it should just switch to using __smp_call_function_single
directly, mirroring commit 3d6efbf62c797a2924785f482e4ce8aa8820ec72 for
the blk-mq core.
I've actually a patch in the queue that allows generic request
completion offloading similar to blk_complete_request() in the old
request code, but it'll need a bit more polishing first.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block/null_blk: Fix completion processing from LIFO to FIFO
2014-02-06 16:35 ` Christoph Hellwig
@ 2014-02-06 19:23 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-02-06 19:23 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Shlomo Pongratz, linux-scsi
On Thu, Feb 06 2014, Christoph Hellwig wrote:
> On Thu, Feb 06, 2014 at 06:33:17PM +0200, Shlomo Pongratz wrote:
> > The completion queue is implemented using lockless list.
> >
> > The llist_add is adds the events to the list head which is a push operation.
> > The processing of the completion elements is done by disconnecting all the
> > pushed elements and iterating over the disconnected list. The problem is
> > that the processing is done in reverse order w.r.t order of the insertion
> > i.e. LIFO processing. By reversing the disconnected list which is done in
> > linear time the desired FIFO processing is achieved.
>
> I think it should just switch to using __smp_call_function_single
> directly, mirroring commit 3d6efbf62c797a2924785f482e4ce8aa8820ec72 for
> the blk-mq core.
>
> I've actually a patch in the queue that allows generic request
> completion offloading similar to blk_complete_request() in the old
> request code, but it'll need a bit more polishing first.
The patch is trivial enough that I may as well just apply it. It's not a
bug as such, but doing FIFO completions does make more sense. I was
aware of this issued, fwiw, it just didn't really matter for my testing
and I opted to avoid a list reversal to make it cheaper.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-06 19:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-06 16:33 [PATCH] block/null_blk: Fix completion processing from LIFO to FIFO Shlomo Pongratz
2014-02-06 16:35 ` Christoph Hellwig
2014-02-06 19:23 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox