Skip to content

mm: memcontrol: constify the read side of the memcg API

Tal Zussman cgroups linux-mm lkml 3 versions – Applied

Status from this message: [merged mm-stable] mm-memcontrol-constify-the-zswap-and-socket-pressure-helpers.patch removed from -mm tree

Get series with b4
b4 am [email protected] change-id 20260807-folio_memcg-const-4a67e40d485b

Versions newest first

  1. v3 Latest11 patches 15 repliesApplied 11/11
  2. v211 patches 1 replySuperseded
  3. v111 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- 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/[email protected]

Patches in v3 All 11 applied

#Subject and filesSizeRepliesApplied
1/11mm: memcontrol: take a const folio in folio_memcg() and friendsinclude/linux/memcontrol.h mm/memcontrol.c+29 -291 replyApplied
2/11mm: memcontrol: constify obj_cgroup_memcg() and friendsinclude/linux/memcontrol.h+4 -41 replyApplied
3/11mm: memcontrol: constify the lruvec helpersinclude/linux/memcontrol.h include/linux/mmzone.h mm/memcontrol.c+27 -271 replyApplied
4/11mm/page_io: take a const folio in bio_associate_blkg_from_folio()mm/page_io.c+9 -51 replyApplied
5/11mm: memcontrol: constify the mem_cgroup accessorsinclude/linux/memcontrol.h mm/memcontrol.c+23 -211 replyApplied
6/11mm: page_counter: constify page_counter_read() and page_counter_margin()include/linux/page_counter.h mm/page_counter.c+3 -31 replyApplied
7/11mm: memcontrol: constify the reclaim protection helpersinclude/linux/memcontrol.h+16 -161 replyApplied
8/11mm: memcontrol: constify the memcg and lruvec stat readersinclude/linux/memcontrol.h mm/memcontrol-v1.h mm/memcontrol.c+30 -291 replyApplied
9/11mm: memcontrol: constify the swap accounting helpersinclude/linux/swap.h mm/memcontrol.c+9 -91 replyApplied
10/11mm: memcontrol: constify mem_cgroup_swappiness() and mem_cgroup_get_max()include/linux/memcontrol.h mm/memcontrol.c mm/swap.h+4 -41 replyApplied
11/11mm: memcontrol: constify the zswap and socket pressure helpersinclude/linux/memcontrol.h mm/memcontrol.c+5 -51 replyApplied

Reviews trailers per patch

All 11 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMuchun SongShakeel ButtLorenzo Stoakes (ARM)
SeriesA-b A-b
1/11R-b
2/11R-b
3/11R-b
4/11R-b
5/11A-b
6/11R-b
7/11A-b
8/11A-b
9/11A-b
10/11A-b
11/11A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

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

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/[email protected]/

---
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/[email protected]

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/[email protected]

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

Signature · 1 line
Tal Zussman <[email protected]>