mm: memcontrol: constify the swap accounting helpers

mem_cgroup_get_nr_swap_pages(), mem_cgroup_get_folio_swap_margin(), and
mem_cgroup_swap_full() only read swap counters and limits.  Constify them.

Remove externs from function declarations while at it.

Link: https://lore.kernel.org/20260915-folio_memcg-const-v3-9-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:13 -04:00 committed by Andrew Morton
parent d5c32fb2c2
commit 56c44e678e
2 changed files with 9 additions and 9 deletions

View File

@ -527,9 +527,9 @@ static inline void mem_cgroup_uncharge_swap(unsigned short id, unsigned int nr_p
__mem_cgroup_uncharge_swap(id, nr_pages);
}
long mem_cgroup_get_folio_swap_margin(struct folio *folio);
extern long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg);
extern bool mem_cgroup_swap_full(struct folio *folio);
long mem_cgroup_get_folio_swap_margin(const struct folio *folio);
long mem_cgroup_get_nr_swap_pages(const struct mem_cgroup *memcg);
bool mem_cgroup_swap_full(const struct folio *folio);
#else
static inline int mem_cgroup_try_charge_swap(struct folio *folio)
{
@ -541,17 +541,17 @@ static inline void mem_cgroup_uncharge_swap(unsigned short id,
{
}
static inline long mem_cgroup_get_folio_swap_margin(struct folio *folio)
static inline long mem_cgroup_get_folio_swap_margin(const struct folio *folio)
{
return PAGE_COUNTER_MAX;
}
static inline long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg)
static inline long mem_cgroup_get_nr_swap_pages(const struct mem_cgroup *memcg)
{
return get_nr_swap_pages();
}
static inline bool mem_cgroup_swap_full(struct folio *folio)
static inline bool mem_cgroup_swap_full(const struct folio *folio)
{
return vm_swap_full();
}

View File

@ -6017,7 +6017,7 @@ void __mem_cgroup_uncharge_swap(unsigned short id, unsigned int nr_pages)
rcu_read_unlock();
}
long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg)
long mem_cgroup_get_nr_swap_pages(const struct mem_cgroup *memcg)
{
long nr_swap_pages = get_nr_swap_pages();
@ -6033,7 +6033,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg)
*
* Return: Remaining chargeable pages in the folio's memcg hierarchy.
*/
long mem_cgroup_get_folio_swap_margin(struct folio *folio)
long mem_cgroup_get_folio_swap_margin(const struct folio *folio)
{
struct mem_cgroup *memcg;
long margin;
@ -6050,7 +6050,7 @@ long mem_cgroup_get_folio_swap_margin(struct folio *folio)
return margin;
}
bool mem_cgroup_swap_full(struct folio *folio)
bool mem_cgroup_swap_full(const struct folio *folio)
{
struct mem_cgroup *memcg;
bool ret = false;