Re: [PATCH v5 1/5] mm/vmscan: introduce folio_activate_locked() helper

Barry Song <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm
Message-ID <CAGsJ_4x7W3Tgr_VNY+RLK_pXnFdehGGbjaVH29JsYipXGf7Z9g@mail.gmail.com>
On Mon, Jul 20, 2026 at 1:08 PM Zhang Peng <[email protected]> wrote:
>
> The activate_locked label in shrink_folio_list() reclaims swap cache
> when needed, marks the folio active, and updates activation statistics.
> Extract this block into folio_activate_locked() so it can be reused.
>
> No functional change.
>
> Signed-off-by: Zhang Peng <[email protected]>

Thanks,

Reviewed-by: Barry Song <[email protected]>

[...]

> + * Prepare a locked folio to be kept active rather than reclaimed.
> + * Reclaims its swap slot if it will not be swapped, then marks it

I'm not quite sure whether this should be "if". Because, it seems
to always be true up to this point. BTW, if we really want to use
"if", shouldn't we use it to check whether swap is full?

> + * active and updates activation statistics.
> + */
> +static void folio_activate_locked(struct folio *folio,
> +               struct reclaim_stat *stat)
> +{
> +       unsigned int nr_pages = folio_nr_pages(folio);
> +
> +       VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);
> +       VM_WARN_ON_ONCE_FOLIO(folio_test_active(folio), folio);
> +
> +       /* Not a candidate for swapping, so reclaim swap space. */
> +       if (folio_test_swapcache(folio) &&
> +           (mem_cgroup_swap_full(folio) || folio_test_mlocked(folio)))
> +               folio_free_swap(folio);

Best Regards
Barry
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.