[PATCH v3 00/11] mm: memcontrol: constify the read side of the memcg API

Tal Zussman posted 11 patches 1 week, 2 days ago
include/linux/memcontrol.h   | 212 ++++++++++++++++++++++---------------------
include/linux/mmzone.h       |   2 +-
include/linux/page_counter.h |   4 +-
include/linux/swap.h         |  12 +--
mm/memcontrol-v1.h           |   6 +-
mm/memcontrol.c              |  57 ++++++------
mm/page_counter.c            |   2 +-
mm/page_io.c                 |  14 ++-
mm/swap.h                    |   2 +-
9 files changed, 159 insertions(+), 152 deletions(-)
[PATCH v3 00/11] mm: memcontrol: constify the read side of the memcg API
Posted by Tal Zussman 1 week, 2 days ago
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 started as a follow-up to [1] that quickly grew in proportions :)

[1]: https://lore.kernel.org/linux-mm/anYqSDnC2BbJXv1h@casper.infradead.org/

---
Changes in v3:
- Patch 1: Constify get_obj_cgroup_from_folio() as well, per Sashiko
- Patch 3: Use container_of_const() in mem_cgroup_get_zone_lru_size(),
  per Sashiko
- Patch 3: Note that lruvec_pgdat() still returns a non-const pgdat and
  does not use container_of_const()
- Patch 8: Constify the local memcg stat readers as well, per Sashiko
- Link to v2: https://patch.msgid.link/20260908-folio_memcg-const-v2-0-811e9f443409@columbia.edu

Changes in v2:
- Patch 3: Constify the folio argument of folio_lruvec_relock_irq() and
  folio_lruvec_relock_irqsave() as well, per Sashiko
- Patch 3: Note that mem_cgroup_lruvec() updates lruvec->pgdat in the
  per-node structure, not the memcg, per Sashiko
- Patches 3 and 8: Use container_of_const() in lruvec_memcg() and the
  lruvec_page_state() family, per Sashiko
- Link to v1: https://patch.msgid.link/20260902-folio_memcg-const-v1-0-e2c1da22246d@columbia.edu

---
Tal Zussman (11):
      mm: memcontrol: take a const folio in folio_memcg() and friends
      mm: memcontrol: constify obj_cgroup_memcg() and friends
      mm: memcontrol: constify the lruvec helpers
      mm/page_io: take a const folio in bio_associate_blkg_from_folio()
      mm: memcontrol: constify the mem_cgroup accessors
      mm: page_counter: constify page_counter_read() and page_counter_margin()
      mm: memcontrol: constify the reclaim protection helpers
      mm: memcontrol: constify the memcg and lruvec stat readers
      mm: memcontrol: constify the swap accounting helpers
      mm: memcontrol: constify mem_cgroup_swappiness() and mem_cgroup_get_max()
      mm: memcontrol: constify the zswap and socket pressure helpers

 include/linux/memcontrol.h   | 212 ++++++++++++++++++++++---------------------
 include/linux/mmzone.h       |   2 +-
 include/linux/page_counter.h |   4 +-
 include/linux/swap.h         |  12 +--
 mm/memcontrol-v1.h           |   6 +-
 mm/memcontrol.c              |  57 ++++++------
 mm/page_counter.c            |   2 +-
 mm/page_io.c                 |  14 ++-
 mm/swap.h                    |   2 +-
 9 files changed, 159 insertions(+), 152 deletions(-)
---
base-commit: b08a65b93426d86e3f354d655d6225397b591877
change-id: 20260807-folio_memcg-const-4a67e40d485b

Best regards,
--  
Tal Zussman <tz2294@columbia.edu>
Re: [PATCH v3 00/11] mm: memcontrol: constify the read side of the memcg API
Posted by Andrew Morton 1 week, 1 day ago
On Tue, 15 Sep 2026 19:20:04 -0400 Tal Zussman <tz2294@columbia.edu> wrote:

> 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.

Thanks, all queued in mm.git's mm-new branch.
Re: [PATCH v3 00/11] mm: memcontrol: constify the read side of the memcg API
Posted by Shakeel Butt 1 week, 2 days ago
On Tue, Sep 15, 2026 at 07:20:04PM -0400, Tal Zussman wrote:
> 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 started as a follow-up to [1] that quickly grew in proportions :)
> 
> [1]: https://lore.kernel.org/linux-mm/anYqSDnC2BbJXv1h@casper.infradead.org/

For the whole series:

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Re: [PATCH v3 00/11] mm: memcontrol: constify the read side of the memcg API
Posted by Lorenzo Stoakes (ARM) 1 week, 1 day ago
On Tue, Sep 15, 2026 at 08:53:10PM -0700, Shakeel Butt wrote:
> On Tue, Sep 15, 2026 at 07:20:04PM -0400, Tal Zussman wrote:
> > 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 started as a follow-up to [1] that quickly grew in proportions :)
> >
> > [1]: https://lore.kernel.org/linux-mm/anYqSDnC2BbJXv1h@casper.infradead.org/
>
> For the whole series:
>
> Acked-by: Shakeel Butt <shakeel.butt@linux.dev>

Oops, I replied on the v2 with the same:

https://lore.kernel.org/linux-mm/aqqaaDqTDahlZ7bR@gremlin/

but obviously, equally so for v3 :) thanks for doing this!

For whole series:

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

--
Cheers, Lorenzo
Re: [PATCH v3 00/11] mm: memcontrol: constify the read side of the memcg API
Posted by Tal Zussman 1 week, 1 day ago
On 9/16/26 1:28 PM, Lorenzo Stoakes (ARM) wrote:
> but obviously, equally so for v3 :) thanks for doing this!
> 
> For whole series:
> 
> Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> 

Thanks Lorenzo, Shakeel, and Muchun for the reviews!