Re: [PATCH 1/4] mm: Move demotion related functions in memory-tiers.c

David Hildenbrand (Arm)
2026-03-12T12:56:32Z

On 3/11/26 12:02, Alexandre Ghiti wrote:
> Let's have all the demotion functions in this file, no functional
> change intended.
>
> Suggested-by: Gregory Price <gourry@gourry.net>
> Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
> ---
> include/linux/memory-tiers.h | 18 ++++++++
> mm/memory-tiers.c | 75 +++++++++++++++++++++++++++++++++
> mm/vmscan.c | 80 +-----------------------------------
> 3 files changed, 94 insertions(+), 79 deletions(-)
>
> diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h
> index 96987d9d95a8..0bf0d002939e 100644
> --- a/include/linux/memory-tiers.h
> +++ b/include/linux/memory-tiers.h
> @@ -56,6 +56,9 @@ void mt_put_memory_types(struct list_head *memory_types);
> int next_demotion_node(int node, const nodemask_t *allowed_mask);
> void node_get_allowed_targets(pg_data_t *pgdat, nodemask_t *targets);
> bool node_is_toptier(int node);
> +unsigned int mt_demote_folios(struct list_head *demote_folios,
> + struct pglist_data *pgdat,
> + struct mem_cgroup *memcg);
> #else
> static inline int next_demotion_node(int node, const nodemask_t *allowed_mask)
> {
> @@ -71,6 +74,14 @@ static inline bool node_is_toptier(int node)
> {
> return true;
> }
> +
> +static inline unsigned int mt_demote_folios(struct list_head *demote_folios,
> + struct pglist_data *pgdat,
> + struct mem_cgroup *memcg)

use two-tab indentation on second parameter line please. So this fits
into a single line. Same for the other functions.

Just like alloc_demote_folio() that you are moving already did.

[...]

> -static struct folio *alloc_demote_folio(struct folio *src,
> - unsigned long private)
> -{
> - struct folio *dst;
> - nodemask_t *allowed_mask;
> - struct migration_target_control *mtc;
> -
> - mtc = (struct migration_target_control *)private;
> -
> - allowed_mask = mtc->nmask;
> - /*
> - * make sure we allocate from the target node first also trying to
> - * demote or reclaim pages from the target node via kswapd if we are
> - * low on free memory on target node. If we don't do this and if
> - * we have free memory on the slower(lower) memtier, we would start
> - * allocating pages from slower(lower) memory tiers without even forcing
> - * a demotion of cold pages from the target memtier. This can result
> - * in the kernel placing hot pages in slower(lower) memory tiers.
> - */
> - mtc->nmask = NULL;
> - mtc->gfp_mask |= __GFP_THISNODE;
> - dst = alloc_migration_target(src, (unsigned long)mtc);
> - if (dst)
> - return dst;
> -
> - mtc->gfp_mask &= ~__GFP_THISNODE;
> - mtc->nmask = allowed_mask;
> -

I think this function changed in the meantime in mm/mm-unstable. Against
which branch is this patch?

--
Cheers,

David