Re: [PATCH v3] block/blk-iocost: annotate ioc_pd_stat reads with data_race()

Tejun Heo <[email protected]>
Newsgroups gmane.linux.kernel.cgroups,gmane.linux.block,gmane.linux.kernel
Message-ID <[email protected]>
On Tue, Aug 04, 2026 at 01:41:20PM +0800, Tao Cui wrote:
> From: Tao Cui <cuitao-UOlijcLmZ/[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 fixed the same issue in ioc_qos_prfill() and
> ioc_cost_model_prfill() by adding spin_lock_irq(&ioc->lock).  However,
> those functions read configuration parameters (qos/model) that need
> synchronized reads.  In contrast, ioc_pd_stat() only reads stat
> values (vrate, usage) where stale reads are harmless, so data_race()
> is more appropriate — it silences the KCSAN warning without adding
> lock contention during high-frequency stat reads.
> 
> Signed-off-by: Tao Cui <cuitao-UOlijcLmZ/[email protected]>

Acked-by: Tejun Heo <[email protected]>

Thanks.

-- 
tejun
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.