All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongfu Li <hongfu.li@linux.dev>
To: akpm@linux-foundation.org
Cc: david@kernel.org, hongfu.li@linux.dev, liam@infradead.org,
	lihongfu@kylinos.cn, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, ljs@kernel.org, mhocko@suse.com,
	rppt@kernel.org, surenb@google.com, vbabka@kernel.org
Subject: Re: [PATCH] mm/memory: use folio lock/ref helpers in do_swap_page
Date: Wed, 22 Jul 2026 14:23:15 +0800	[thread overview]
Message-ID: <20260722062315.43584-1-hongfu.li@linux.dev> (raw)
In-Reply-To: <20260721180232.0984ad6fd55ad43053b3a079@linux-foundation.org>

> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -4852,6 +4852,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> >  			vmf->page = softleaf_to_page(entry);
> >  			ret = remove_device_exclusive_entry(vmf);
> >  		} else if (softleaf_is_device_private(entry)) {
> > +			struct folio *fault_folio;
> > +
> >  			if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
> >  				/*
> >  				 * migrate_to_ram is not yet ready to operate
> > @@ -4863,6 +4865,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> >  			}
> >  
> >  			vmf->page = softleaf_to_page(entry);
> > +			fault_folio = page_folio(vmf->page);
> >  			vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd,
> >  					vmf->address, &vmf->ptl);
> 
> AI review thinks we shouldn't be reading vmf->page until after taking
> the page table lock:
> 
> 	https://sashiko.dev/#/patchset/20260721013347.65698-1-hongfu.li@linux.dev

Thanks for the review.

The AI review makes a valid observation: `vmf->page` should not be accessed
before holding the page table lock.

I've moved `fault_folio = page_folio(vmf->page)` after `pte_offset_map_lock()`
and the PTE validation check, so `vmf->page` is now read under the page table
lock. This fix will be included in v2.

Best regards,
Hongfu

  reply	other threads:[~2026-07-22  6:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  1:33 [PATCH] mm/memory: use folio lock/ref helpers in do_swap_page Hongfu Li
2026-07-21 10:21 ` David Hildenbrand (Arm)
2026-07-22  1:02 ` Andrew Morton
2026-07-22  6:23   ` Hongfu Li [this message]
2026-07-22  1:25 ` Matthew Wilcox
2026-07-22  7:46   ` Hongfu Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260722062315.43584-1-hongfu.li@linux.dev \
    --to=hongfu.li@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=lihongfu@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.