[RFC PATCH 7/9 v2] mm/memcontrol: Make memory.low and memory.min tier-aware
From: Joshua Hahn
Date: Thu Apr 23 2026 - 16:42:57 EST
On machines serving multiple workloads whose memory is isolated via
the memory cgroup controller, it is currently impossible to enforce a
fair distribution of toptier memory among the workloads, as the only
enforceable limits have to do with total memory footprint, but not where
that memory resides.
This makes ensuring a consistent and baseline performance difficult, as
each workload's performance is heavily impacted by workload-external
factors such as which other workloads are co-located in the same host,
and the order at which different workloads are started.
Extend the existing memory.{low, min} protection to be tier-aware in
order to enforce proportional best-effort and guaranteed memory
protection of toptier memory.
Signed-off-by: Joshua Hahn <joshua.hahnjy@xxxxxxxxx>
---
include/linux/memcontrol.h | 8 ++++++++
mm/memcontrol.c | 3 +++
2 files changed, 11 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 6bcb866440075..2222b390ebf10 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -624,6 +624,10 @@ static inline bool mem_cgroup_below_low(struct mem_cgroup *target,
if (mem_cgroup_unprotected(target, memcg))
return false;
+ if (mem_cgroup_tiered_limits() && READ_ONCE(memcg->toptier.elow) >=
+ page_counter_read(&memcg->toptier))
+ return true;
+
return READ_ONCE(memcg->memory.elow) >=
page_counter_read(&memcg->memory);
}
@@ -634,6 +638,10 @@ static inline bool mem_cgroup_below_min(struct mem_cgroup *target,
if (mem_cgroup_unprotected(target, memcg))
return false;
+ if (mem_cgroup_tiered_limits() && READ_ONCE(memcg->toptier.emin) >=
+ page_counter_read(&memcg->toptier))
+ return true;
+
return READ_ONCE(memcg->memory.emin) >=
page_counter_read(&memcg->memory);
}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3fb1ee1d18603..b115ff40e268d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4933,6 +4933,9 @@ void mem_cgroup_calculate_protection(struct mem_cgroup *root,
root = root_mem_cgroup;
page_counter_calculate_protection(&root->memory, &memcg->memory, recursive_protection);
+ if (mem_cgroup_tiered_limits())
+ page_counter_calculate_protection(&root->toptier,
+ &memcg->toptier, recursive_protection);
}
static int charge_memcg(struct folio *folio, struct mem_cgroup *memcg,
--
2.52.0