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

From: Barry Song

Date: Mon Aug 10 2026 - 04:43:00 EST


On Mon, Jul 20, 2026 at 1:08 PM Zhang Peng <zippermonkey@xxxxxxxxxx> 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 <bruzzhang@xxxxxxxxxxx>

Thanks,

Reviewed-by: Barry Song <baohua@xxxxxxxxxx>

[...]

> + * 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