Subject: Re: [PATCH v2 09/13] mm/gup: Cache *pudp in follow_pud_mask()

From: Jason Gunthorpe <[email-masked]>
Date: Mon, 15 Jan 2024 14:41:02 -0400

On Wed, Jan 03, 2024 at 05:14:19PM +0800, [email-masked] wrote:
> From: Peter Xu <[email-masked]>
> 
> Introduce "pud_t pud" in the function, so the code won't dereference *pudp
> multiple time.  Not only because that looks less straightforward, but also
> because if the dereference really happened, it's not clear whether there
> can be race to see different *pudp values if it's being modified at the
> same time.
> 
> Acked-by: James Houghton <[email-masked]>
> Signed-off-by: Peter Xu <[email-masked]>
> ---
>  mm/gup.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)

I think we have several more case like this, and I ceratinly agree
code should not access a READ_ONCE variable more than once :(

Reviewed-by: Jason Gunthorpe <[email-masked]>

Jason