On Wed, 24 May 2023, Peter Xu wrote: > On Sun, May 21, 2023 at 09:49:45PM -0700, Hugh Dickins wrote: > > Use pmdp_get_lockless() in preference to READ_ONCE(*pmdp), to get a more > > reliable result with PAE (or READ_ONCE as before without PAE); and remove > > the unnecessary extra barrier()s which got left behind in its callers. > > Pure question: does it mean that some of below path (missing barrier() > ones) could have problem when CONFIG_PAE, hence this can be seen as a > (potential) bug fix? I don't think so; or at least, I am not claiming that this fixes any. It really depends on what use is made of the pmdval afterwards, and I've not checked through them. The READ_ONCE()s which were there, were good enough to make sure that the compiler did not reevaluate the pmdval later on, with perhaps a confusingly different result. But, at least in the x86 PAE case, they were not good enough to ensure that the two halves of the entry match up; and, sad to say, nor is that absolutely guaranteed by these conversions to pmdp_get_lockless() - because of the "HOWEVER" below. PeterZ's comments in linux/pgtable.h are well worth reading through. You might question why I made these changes at all: some days I question them too. Better though imperfect? Or deceptive? Hugh > > > > HOWEVER: Note the small print in linux/pgtable.h, where it was designed > > specifically for fast GUP, and depends on interrupts being disabled for > > its full guarantee: most callers which have been added (here and before) > > do NOT have interrupts disabled, so there is still some need for caution.