Re: [PATCH 20/28] mm, swap: check swap table directly for checking cache

From: Baoquan He
Date: Fri Jun 20 2025 - 04:05:25 EST


On 06/19/25 at 06:50pm, Kairui Song wrote:
> On Thu, Jun 19, 2025 at 6:38 PM Baoquan He <bhe@xxxxxxxxxx> wrote:
> >
> > On 05/15/25 at 04:17am, Kairui Song wrote:
> > > From: Kairui Song <kasong@xxxxxxxxxxx>
> > >
> > > Instead of looking at the swap map, check swap table directly to tell if
> > > a swap entry has cache. Prepare for remove SWAP_HAS_CACHE.
> >
> > But you actually check both the swap table entry and swap map entry in
> > this patch, or do I miss anything?
>
> Hi, Baoquan
>
> >
> > E.g
> >
> > if (!swap_count(si->swap_map[offset]) && swp_te_is_folio(swp_te))
>
> Yes, the count info is still in the swap_map now, I'm only converting
> the HAS_CACHE check to use swp_te_t here. We'll remove swap_map in
> later patches and use the swp_te_t solely to get both info.

Ah, I see it now. That's why the subject is saying it's checking swap table
for checking cache. Then it's fine to me, even though it's a little
confusing.

>
> The reason some checks are added to check the swap_count is that:
> Before this patch, `swap_map[offset] == SWAP_HAS_CACHE` implies the
> count is zero too. So if HAS_CACHE is moved to swp_te_t, we still need
> to check the count separately. The overhead will be gone very soon in
> a later patch.

Got it, that sounds great, thanks.