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

Jason Gunthorpe jgg at nvidia.com
Tue Jan 16 05:41:02 AEDT 2024


On Wed, Jan 03, 2024 at 05:14:19PM +0800, peterx at redhat.com wrote:
> From: Peter Xu <peterx at redhat.com>
> 
> 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 <jthoughton at google.com>
> Signed-off-by: Peter Xu <peterx at redhat.com>
> ---
>  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 <jgg at nvidia.com>

Jason


More information about the Linuxppc-dev mailing list