Proactive reclaim/demote discussion (was Re: [PATCH] Revert "mm: add nodes= arg to memory.reclaim")

From: Huang, Ying
Date: Wed Jan 04 2023 - 03:43:00 EST


Michal Hocko <mhocko@xxxxxxxx> writes:

[snip]

> This really requires more discussion.

Let's start the discussion with some summary.

Requirements:

- Proactive reclaim. The counting of current per-memcg proactive
reclaim (memory.reclaim) isn't correct. The demoted, but not
reclaimed pages will be counted as reclaimed. So "echo XXM >
memory.reclaim" may exit prematurely before the specified number of
memory is reclaimed.

- Proactive demote. We need an interface to do per-memcg proactive
demote. We may reuse memory.reclaim via extending the concept of
reclaiming to include demoting. Or, we can add a new interface for
that (for example, memory.demote). In addition to demote from fast
tier to slow tier, in theory, we may need to demote from a set of
nodes to another set of nodes for something like general node
balancing.

- Proactive promote. In theory, this is possible, but there's no real
life requirements yet. And it should use a separate interface, so I
don't think we need to discuss that here.

Open questions:

- Use memory.reclaim or memory.demote for proactive demote. In current
memcg context, reclaiming and demoting is quite different, because
reclaiming will uncharge, while demoting will not. But if we will add
per-memory-tier charging finally, the difference disappears. So the
question becomes whether will we add per-memory-tier charging.

- Whether should we demote from faster tier nodes to lower tier nodes
during the proactive reclaiming. Choice A is to keep as much fast
memory as possible. That is, reclaim from the lowest tier nodes
firstly, then the secondary lowest tier nodes, and so on. Choice B is
to demote at the same time of reclaiming. In this way, if we
proactively reclaim XX MB memory, we may free XX MB memory on the
fastest memory nodes.

- When we proactively demote some memory from a fast memory tier, should
we trigger memory competition in the slower memory tiers? That is,
whether to wake up kswapd of the slower memory tiers nodes? If we
want to make per-memcg proactive demoting to be per-memcg strictly, we
should avoid to trigger the global behavior such as triggering memory
competition in the slower memory tiers. Instead, we can add a global
proactive demote interface for that (such as per-memory-tier or
per-node).

Best Regards,
Huang, Ying