bfq_max_budget and bfq_user_max_budget maybe be in inconsisten state if bfq_max_budget configuration and bfq_max_budget auto-update happen concurrently. Example sequence: config auto-update bfqd->bfq_max_budget = __data if (bfqd->bfq_user_max_budget == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); bfqd->bfq_user_max_budget = __data; bfq_max_budget is only update in update_thr_responsiveness_params and configuration code. As update_thr_responsiveness_params is always called under bfqd->lock, fix this by holding lock in configuration code. Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxx> --- block/bfq-iosched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 25a88ffd997e..13370c41ad36 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -7328,6 +7328,7 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e, if (ret) return ret; + spin_lock_irq(&bfqd->lock); if (__data == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); else { @@ -7337,6 +7338,7 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e, } bfqd->bfq_user_max_budget = __data; + spin_unlock_irq(&bfqd->lock); return count; } @@ -7362,8 +7364,11 @@ static ssize_t bfq_timeout_sync_store(struct elevator_queue *e, __data = INT_MAX; bfqd->bfq_timeout = msecs_to_jiffies(__data); + + spin_lock_irq(&bfqd->lock); if (bfqd->bfq_user_max_budget == 0) bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); + spin_unlock_irq(&bfqd->lock); return count; } -- 2.30.0