Re: [PATCH v5 2/5] mm/vmscan: extract folio_free() from shrink_folio_list()
From: Zhang Peng
Date: Sun Sep 20 2026 - 10:45:37 EST
[Resending this one on its own - my first attempt accidentally sent
all four replies concatenated into a single mail, see
https://lore.kernel.org/all/20260920143816.39827-1-zippermonkey@xxxxxxxxxx/
Sorry for the noise.]
On Fri, Aug 14, 2026 at 5:40 AM Barry Song <baohua@xxxxxxxxxx> wrote:
>
> Could we avoid hiding the activate semantics inside
> folio_try_reclaim_free()? It makes the logic harder to read and
> can be confusing.
>
> Could we pull this out so that the three possible outcomes are
> explicit?
>
> 1. activate
> 2. keep
> 3. free
[...]
> I mean, this is confusing because an activated folio ends up in the
> "keep" path. Can we make the activation semantics explicit at the
> outer level?
Agreed, and thanks - the bool return was the root of it. The helper
now returns exactly the three outcomes you listed, and the caller,
not the helper, decides what to do with each:
enum folio_reclaim_result {
FOLIO_RECLAIM_KEEP,
FOLIO_RECLAIM_ACTIVATE,
FOLIO_RECLAIM_SUCCESS,
};
switch (folio_try_reclaim_free(folio, &free_folios, sc,
&nr_reclaimed)) {
case FOLIO_RECLAIM_ACTIVATE:
goto activate_locked;
case FOLIO_RECLAIM_KEEP:
goto keep_locked;
case FOLIO_RECLAIM_SUCCESS:
continue;
}
So there is no longer a folio_activate_locked() call inside the
helper at all, and an activated folio no longer disappears into the
"keep" path.
The patch has been respun on that basis and posted in a cleanup-only
series, see my reply on 5/5.
Thanks
Zhang Peng