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

From: Tal Zussman

Date: Tue Sep 08 2026 - 13:41:38 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 d8600f1444df..9fade4667d9b 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -941,7 +941,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);
@@ -1372,7 +1372,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 0fcc0ff587fc..4de2aee45ac8 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1884,7 +1884,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