Re: [PATCH v4 1/2] mm: store zero pages to be swapped out in a bitmap

From: Barry Song
Date: Fri Sep 06 2024 - 06:27:18 EST


On Fri, Sep 6, 2024 at 7:28 AM Yosry Ahmed <yosryahmed@xxxxxxxxxx> wrote:
>
> [..]
> > /*
> > * Check if all entries have consistent zeromap status, return true if
> > * all entries are zeromap or non-zeromap, else return false;
> > */
> > static inline bool swap_zeromap_entries_check(swp_entry_t entry, int nr)
>
> Let's also rename this now to swap_zeromap_entries_same(), "check" is
> a little vague.

Hi Yosry, Usama,
Thanks very much for your comments.

After further consideration, I have adopted a different approach that
offers more
flexibility than returning a boolean value and also has an equally low
implementation
cost:
https://lore.kernel.org/linux-mm/20240906001047.1245-2-21cnbao@xxxxxxxxx/

This is somewhat similar to Yosry's previous idea but does not reintroduce the
existing bug.

>
> > {
> > struct swap_info_struct *sis = swp_swap_info(entry);
> > unsigned long start = swp_offset(entry);
> > unsigned long end = start + *nr;
> >
> > if (find_next_bit(sis->zeromap, end, start) == end)
> > return true;
> > if (find_next_zero_bit(sis->zeromap, end, start) == end)
> > return true;
> >
> > return false;
> > }
> >

Thanks
Barry