On Wed, Jul 16, 2025 at 9:57 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Wed, Jul 16, 2025 at 09:44:31PM +0800, Alex wrote: > > On Wed, Jul 16, 2025 at 9:41 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > > > > > On Wed, Jul 16, 2025 at 09:28:29PM +0800, Alex wrote: > > > > On Wed, Jul 16, 2025 at 9:12 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote: > > > > > > > > > > On Wed, Jul 16, 2025 at 08:53:04PM +0800, Alex wrote: > > > > > > The logic is used to protect load/store tearing on 32 bit platforms, > > > > > > for example, after i_size_read returned, there is no guarantee that > > > > > > inode->size won't be changed. Therefore, READ/WRITE_ONCE suffice, which > > > > > > is already implied by smp_load_acquire/smp_store_release. > > > > > > > > > > Sorry, what? The problem is not a _later_ change, it's getting the > > > > > upper and lower 32bit halves from different values. > > > > > > > > > > Before: position is 0xffffffff > > > > > After: position is 0x100000000 > > > > > The value that might be returned by your variant: 0x1ffffffff. > > > > > > > > I mean the sequence lock here is used to only avoid load/store tearing, > > > > smp_load_acquire/smp_store_release already protects that. > > > > > > Why do you think that? You're wrong, but it'd be useful to understand > > > what misled you into thinking that. > > > > smp_load_acquire/smp_store_release implies READ_ONCE/WRITE_ONCE, > > and READ_ONCE/WRITE_ONCE avoid load/store tearing. > > > > What am I missing here? > > They only avoid tearing for sizes <= word size. If you have a 32-bit > CPU, they cannot avoid tearing for 64-bit loads/stores. You’re right, I got that wrong. Thanks for the clarification!