Re: [PATCH v5 6/8] mm/shmem, swap: simplify swapin path and result handling

From: Kairui Song
Date: Fri Jul 11 2025 - 02:29:42 EST


On Fri, Jul 11, 2025 at 2:23 PM Baolin Wang
<baolin.wang@xxxxxxxxxxxxxxxxx> wrote:
>
>
>
> On 2025/7/10 11:37, Kairui Song wrote:
> > From: Kairui Song <kasong@xxxxxxxxxxx>
> >
> > Slightly tidy up the different handling of swap in and error handling
> > for SWP_SYNCHRONOUS_IO and non-SWP_SYNCHRONOUS_IO devices. Now swapin
> > will always use either shmem_swap_alloc_folio or shmem_swapin_cluster,
> > then check the result.
> >
> > Simplify the control flow and avoid a redundant goto label.
> >
> > Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
>
> LGTM, with a nit as follows.
> Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
>
> > ---
> > mm/shmem.c | 45 +++++++++++++++++++--------------------------
> > 1 file changed, 19 insertions(+), 26 deletions(-)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 847e6f128485..80f5b8c73eb8 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -2320,40 +2320,33 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
> > count_memcg_event_mm(fault_mm, PGMAJFAULT);
> > }
> >
> > - /* Skip swapcache for synchronous device. */
> > if (data_race(si->flags & SWP_SYNCHRONOUS_IO)) {
> > + /* Direct mTHP swapin skipping swap cache & readhaed */
> > folio = shmem_swap_alloc_folio(inode, vma, index, swap, order, gfp);
>
> Nit: the 'mTHP' word can be confusing, since we will skip swapcache for
> order 0 too. Please drop it.
>

Yes, thanks for the review.