Re: [PATCH] sbitmap: fix permanent io blocking caused by insufficient wakeup times

From: Liu Song
Date: Sat Sep 17 2022 - 05:11:16 EST



On 2022/9/17 11:58, Hillf Danton wrote:
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)
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;
Hi Song,

See if advancing wake_index can survive your tests.

Hi

Thanks for your suggestion, this problem not only needs to switch a wait queue, but also needs to consume "wait_cnt" correctly.


Thanks



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;
}