[Devel] [PATCH RH7 12/12] rq-qos: use a mb for got_token
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Sep 29 14:30:12 MSK 2022
From: Josef Bacik <josef at toxicpanda.com>
Oleg noticed that our checking of data.got_token is unsafe in the
cleanup case, and should really use a memory barrier. Use a wmb on the
write side, and a rmb() on the read side. We don't need one in the main
loop since we're saved by set_current_state().
Reviewed-by: Oleg Nesterov <oleg at redhat.com>
Signed-off-by: Josef Bacik <josef at toxicpanda.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>
Changes when porting to vz7:
- original patch is patching block/blk-rq-qos.c:rq_qos_wait, but in vz7
similar hunk is in block/blk-wbt.c:__wbt_wait
- also original patch is patching rq_qos_wake_function, but in vz7
similar hunk is in wbt_wake_function
https://jira.sw.ru/browse/PSBM-141883
(cherry picked from commit ac38297f7038cd5b80d66f8809c7bbf5b70031f3)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
block/blk-wbt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 4c5b6899db71..099678cd0d04 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -541,6 +541,7 @@ static int wbt_wake_function(struct __wait_queue *curr, unsigned int mode,
return -1;
data->got_token = true;
+ smp_wmb();
list_del_init(&curr->task_list);
wake_up_process(data->task);
return 1;
@@ -573,6 +574,7 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
has_sleeper = !wq_has_single_sleeper(&rqw->wait);
do {
+ /* The memory barrier in set_task_state saves us here. */
if (data.got_token)
break;
@@ -585,6 +587,7 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
* which means we now have two. Put our local token
* and wake anyone else potentially waiting for one.
*/
+ smp_rmb();
if (data.got_token)
wbt_rqw_done(rwb, rqw, wb_acct);
break;
--
2.37.1
More information about the Devel
mailing list