mm: memcontrol: constify mem_cgroup_swappiness() and mem_cgroup_get_max()

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

Link: https://lore.kernel.org/20260915-folio_memcg-const-v3-10-c239a6010b58@columbia.edu
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Barry Song <baohua@kernel.org>
Cc: Chris Li <chrisl@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
This commit is contained in:
Tal Zussman 2026-09-15 19:20:14 -04:00 committed by Andrew Morton
parent 56c44e678e
commit bc936f771a
3 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -1898,7 +1898,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);

View File

@ -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) &&