* + mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends.patch added to mm-new branch
@ 2026-09-16 21:54 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-09-16 21:54 UTC (permalink / raw)
To: mm-commits, tz2294, akpm
The patch titled
Subject: mm: memcontrol: take a const folio in folio_memcg() and friends
has been added to the -mm mm-new branch. Its filename is
mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Tal Zussman <tz2294@columbia.edu>
Subject: mm: memcontrol: take a const folio in folio_memcg() and friends
Date: Tue, 15 Sep 2026 19:20:05 -0400
Patch series "mm: memcontrol: constify the read side of the read side of
the memcg API", v3.
The memcg accessors, lruvec helpers, and stat readers only read from the
memcg, folio, or lruvec they are given, but take non-const pointers.
Constify them, along with the page_counter readers and the swap I/O blkg
helpers along the way.
This patch (of 11):
The folio_memcg() family only reads from the folio, and everything it
calls already takes a const folio. Constify it, along with the page
wrappers built on top of it and get_obj_cgroup_from_folio(), which only
reads the folio's objcg.
Link: https://lore.kernel.org/20260915-folio_memcg-const-v3-0-c239a6010b58@columbia.edu
Link: https://lore.kernel.org/20260915-folio_memcg-const-v3-1-c239a6010b58@columbia.edu
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-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>
---
include/linux/memcontrol.h | 50 +++++++++++++++++------------------
mm/memcontrol.c | 8 ++---
2 files changed, 29 insertions(+), 29 deletions(-)
--- a/include/linux/memcontrol.h~mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends
+++ a/include/linux/memcontrol.h
@@ -410,7 +410,7 @@ static inline struct mem_cgroup *obj_cgr
* or NULL. This function assumes that the folio is known to have a
* proper object cgroup pointer.
*/
-static inline struct obj_cgroup *folio_objcg(struct folio *folio)
+static inline struct obj_cgroup *folio_objcg(const struct folio *folio)
{
unsigned long memcg_data = folio->memcg_data;
@@ -448,7 +448,7 @@ static inline struct obj_cgroup *folio_o
* Note: The caller should hold an rcu read lock or cgroup_mutex to protect
* memcg associated with a folio from being released.
*/
-static inline struct mem_cgroup *folio_memcg(struct folio *folio)
+static inline struct mem_cgroup *folio_memcg(const struct folio *folio)
{
struct obj_cgroup *objcg = folio_objcg(folio);
@@ -461,7 +461,7 @@ static inline struct mem_cgroup *folio_m
*
* Returns true if folio is charged to a memory cgroup, otherwise returns false.
*/
-static inline bool folio_memcg_charged(struct folio *folio)
+static inline bool folio_memcg_charged(const struct folio *folio)
{
return folio->memcg_data != 0;
}
@@ -481,7 +481,7 @@ static inline bool folio_memcg_charged(s
* A caller should hold an rcu read lock to protect memcg associated with a
* page from being released.
*/
-static inline struct mem_cgroup *folio_memcg_check(struct folio *folio)
+static inline struct mem_cgroup *folio_memcg_check(const struct folio *folio)
{
/*
* Because folio->memcg_data might be changed asynchronously
@@ -498,11 +498,11 @@ static inline struct mem_cgroup *folio_m
return obj_cgroup_memcg(objcg);
}
-static inline struct mem_cgroup *page_memcg_check(struct page *page)
+static inline struct mem_cgroup *page_memcg_check(const struct page *page)
{
if (PageTail(page))
return NULL;
- return folio_memcg_check((struct folio *)page);
+ return folio_memcg_check((const struct folio *)page);
}
static inline struct mem_cgroup *get_mem_cgroup_from_objcg(struct obj_cgroup *objcg)
@@ -527,14 +527,14 @@ retry:
* that the folio has an associated memory cgroup. It's not safe to call
* this function against some types of folios, e.g. slab folios.
*/
-static inline bool folio_memcg_kmem(struct folio *folio)
+static inline bool folio_memcg_kmem(const struct folio *folio)
{
VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
VM_BUG_ON_FOLIO(folio->memcg_data & MEMCG_DATA_OBJEXTS, folio);
return folio->memcg_data & MEMCG_DATA_KMEM;
}
-static inline bool PageMemcgKmem(struct page *page)
+static inline bool PageMemcgKmem(const struct page *page)
{
return folio_memcg_kmem(page_folio(page));
}
@@ -777,7 +777,7 @@ struct mem_cgroup *get_mem_cgroup_from_m
struct mem_cgroup *get_mem_cgroup_from_current(void);
-struct mem_cgroup *get_mem_cgroup_from_folio(struct folio *folio);
+struct mem_cgroup *get_mem_cgroup_from_folio(const struct folio *folio);
struct lruvec *folio_lruvec_lock(struct folio *folio);
struct lruvec *folio_lruvec_lock_irq(struct folio *folio);
@@ -905,8 +905,8 @@ static inline bool mm_match_cgroup(struc
return match;
}
-struct cgroup_subsys_state *get_mem_cgroup_css_from_folio(struct folio *folio);
-ino_t page_cgroup_ino(struct page *page);
+struct cgroup_subsys_state *get_mem_cgroup_css_from_folio(const struct folio *folio);
+ino_t page_cgroup_ino(const struct page *page);
static inline bool mem_cgroup_online(struct mem_cgroup *memcg)
{
@@ -956,7 +956,7 @@ void mem_cgroup_print_oom_group(struct m
void mod_memcg_state(struct mem_cgroup *memcg,
enum memcg_stat_item idx, int val);
-static inline void mod_memcg_page_state(struct page *page,
+static inline void mod_memcg_page_state(const struct page *page,
enum memcg_stat_item idx, int val)
{
struct mem_cgroup *memcg;
@@ -990,7 +990,7 @@ void mod_lruvec_kmem_state(void *p, enum
void count_memcg_events(struct mem_cgroup *memcg, enum vm_event_item idx,
unsigned long count);
-static inline void count_memcg_folio_events(struct folio *folio,
+static inline void count_memcg_folio_events(const struct folio *folio,
enum vm_event_item idx, unsigned long nr)
{
struct mem_cgroup *memcg;
@@ -1084,22 +1084,22 @@ static inline struct mem_cgroup *obj_cgr
#define root_mem_cgroup (NULL)
-static inline struct mem_cgroup *folio_memcg(struct folio *folio)
+static inline struct mem_cgroup *folio_memcg(const struct folio *folio)
{
return NULL;
}
-static inline bool folio_memcg_charged(struct folio *folio)
+static inline bool folio_memcg_charged(const struct folio *folio)
{
return false;
}
-static inline struct mem_cgroup *folio_memcg_check(struct folio *folio)
+static inline struct mem_cgroup *folio_memcg_check(const struct folio *folio)
{
return NULL;
}
-static inline struct mem_cgroup *page_memcg_check(struct page *page)
+static inline struct mem_cgroup *page_memcg_check(const struct page *page)
{
return NULL;
}
@@ -1109,12 +1109,12 @@ static inline struct mem_cgroup *get_mem
return NULL;
}
-static inline bool folio_memcg_kmem(struct folio *folio)
+static inline bool folio_memcg_kmem(const struct folio *folio)
{
return false;
}
-static inline bool PageMemcgKmem(struct page *page)
+static inline bool PageMemcgKmem(const struct page *page)
{
return false;
}
@@ -1248,7 +1248,7 @@ static inline struct mem_cgroup *get_mem
return NULL;
}
-static inline struct mem_cgroup *get_mem_cgroup_from_folio(struct folio *folio)
+static inline struct mem_cgroup *get_mem_cgroup_from_folio(const struct folio *folio)
{
return NULL;
}
@@ -1406,7 +1406,7 @@ static inline void mod_memcg_state(struc
{
}
-static inline void mod_memcg_page_state(struct page *page,
+static inline void mod_memcg_page_state(const struct page *page,
enum memcg_stat_item idx, int val)
{
}
@@ -1471,7 +1471,7 @@ static inline void count_memcg_events(st
{
}
-static inline void count_memcg_folio_events(struct folio *folio,
+static inline void count_memcg_folio_events(const struct folio *folio,
enum vm_event_item idx, unsigned long nr)
{
}
@@ -1767,7 +1767,7 @@ void __memcg_kmem_uncharge_page(struct p
* needs to be used outside of the local scope.
*/
struct obj_cgroup *current_obj_cgroup(void);
-struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio);
+struct obj_cgroup *get_obj_cgroup_from_folio(const struct folio *folio);
static inline struct obj_cgroup *get_obj_cgroup_from_current(void)
{
@@ -1870,7 +1870,7 @@ static inline void __memcg_kmem_uncharge
{
}
-static inline struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio)
+static inline struct obj_cgroup *get_obj_cgroup_from_folio(const struct folio *folio)
{
return NULL;
}
@@ -1901,7 +1901,7 @@ static inline void count_objcg_events(st
{
}
-static inline ino_t page_cgroup_ino(struct page *page)
+static inline ino_t page_cgroup_ino(const struct page *page)
{
return 0;
}
--- a/mm/memcontrol.c~mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends
+++ a/mm/memcontrol.c
@@ -332,7 +332,7 @@ EXPORT_SYMBOL(memcg_bpf_enabled_key);
* If memcg is bound to a traditional hierarchy, the css of root_mem_cgroup
* is returned.
*/
-struct cgroup_subsys_state *get_mem_cgroup_css_from_folio(struct folio *folio)
+struct cgroup_subsys_state *get_mem_cgroup_css_from_folio(const struct folio *folio)
{
struct mem_cgroup *memcg;
@@ -357,7 +357,7 @@ struct cgroup_subsys_state *get_mem_cgro
* after page_cgroup_ino() returns, so it only should be used by callers that
* do not care (such as procfs interfaces).
*/
-ino_t page_cgroup_ino(struct page *page)
+ino_t page_cgroup_ino(const struct page *page)
{
struct mem_cgroup *memcg;
unsigned long ino = 0;
@@ -1242,7 +1242,7 @@ again:
*
* See folio_memcg() for folio->objcg/memcg binding rules.
*/
-struct mem_cgroup *get_mem_cgroup_from_folio(struct folio *folio)
+struct mem_cgroup *get_mem_cgroup_from_folio(const struct folio *folio)
{
struct mem_cgroup *memcg;
@@ -3140,7 +3140,7 @@ from_memcg:
return rcu_dereference_check(root_mem_cgroup->nodeinfo[nid]->objcg, 1);
}
-struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio)
+struct obj_cgroup *get_obj_cgroup_from_folio(const struct folio *folio)
{
struct obj_cgroup *objcg;
_
Patches currently in -mm which might be from tz2294@columbia.edu are
mm-page_io-convert-write-completion-handlers-to-folios.patch
mm-remove-pagereclaim.patch
mm-page_io-use-swap-entries-directly-in-zeromap-helpers.patch
mm-page_io-rename-bio_associate_blkg_from_page.patch
mm-page_io-refer-to-folios-in-swap_writeout-comments.patch
mm-swap-rename-__swap_writepage-to-__swap_writeout.patch
mm-remove-unused-mark_page_reserved.patch
mm-remove-unused-totalram_pages_inc-and-totalram_pages_dec.patch
mm-remove-pagewriteback.patch
mm-swap-add-folio_swap_entry-and-folio_page_swap_entry.patch
mm-swap-add-folio_swap_entry-and-folio_page_swap_entry-fix.patch
mm-huge_memory-add-a-comment-to-the-open-coded-swap-entry.patch
mm-rmap-use-folio_page_swap_entry-in-ttu_anon_swapbacked_folio.patch
mm-zswap-use-folio_swap_entry-in-zswap_store_page.patch
mm-swapfile-use-folio_page_swap_entry.patch
arm64-mte-make-mte_save_tags-and-mte_restore_tags-static.patch
arm64-mte-pass-the-swap-entry-to-mte_save_tags.patch
mm-swap-remove-page_swap_entry.patch
mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends.patch
mm-memcontrol-constify-obj_cgroup_memcg-and-friends.patch
mm-memcontrol-constify-the-lruvec-helpers.patch
mm-page_io-take-a-const-folio-in-bio_associate_blkg_from_folio.patch
mm-memcontrol-constify-the-mem_cgroup-accessors.patch
mm-page_counter-constify-page_counter_read-and-page_counter_margin.patch
mm-memcontrol-constify-the-reclaim-protection-helpers.patch
mm-memcontrol-constify-the-memcg-and-lruvec-stat-readers.patch
mm-memcontrol-constify-the-swap-accounting-helpers.patch
mm-memcontrol-constify-mem_cgroup_swappiness-and-mem_cgroup_get_max.patch
mm-memcontrol-constify-the-zswap-and-socket-pressure-helpers.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-16 21:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 21:54 + mm-memcontrol-take-a-const-folio-in-folio_memcg-and-friends.patch added to mm-new branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.