]> git.baikalelectronics.ru Git - kernel.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:34 +0000 (09:34 +0100)
commitde2b9d2c0855782d361846c85b6b1ba0651d1b04
treee9cd8a2ec508257b2b6e11f3b9084ebbd96cdc9b
parent7827dbb819f965d887e7c8d3473d8db0c75a301d
sbitmap: Advance the queue index before waking up a queue

commit 72b64a9c71a049d35be6aa8253c5f81ff62d7d93 upstream.

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: 2838834268c2 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/sbitmap.c