]> git.baikalelectronics.ru Git - kernel.git/commit
sbitmap: Try each queue to wake up at least one waiter
authorGabriel Krisman Bertazi <krisman@suse.de>
Tue, 15 Nov 2022 22:45:53 +0000 (17:45 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:34 +0000 (09:34 +0100)
commit18019f066e3f118940d0928c6691d359b2f89657
tree38e6d62e7cc582d732ba1fe0b825223fcef39052
parent78c8b70f65cb3e448de96de2907ce9fc236e1e15
sbitmap: Try each queue to wake up at least one waiter

commit 75a774f38d176ce12fefd0fea8cf708e09243614 upstream.

Jan reported the new algorithm as merged might be problematic if the
queue being awaken becomes empty between the waitqueue_active inside
sbq_wake_ptr check and the wake up.  If that happens, wake_up_nr will
not wake up any waiter and we loose too many wake ups.  In order to
guarantee progress, we need to wake up at least one waiter here, if
there are any.  This now requires trying to wake up from every queue.

Instead of walking through all the queues with sbq_wake_ptr, this call
moves the wake up inside that function.  In a previous version of the
patch, I found that updating wake_index several times when walking
through queues had a measurable overhead.  This ensures we only update
it once, at the end.

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