[PATCH 10/11] mm: memcontrol: constify mem_cgroup_swappiness() and mem_cgroup_get_max()

From: Tal Zussman

Date: Wed Sep 02 2026 - 16:34:27 EST


Both only read swappiness and the memory limits. Constify them.

Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
include/linux/memcontrol.h | 4 ++--
mm/memcontrol.c | 2 +-
mm/swap.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 10a197886f31..2d5e43dbec4d 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -902,7 +902,7 @@ static inline void mem_cgroup_handle_over_high(gfp_t gfp_mask)
__mem_cgroup_handle_over_high(gfp_mask);
}

-unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg);
+unsigned long mem_cgroup_get_max(const struct mem_cgroup *memcg);

void mem_cgroup_print_oom_context(const struct mem_cgroup *memcg,
struct task_struct *p);
@@ -1332,7 +1332,7 @@ unsigned long mem_cgroup_get_zone_lru_size(const struct lruvec *lruvec,
return 0;
}

-static inline unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg)
+static inline unsigned long mem_cgroup_get_max(const struct mem_cgroup *memcg)
{
return 0;
}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2b8705a88f6a..e28b2a4f278d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1878,7 +1878,7 @@ void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
/*
* Return the memory (and swap, if configured) limit for a memcg.
*/
-unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg)
+unsigned long mem_cgroup_get_max(const struct mem_cgroup *memcg)
{
unsigned long max = READ_ONCE(memcg->memory.max);

diff --git a/mm/swap.h b/mm/swap.h
index 0b5d507739bc..94714d9dd003 100644
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -82,7 +82,7 @@ enum swap_cluster_flags {

extern int vm_swappiness;

-static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)
+static inline int mem_cgroup_swappiness(const struct mem_cgroup *memcg)
{
#ifdef CONFIG_MEMCG_V1
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) &&

--
2.39.5