On 17 Sep 2022 10:33:01 +0800 Liu Song <liusong@xxxxxxxxxxxxxxxxx> wrote:
@@ -632,10 +633,14 @@ static bool __sbq_wake_up(struct sbitmap_queue *sbq)Hi Song,
if (ret == wait_cnt) {
sbq_index_atomic_inc(&sbq->wake_index);
wake_up_nr(&ws->wait, wake_batch);
- return false;
+ if (!nr || *nr <= 0)
+ return false;
}
return true;
+ } else if (nr && *nr) {
+ (*nr)--;
+ goto again;
}
return false;
See if advancing wake_index can survive your tests.
Only for thoughts now.
Hillf
--- a/lib/sbitmap.c
+++ b/lib/sbitmap.c
@@ -611,6 +611,7 @@ static bool __sbq_wake_up(struct sbitmap
if (wait_cnt <= 0) {
int ret;
+ sbq_index_atomic_inc(&sbq->wake_index);
wake_batch = READ_ONCE(sbq->wake_batch);
/*
@@ -627,7 +628,6 @@ static bool __sbq_wake_up(struct sbitmap
*/
ret = atomic_cmpxchg(&ws->wait_cnt, wait_cnt, wake_batch);
if (ret == wait_cnt) {
- sbq_index_atomic_inc(&sbq->wake_index);
wake_up_nr(&ws->wait, wake_batch);
return false;
}