sbitmap: Advance the queue index before waking up a queue
authorGabriel Krisman Bertazi <krisman@suse.de>
Tue, 15 Nov 2022 22:45:51 +0000 (17:45 -0500)
committerJens Axboe <axboe@kernel.dk>
Wed, 16 Nov 2022 18:33:03 +0000 (11:33 -0700)
commit976570b4ecd30d3ec6e1b0910da8e5edc591f2b6
tree378e2ade7b1b3289296cf1e2e8afc7ad5a66d018
parent470373e888f494a52f9916bf3eeea41fe819d031
sbitmap: Advance the queue index before waking up a queue

When a queue is awaken, the wake_index written by sbq_wake_ptr currently
keeps pointing to the same queue.  On the next wake up, it will thus
retry the same queue, which is unfair to other queues, and can lead to
starvation.  This patch, moves the index update to happen before the
queue is returned, such that it will now try a different queue first on
the next wake up, improving fairness.

Fixes: 4f8126bb2308 ("sbitmap: Use single per-bitmap counting to wake up queued tags")
Reported-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
Link: https://lore.kernel.org/r/20221115224553.23594-2-krisman@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
lib/sbitmap.c