* [PATCH] block: fix request sorting at unplug
@ 2011-04-02 15:37 Konstantin Khlebnikov
2011-04-03 22:10 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Khlebnikov @ 2011-04-02 15:37 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel
Comparison function for list_sort() must be anticommutative,
otherwise it is not sorting in ordinary meaning.
But fortunately list_sort() always check ((*cmp)(priv, a, b) <= 0)
it not distinguish negative and zero, so comparison function can
implement only less-or-equal instead of full three-way comparison.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
block/blk-core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index e0a0623..5e151d2 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2665,7 +2665,7 @@ static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
struct request *rqa = container_of(a, struct request, queuelist);
struct request *rqb = container_of(b, struct request, queuelist);
- return !(rqa->q == rqb->q);
+ return !(rqa->q <= rqb->q);
}
static void flush_plug_list(struct blk_plug *plug)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] block: fix request sorting at unplug
2011-04-02 15:37 [PATCH] block: fix request sorting at unplug Konstantin Khlebnikov
@ 2011-04-03 22:10 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2011-04-03 22:10 UTC (permalink / raw)
To: Konstantin Khlebnikov; +Cc: linux-kernel
On 2011-04-02 17:37, Konstantin Khlebnikov wrote:
> Comparison function for list_sort() must be anticommutative,
> otherwise it is not sorting in ordinary meaning.
>
> But fortunately list_sort() always check ((*cmp)(priv, a, b) <= 0)
> it not distinguish negative and zero, so comparison function can
> implement only less-or-equal instead of full three-way comparison.
Thanks, good catch! It's an optimization, so no breakage. But if you end
up often having > 1 queue plugged, it's a good optimization.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-03 22:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-02 15:37 [PATCH] block: fix request sorting at unplug Konstantin Khlebnikov
2011-04-03 22:10 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox