]> www.infradead.org Git - users/jedix/linux-maple.git/commit
writeback: use READ_ONCE for unlocked reads of writeback stats
authorJan Kara <jack@suse.cz>
Mon, 23 Aug 2021 23:59:07 +0000 (09:59 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Aug 2021 23:33:40 +0000 (09:33 +1000)
commit40264e1e5ed4074cb3cacede4404259948de7738
treec39fbde82a1eee881c2a3790ec145dc30cbd27d5
parentdca30501d55714ed99a4defab9b507f8f5a8f160
writeback: use READ_ONCE for unlocked reads of writeback stats

We do some unlocked reads of writeback statistics like
avg_write_bandwidth, dirty_ratelimit, or bw_time_stamp.  Generally we are
fine with getting somewhat out-of-date values but actually getting
different values in various parts of the functions because the compiler
decided to reload value from original memory location could confuse
calculations.  Use READ_ONCE for these unlocked accesses and WRITE_ONCE
for the updates to be on the safe side.

Link: https://lkml.kernel.org/r/20210713104716.22868-5-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Michael Stapelberg <stapelberg+linux@google.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
mm/page-writeback.c