From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D782472096 for ; Wed, 16 Sep 2026 21:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789595689; cv=none; b=OJqr1NEPQtWvjNtWdbWtKUgEZcwybXYBGh8vTNSJfOhv0byUMA1QegwLNOvYdak4ZQ/3b46DJM5jg2YmjOpHiYPhEkCvjks4+JN5HVXu0B9H9ruXktwIsFBxwgRLTzcZPxOqeddgRiMKTGFzxJP7hkbPZxn7pbgrbOuyWbwS/j8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789595689; c=relaxed/simple; bh=syVdqjNyqHaSt0bFKgHsUA2nqyuX62SUPWHBYAItqeA=; h=Date:To:From:Subject:Message-Id; b=WQuKy3l7Xr5v3YAMtSg9HDg7bIILnPgKKGGl9eRY1Y8/Htw/0ZIfJ3LpzXVV5Aivg8gzyWFALOkP9Eh9j8Rq21Ge8B6+SFM5Iqk+WXkZjs+8KqjZKS1dDcPMBkPJCykw3m9oYse3fdSBAUEj4w/YrcZZ8nnrlogdPiIzh543K7M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=PtXh8iuf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="PtXh8iuf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DE901F00898; Wed, 16 Sep 2026 21:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1789595678; bh=om5qFFfBxFkLHc1KAeMM0/l8a7aIwitdBkpsljRHlvo=; h=Date:To:From:Subject; b=PtXh8iufbEOj27/5HridEOSZAjwUUdINQSg+xW/kw+fku1MEJQSKEkifjBt4c1xDG Otb6E94fZg0y1zq/kwM+IVBcXMEC7dCMqdE5qlYsjUQ1IIkhbeg/lF9ZMtmg6tIo6q /n7Q1Toz573auBYXeLf5kNXTKrHYRY1+602noQnA= Date: Wed, 16 Sep 2026 14:54:37 -0700 To: mm-commits@vger.kernel.org,tz2294@columbia.edu,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-memcontrol-constify-the-lruvec-helpers.patch added to mm-new branch Message-Id: <20260916215438.5DE901F00898@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm: memcontrol: constify the lruvec helpers has been added to the -mm mm-new branch. Its filename is mm-memcontrol-constify-the-lruvec-helpers.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcontrol-constify-the-lruvec-helpers.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 Subject: mm: memcontrol: constify the lruvec helpers Date: Tue, 15 Sep 2026 19:20:07 -0400 The lruvec lookup helpers only read from the memcg, folio, or lruvec they are given. Constify them, along with lruvec_pgdat() and the folio argument of the folio_lruvec_relock_irq() helpers. mem_cgroup_lruvec() may update lruvec->pgdat for a newly onlined node, but that lives in the per-node structure, not the memcg. Similarly, lruvec_pgdat() still returns a non-const pgdat and does not use container_of_const(). Use container_of_const() in lruvec_memcg() and mem_cgroup_get_zone_lru_size(), so the const isn't silently cast away. Link: https://lore.kernel.org/20260915-folio_memcg-const-v3-3-c239a6010b58@columbia.edu Signed-off-by: Tal Zussman Signed-off-by: Andrew Morton Reviewed-by: Muchun Song Acked-by: Shakeel Butt Acked-by: Lorenzo Stoakes (ARM) Cc: Axel Rasmussen Cc: Baolin Wang Cc: Baoquan He Cc: Barry Song Cc: Chris Li Cc: David Hildenbrand Cc: Johannes Weiner Cc: Kairui Song Cc: Kemeng Shi Cc: Liam R. Howlett Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Mike Rapoport Cc: Nhat Pham Cc: Roman Gushchin Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Wei Xu Cc: Yuanchu Xie --- include/linux/memcontrol.h | 46 +++++++++++++++++------------------ include/linux/mmzone.h | 2 - mm/memcontrol.c | 6 ++-- 3 files changed, 27 insertions(+), 27 deletions(-) --- a/include/linux/memcontrol.h~mm-memcontrol-constify-the-lruvec-helpers +++ a/include/linux/memcontrol.h @@ -722,7 +722,7 @@ void mem_cgroup_migrate(struct folio *ol * @pgdat combination. This can be the node lruvec, if the memory * controller is disabled. */ -static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, +static inline struct lruvec *mem_cgroup_lruvec(const struct mem_cgroup *memcg, struct pglist_data *pgdat) { struct mem_cgroup_per_node *mz; @@ -763,7 +763,7 @@ out: * their binding is stable if the returned lruvec matches the one the caller has * locked. Useful for lock batching. */ -static inline struct lruvec *folio_lruvec(struct folio *folio) +static inline struct lruvec *folio_lruvec(const struct folio *folio) { struct mem_cgroup *memcg = folio_memcg(folio); @@ -779,9 +779,9 @@ struct mem_cgroup *get_mem_cgroup_from_c 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); -struct lruvec *folio_lruvec_lock_irqsave(struct folio *folio, +struct lruvec *folio_lruvec_lock(const struct folio *folio); +struct lruvec *folio_lruvec_lock_irq(const struct folio *folio); +struct lruvec *folio_lruvec_lock_irqsave(const struct folio *folio, unsigned long *flags); static inline @@ -861,14 +861,14 @@ static inline struct mem_cgroup *mem_cgr return mem_cgroup_from_css(seq_css(m)); } -static inline struct mem_cgroup *lruvec_memcg(struct lruvec *lruvec) +static inline struct mem_cgroup *lruvec_memcg(const struct lruvec *lruvec) { - struct mem_cgroup_per_node *mz; + const struct mem_cgroup_per_node *mz; if (mem_cgroup_disabled()) return NULL; - mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec); + mz = container_of_const(lruvec, struct mem_cgroup_per_node, lruvec); return mz->memcg; } @@ -919,13 +919,13 @@ void mem_cgroup_update_lru_size(struct l int zid, long nr_pages); static inline -unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec, +unsigned long mem_cgroup_get_zone_lru_size(const struct lruvec *lruvec, enum lru_list lru, int zone_idx) { long val; - struct mem_cgroup_per_node *mz; + const struct mem_cgroup_per_node *mz; - mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec); + mz = container_of_const(lruvec, struct mem_cgroup_per_node, lruvec); val = READ_ONCE(mz->lru_zone_size[zone_idx][lru]); if (WARN_ON_ONCE(val < 0)) return 0; @@ -1215,13 +1215,13 @@ static inline void mem_cgroup_migrate(st { } -static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, +static inline struct lruvec *mem_cgroup_lruvec(const struct mem_cgroup *memcg, struct pglist_data *pgdat) { return &pgdat->__lruvec; } -static inline struct lruvec *folio_lruvec(struct folio *folio) +static inline struct lruvec *folio_lruvec(const struct folio *folio) { struct pglist_data *pgdat = folio_pgdat(folio); return &pgdat->__lruvec; @@ -1281,7 +1281,7 @@ static inline void mem_cgroup_put(struct { } -static inline struct lruvec *folio_lruvec_lock(struct folio *folio) +static inline struct lruvec *folio_lruvec_lock(const struct folio *folio) { struct pglist_data *pgdat = folio_pgdat(folio); @@ -1290,7 +1290,7 @@ static inline struct lruvec *folio_lruve return &pgdat->__lruvec; } -static inline struct lruvec *folio_lruvec_lock_irq(struct folio *folio) +static inline struct lruvec *folio_lruvec_lock_irq(const struct folio *folio) { struct pglist_data *pgdat = folio_pgdat(folio); @@ -1299,7 +1299,7 @@ static inline struct lruvec *folio_lruve return &pgdat->__lruvec; } -static inline struct lruvec *folio_lruvec_lock_irqsave(struct folio *folio, +static inline struct lruvec *folio_lruvec_lock_irqsave(const struct folio *folio, unsigned long *flagsp) { struct pglist_data *pgdat = folio_pgdat(folio); @@ -1354,7 +1354,7 @@ static inline struct mem_cgroup *mem_cgr return NULL; } -static inline struct mem_cgroup *lruvec_memcg(struct lruvec *lruvec) +static inline struct mem_cgroup *lruvec_memcg(const struct lruvec *lruvec) { return NULL; } @@ -1365,7 +1365,7 @@ static inline bool mem_cgroup_online(str } static inline -unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec, +unsigned long mem_cgroup_get_zone_lru_size(const struct lruvec *lruvec, enum lru_list lru, int zone_idx) { return 0; @@ -1505,7 +1505,7 @@ static inline void mem_cgroup_flush_work static inline int mem_cgroup_init(void) { return 0; } #endif /* CONFIG_MEMCG */ -static inline struct lruvec *parent_lruvec(struct lruvec *lruvec) +static inline struct lruvec *parent_lruvec(const struct lruvec *lruvec) { struct mem_cgroup *memcg; @@ -1568,15 +1568,15 @@ static inline void lruvec_unlock_irqrest } /* Test requires a stable folio->memcg binding, see folio_memcg() */ -static inline bool folio_matches_lruvec(struct folio *folio, - struct lruvec *lruvec) +static inline bool folio_matches_lruvec(const struct folio *folio, + const struct lruvec *lruvec) { return lruvec_pgdat(lruvec) == folio_pgdat(folio) && lruvec_memcg(lruvec) == folio_memcg(folio); } /* Don't lock again iff page's lruvec locked */ -static inline struct lruvec *folio_lruvec_relock_irq(struct folio *folio, +static inline struct lruvec *folio_lruvec_relock_irq(const struct folio *folio, struct lruvec *locked_lruvec) { if (locked_lruvec) { @@ -1590,7 +1590,7 @@ static inline struct lruvec *folio_lruve } /* Don't lock again iff folio's lruvec locked */ -static inline void folio_lruvec_relock_irqsave(struct folio *folio, +static inline void folio_lruvec_relock_irqsave(const struct folio *folio, struct lruvec **lruvecp, unsigned long *flags) { if (*lruvecp) { --- a/include/linux/mmzone.h~mm-memcontrol-constify-the-lruvec-helpers +++ a/include/linux/mmzone.h @@ -1661,7 +1661,7 @@ extern void init_currently_empty_zone(st extern void lruvec_init(struct lruvec *lruvec); -static inline struct pglist_data *lruvec_pgdat(struct lruvec *lruvec) +static inline struct pglist_data *lruvec_pgdat(const struct lruvec *lruvec) { #ifdef CONFIG_MEMCG return lruvec->pgdat; --- a/mm/memcontrol.c~mm-memcontrol-constify-the-lruvec-helpers +++ a/mm/memcontrol.c @@ -1463,7 +1463,7 @@ void mem_cgroup_scan_tasks(struct mem_cg * * Return: The lruvec this folio is on with its lock held and rcu read lock held. */ -struct lruvec *folio_lruvec_lock(struct folio *folio) +struct lruvec *folio_lruvec_lock(const struct folio *folio) { struct lruvec *lruvec; @@ -1491,7 +1491,7 @@ retry: * Return: The lruvec this folio is on with its lock held and interrupts * disabled and rcu read lock held. */ -struct lruvec *folio_lruvec_lock_irq(struct folio *folio) +struct lruvec *folio_lruvec_lock_irq(const struct folio *folio) { struct lruvec *lruvec; @@ -1520,7 +1520,7 @@ retry: * Return: The lruvec this folio is on with its lock held and interrupts * disabled and rcu read lock held. */ -struct lruvec *folio_lruvec_lock_irqsave(struct folio *folio, +struct lruvec *folio_lruvec_lock_irqsave(const struct folio *folio, unsigned long *flags) { struct lruvec *lruvec; _ 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