block/blk-iocost: read ioc_pd_stat params inside ioc->lock
Subsystems (3)
PATCH 1/1 block/blk-iocost: read ioc_pd_stat params inside ioc->lock
From: Tao Cui <[email protected]>
ioc_pd_stat() reads ioc->enabled, ioc->vtime_base_rate, and iocg->last_stat without holding ioc->lock, which trips KCSAN since ioc_adjust_base_vrate() and iocg_flush_stat_upward() write those fields under ioc->lock.
Commit 35198e323001 ("blk-iocost: read params inside lock in sysfs apis") fixed the same issue in ioc_qos_prfill() and ioc_cost_model_prfill(), but ioc_pd_stat() was missed.
Add spin_lock_irq(&ioc->lock) around the reads, matching the fix style of 35198e323001.
Fixes 35198e323001 ("blk-iocost: read params inside lock in sysfs apis")
Signed-off-by Tao Cui <[email protected]>
--- block/blk-iocost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
block/blk-iocost.c +5 -1
@@ -3093,8 +3093,10 @@ static void ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s)struct ioc_gq *iocg =pd_to_iocg (pd);struct ioc *ioc = iocg->ioc; +spin_lock_irq (&ioc->lock); +if (!ioc->enabled) -return ; + goto out;if (iocg->level ==0 ) { unsigned vp10k = DIV64_U64_ROUND_CLOSEST(
@@ -3110,6 +3112,8 @@ static void ioc_pd_stat(struct blkg_policy_data *pd, struct seq_file *s) iocg->last_stat.wait_us, iocg->last_stat.indebt_us, iocg->last_stat.indelay_us); +out: +spin_unlock_irq (&ioc->lock); } static u64 ioc_weight_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
Signature · 1 line
2.43.0