v2 2026-09-09

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

将memcg访问器、lruvec/统计读取等API改为const入参,扩大memcg API只读侧的const限定。

原始补丁链接

子 Patch(11)

1/11
mm: memcontrol: take a const folio in folio_memcg() and friends
[mm: memcontrol: take a const folio in folio_memcg() and friends] The folio_memcg() family only reads from the folio, and everything it calls already takes a const folio. Constify it, along with the p
2/11
mm: memcontrol: constify obj_cgroup_memcg() and friends
[mm: memcontrol: constify obj_cgroup_memcg() and friends] obj_cgroup_memcg() and get_mem_cgroup_from_objcg() only read from the objcg. Constify them. Signed-off-by: Tal Zussman tz2294@columbia.edu
3/11
mm: memcontrol: constify the lruvec helpers
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_cgrou
4/11
mm/page_io: take a const folio in bio_associate_blkg_from_folio()
[mm/page_io: take a const folio in bio_associate_blkg_from_folio()] bio_associate_blkg_from_folio() and its helpers only read from the folio. Constify their folio arguments. Signed-off-by: Tal Zussma
5/11
mm: memcontrol: constify the mem_cgroup accessors
mem_cgroup_id(), parent_mem_cgroup(), mem_cgroup_is_root(), mem_cgroup_is_descendant(), memcg_kmem_id(), and the other memcg accessors only read from the memcg. Constify them, along with mem_cgroup_sh
6/11
mm: page_counter: constify page_counter_read() and page_counter_margin()
[mm: page_counter: constify page_counter_read() and page_counter_margin()] Both only read the counter. Constify them so that users can read counters from const memcgs. Signed-off-by: Tal Zussman <tz2
7/11
mm: memcontrol: constify the reclaim protection helpers
[mm: memcontrol: constify the reclaim protection helpers] mem_cgroup_protection(), mem_cgroup_unprotected(), mem_cgroup_below_low(), and mem_cgroup_below_min() only read the protection state. Constify
8/11
mm: memcontrol: constify the memcg and lruvec stat readers
[mm: memcontrol: constify the memcg and lruvec stat readers] memcg_page_state(), memcg_events(), and the lruvec_page_state() family only read counters. Constify them. Use container_of_const() in the
9/11
mm: memcontrol: constify the swap accounting helpers
[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.
10/11
mm: memcontrol: constify mem_cgroup_swappiness() and mem_cgroup_get_max()
[mm: memcontrol: constify mem_cgroup_swappiness() and mem_cgroup_get_max()] Both only read swappiness and the memory limits. Constify them. Signed-off-by: Tal Zussman tz2294@columbia.edu — inclu
11/11
mm: memcontrol: constify the zswap and socket pressure helpers
[mm: memcontrol: constify the zswap and socket pressure helpers] mem_cgroup_zswap_writeback_enabled() only reads the zswap_writeback flags, and mem_cgroup_get_socket_pressure() only reads the socket p