Re: [PATCH v5 3/5] mm/vmscan: extract pageout_one() from shrink_folio_list()
From: Zhang Peng
Date: Sun Sep 20 2026 - 10:47:16 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:49 AM Barry Song <baohua@xxxxxxxxxx> wrote:
>
> Also, this patch looks basically good, just like the previous one.
> Could we also avoid hiding the activation semantics in the inner
> function? It would be clearer to make the activation semantics
> explicit at the outer level, so readers don't have to dig into a
> deep internal function to realize that a folio may take the
> activation path.
>
> In LRU, we have two distinct possibilities: activate a folio or just
> keep it. This is an important semantic distinction in the LRU logic.
> Hiding the activation decision so deep in an inner function makes
> that semantic much less obvious.
Done, same treatment as 2/5 - the helper reports the decision and the
caller acts on it:
enum folio_pageout_result {
FOLIO_PAGEOUT_KEEP_LOCKED,
FOLIO_PAGEOUT_KEEP_UNLOCKED,
FOLIO_PAGEOUT_ACTIVATE,
FOLIO_PAGEOUT_FREE, /* folio is locked, hand it to
folio_try_reclaim_free() */
};
switch (folio_try_pageout(folio, sc, &ctx, folio_list)) {
case FOLIO_PAGEOUT_ACTIVATE:
goto activate_locked;
case FOLIO_PAGEOUT_KEEP_LOCKED:
goto keep_locked;
case FOLIO_PAGEOUT_KEEP_UNLOCKED:
goto keep;
case FOLIO_PAGEOUT_FREE:
break; /* folio is locked; try to free it below */
}
Two things beyond what you asked for, both because pageout() has more
outcomes than the freeing path does:
- "keep" is split into KEEP_LOCKED and KEEP_UNLOCKED. pageout() can
return with the folio either still locked or already unlocked, and
previously the caller had to know which internal branch it came
from to pick between the keep_locked and keep labels. Now the
result says so.
- FOLIO_PAGEOUT_FREE keeps the "and now try to free it" step at the
outer level too, instead of chaining into folio_try_reclaim_free()
from inside folio_try_pageout().
This patch is in the cleanup-only series, see my reply on 5/5.
Thanks
Zhang Peng