diff options
author | Baokun Li <libaokun1@huawei.com> | 2024-01-24 17:28:55 +0300 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-01-25 19:23:51 +0300 |
commit | d8f899d13d72d285db43dbb9df1acaed22d8c4e7 (patch) | |
tree | d9aaf11fd732357be2347b6fb0e6d7ed98df30b8 /include/asm-generic | |
parent | 2263639f96f24a121ec9f037981b81daf5a8d60a (diff) | |
download | linux-d8f899d13d72d285db43dbb9df1acaed22d8c4e7.tar.xz |
fs: make the i_size_read/write helpers be smp_load_acquire/store_release()
In [Link] Linus mentions that acquire/release makes it clear which
_particular_ memory accesses are the ordered ones, and it's unlikely
to make any performance difference, so it's much better to pair up
the release->acquire ordering than have a "wmb->rmb" ordering.
=========================================================
update pagecache
folio_mark_uptodate(folio)
smp_wmb()
set_bit PG_uptodate
=== ↑↑↑ STLR ↑↑↑ === smp_store_release(&inode->i_size, i_size)
folio_test_uptodate(folio)
test_bit PG_uptodate
smp_rmb()
=== ↓↓↓ LDAR ↓↓↓ === smp_load_acquire(&inode->i_size)
copy_page_to_iter()
=========================================================
Calling smp_store_release() in i_size_write() ensures that the data
in the page and the PG_uptodate bit are updated before the isize is
updated, and calling smp_load_acquire() in i_size_read ensures that
it will not read a newer isize than the data in the page. Therefore,
this avoids buffered read-write inconsistencies caused by Load-Load
reordering.
Link: https://lore.kernel.org/r/CAHk-=wifOnmeJq+sn+2s-P46zw0SFEbw9BSCGgp2c5fYPtRPGw@mail.gmail.com/
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Link: https://lore.kernel.org/r/20240124142857.4146716-2-libaokun1@huawei.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/asm-generic')
0 files changed, 0 insertions, 0 deletions