* [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask
@ 2026-06-09 0:29 Gregory Price
2026-06-09 1:44 ` Zi Yan
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Gregory Price @ 2026-06-09 0:29 UTC (permalink / raw)
To: linux-mm
Cc: linux-kernel, cgroups, kernel-team, longman, chenridong, akpm,
david, ljs, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng,
shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes,
chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes,
mkoutny, jackmanb, ziy
The nodemasks in these structures may come from a variety of sources,
including tasks and cpusets - and should never be modified by any code
when being passed around inside another context.
Signed-off-by: Gregory Price <gourry@gourry.net>
---
include/linux/cpuset.h | 4 ++--
include/linux/mm.h | 4 ++--
include/linux/mmzone.h | 6 +++---
include/linux/oom.h | 2 +-
include/linux/swap.h | 2 +-
kernel/cgroup/cpuset.c | 2 +-
mm/internal.h | 2 +-
mm/mmzone.c | 5 +++--
mm/page_alloc.c | 6 +++---
mm/show_mem.c | 9 ++++++---
mm/vmscan.c | 6 +++---
11 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 65d76a38974b..a80d38e752d2 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -83,7 +83,7 @@ extern bool cpuset_cpus_allowed_fallback(struct task_struct *p);
extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
#define cpuset_current_mems_allowed (current->mems_allowed)
void cpuset_init_current_mems_allowed(void);
-int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
+int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask);
extern bool cpuset_current_node_allowed(int node, gfp_t gfp_mask);
@@ -224,7 +224,7 @@ static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
#define cpuset_current_mems_allowed (node_states[N_MEMORY])
static inline void cpuset_init_current_mems_allowed(void) {}
-static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
+static inline int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask)
{
return 1;
}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 485df9c2dbdd..2101e5205fc0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4042,7 +4042,7 @@ extern int __meminit early_pfn_to_nid(unsigned long pfn);
extern void mem_init(void);
extern void __init mmap_init(void);
-extern void __show_mem(unsigned int flags, nodemask_t *nodemask, int max_zone_idx);
+extern void __show_mem(unsigned int flags, const nodemask_t *nodemask, int max_zone_idx);
static inline void show_mem(void)
{
__show_mem(0, NULL, MAX_NR_ZONES - 1);
@@ -4052,7 +4052,7 @@ extern void si_meminfo(struct sysinfo * val);
extern void si_meminfo_node(struct sysinfo *val, int nid);
extern __printf(3, 4)
-void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...);
+void warn_alloc(gfp_t gfp_mask, const nodemask_t *nodemask, const char *fmt, ...);
extern void setup_per_cpu_pageset(void);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index ca2712187147..919be0d9b4fa 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1815,7 +1815,7 @@ static inline int zonelist_node_idx(const struct zoneref *zoneref)
struct zoneref *__next_zones_zonelist(struct zoneref *z,
enum zone_type highest_zoneidx,
- nodemask_t *nodes);
+ const nodemask_t *nodes);
/**
* next_zones_zonelist - Returns the next zone at or below highest_zoneidx within the allowed nodemask using a cursor within a zonelist as a starting point
@@ -1834,7 +1834,7 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z,
*/
static __always_inline struct zoneref *next_zones_zonelist(struct zoneref *z,
enum zone_type highest_zoneidx,
- nodemask_t *nodes)
+ const nodemask_t *nodes)
{
if (likely(!nodes && zonelist_zone_idx(z) <= highest_zoneidx))
return z;
@@ -1860,7 +1860,7 @@ static __always_inline struct zoneref *next_zones_zonelist(struct zoneref *z,
*/
static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
enum zone_type highest_zoneidx,
- nodemask_t *nodes)
+ const nodemask_t *nodes)
{
return next_zones_zonelist(zonelist->_zonerefs,
highest_zoneidx, nodes);
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 7b02bc1d0a7e..00da05d227e6 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -30,7 +30,7 @@ struct oom_control {
struct zonelist *zonelist;
/* Used to determine mempolicy */
- nodemask_t *nodemask;
+ const nodemask_t *nodemask;
/* Memory cgroup in which oom is invoked, or NULL for global oom */
struct mem_cgroup *memcg;
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 8f0f68e245ba..bf76356d94fe 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -351,7 +351,7 @@ extern void swap_setup(void);
/* linux/mm/vmscan.c */
extern unsigned long zone_reclaimable_pages(struct zone *zone);
extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
- gfp_t gfp_mask, nodemask_t *mask);
+ gfp_t gfp_mask, const nodemask_t *mask);
unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx);
#define MEMCG_RECLAIM_MAY_SWAP (1 << 1)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 5c33ab20cc20..536ce591c7ba 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -4153,7 +4153,7 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)
*
* Are any of the nodes in the nodemask allowed in current->mems_allowed?
*/
-int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
+int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask)
{
return nodes_intersects(*nodemask, current->mems_allowed);
}
diff --git a/mm/internal.h b/mm/internal.h
index 181e79f1d6a2..a2ef9512b5bc 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -668,7 +668,7 @@ void page_alloc_sysctl_init(void);
*/
struct alloc_context {
struct zonelist *zonelist;
- nodemask_t *nodemask;
+ const nodemask_t *nodemask;
struct zoneref *preferred_zoneref;
int migratetype;
diff --git a/mm/mmzone.c b/mm/mmzone.c
index 0c8f181d9d50..59dc3f2076a6 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -43,7 +43,8 @@ struct zone *next_zone(struct zone *zone)
return zone;
}
-static inline int zref_in_nodemask(struct zoneref *zref, nodemask_t *nodes)
+static inline int zref_in_nodemask(struct zoneref *zref,
+ const nodemask_t *nodes)
{
#ifdef CONFIG_NUMA
return node_isset(zonelist_node_idx(zref), *nodes);
@@ -55,7 +56,7 @@ static inline int zref_in_nodemask(struct zoneref *zref, nodemask_t *nodes)
/* Returns the next zone at or below highest_zoneidx in a zonelist */
struct zoneref *__next_zones_zonelist(struct zoneref *z,
enum zone_type highest_zoneidx,
- nodemask_t *nodes)
+ const nodemask_t *nodes)
{
/*
* Find the next suitable zone to use for the allocation.
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 81a9d4d1e6c0..586524bbde9c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3979,7 +3979,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
return NULL;
}
-static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask)
+static void warn_alloc_show_mem(gfp_t gfp_mask, const nodemask_t *nodemask)
{
unsigned int filter = SHOW_MEM_FILTER_NODES;
@@ -3999,7 +3999,7 @@ static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask)
mem_cgroup_show_protected_memory(NULL);
}
-void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
+void warn_alloc(gfp_t gfp_mask, const nodemask_t *nodemask, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
@@ -4687,7 +4687,7 @@ check_retry_cpuset(int cpuset_mems_cookie, struct alloc_context *ac)
return false;
}
-static void check_alloc_stall_warn(gfp_t gfp_mask, nodemask_t *nodemask,
+static void check_alloc_stall_warn(gfp_t gfp_mask, const nodemask_t *nodemask,
unsigned int order, unsigned long alloc_start_time)
{
static DEFINE_SPINLOCK(alloc_stall_lock);
diff --git a/mm/show_mem.c b/mm/show_mem.c
index 43aca5a2ac99..1b721a8ade67 100644
--- a/mm/show_mem.c
+++ b/mm/show_mem.c
@@ -116,7 +116,8 @@ void si_meminfo_node(struct sysinfo *val, int nid)
* Determine whether the node should be displayed or not, depending on whether
* SHOW_MEM_FILTER_NODES was passed to show_free_areas().
*/
-static bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask)
+static bool show_mem_node_skip(unsigned int flags, int nid,
+ const nodemask_t *nodemask)
{
if (!(flags & SHOW_MEM_FILTER_NODES))
return false;
@@ -177,7 +178,8 @@ static bool node_has_managed_zones(pg_data_t *pgdat, int max_zone_idx)
* SHOW_MEM_FILTER_NODES: suppress nodes that are not allowed by current's
* cpuset.
*/
-static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
+static void show_free_areas(unsigned int filter, const nodemask_t *nodemask,
+ int max_zone_idx)
{
unsigned long free_pcp = 0;
int cpu, nid;
@@ -402,7 +404,8 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
show_swap_cache_info();
}
-void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
+void __show_mem(unsigned int filter, const nodemask_t *nodemask,
+ int max_zone_idx)
{
unsigned long total = 0, reserved = 0, highmem = 0;
struct zone *zone;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index e8a90911bf88..47d3f3361fb9 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -79,7 +79,7 @@ struct scan_control {
* Nodemask of nodes allowed by the caller. If NULL, all nodes
* are scanned.
*/
- nodemask_t *nodemask;
+ const nodemask_t *nodemask;
/*
* The memory cgroup that hit its limit and as a result is the
@@ -6599,7 +6599,7 @@ static bool allow_direct_reclaim(pg_data_t *pgdat)
* happens, the page allocator should not consider triggering the OOM killer.
*/
static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
- nodemask_t *nodemask)
+ const nodemask_t *nodemask)
{
struct zoneref *z;
struct zone *zone;
@@ -6679,7 +6679,7 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist,
}
unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
- gfp_t gfp_mask, nodemask_t *nodemask)
+ gfp_t gfp_mask, const nodemask_t *nodemask)
{
unsigned long nr_reclaimed;
struct scan_control sc = {
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 0:29 [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask Gregory Price @ 2026-06-09 1:44 ` Zi Yan 2026-06-09 7:39 ` Lorenzo Stoakes 2026-06-09 7:41 ` Lorenzo Stoakes ` (2 subsequent siblings) 3 siblings, 1 reply; 10+ messages in thread From: Zi Yan @ 2026-06-09 1:44 UTC (permalink / raw) To: Gregory Price Cc: linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb On 8 Jun 2026, at 20:29, Gregory Price wrote: > The nodemasks in these structures may come from a variety of sources, > including tasks and cpusets - and should never be modified by any code > when being passed around inside another context. > > Signed-off-by: Gregory Price <gourry@gourry.net> > --- > include/linux/cpuset.h | 4 ++-- > include/linux/mm.h | 4 ++-- > include/linux/mmzone.h | 6 +++--- > include/linux/oom.h | 2 +- > include/linux/swap.h | 2 +- > kernel/cgroup/cpuset.c | 2 +- > mm/internal.h | 2 +- > mm/mmzone.c | 5 +++-- > mm/page_alloc.c | 6 +++--- > mm/show_mem.c | 9 ++++++--- > mm/vmscan.c | 6 +++--- > 11 files changed, 26 insertions(+), 22 deletions(-) > LGTM and it compiles. As long as Sashiko does not complain, feel free to add: Acked-by: Zi Yan <ziy@nvidia.com> Best Regards, Yan, Zi ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 1:44 ` Zi Yan @ 2026-06-09 7:39 ` Lorenzo Stoakes 2026-06-09 14:43 ` Zi Yan 2026-06-09 15:41 ` Gregory Price 0 siblings, 2 replies; 10+ messages in thread From: Lorenzo Stoakes @ 2026-06-09 7:39 UTC (permalink / raw) To: Zi Yan Cc: Gregory Price, linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb On Mon, Jun 08, 2026 at 09:44:42PM -0400, Zi Yan wrote: > On 8 Jun 2026, at 20:29, Gregory Price wrote: > > > The nodemasks in these structures may come from a variety of sources, > > including tasks and cpusets - and should never be modified by any code > > when being passed around inside another context. > > > > Signed-off-by: Gregory Price <gourry@gourry.net> > > --- > > include/linux/cpuset.h | 4 ++-- > > include/linux/mm.h | 4 ++-- > > include/linux/mmzone.h | 6 +++--- > > include/linux/oom.h | 2 +- > > include/linux/swap.h | 2 +- > > kernel/cgroup/cpuset.c | 2 +- > > mm/internal.h | 2 +- > > mm/mmzone.c | 5 +++-- > > mm/page_alloc.c | 6 +++--- > > mm/show_mem.c | 9 ++++++--- > > mm/vmscan.c | 6 +++--- > > 11 files changed, 26 insertions(+), 22 deletions(-) > > > > LGTM and it compiles. As long as Sashiko does not complain, feel free to > add: I would add caveats of: - Complains legitimately - And it's about this actual patch not something unrelated :P (Not speaking for Zi of course, but I mean just in general I feel these caveats should be implicit :)) > > Acked-by: Zi Yan <ziy@nvidia.com> > > Best Regards, > Yan, Zi Cheers, Lorenzo ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 7:39 ` Lorenzo Stoakes @ 2026-06-09 14:43 ` Zi Yan 2026-06-09 15:41 ` Gregory Price 1 sibling, 0 replies; 10+ messages in thread From: Zi Yan @ 2026-06-09 14:43 UTC (permalink / raw) To: Lorenzo Stoakes Cc: Gregory Price, linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb On 9 Jun 2026, at 3:39, Lorenzo Stoakes wrote: > On Mon, Jun 08, 2026 at 09:44:42PM -0400, Zi Yan wrote: >> On 8 Jun 2026, at 20:29, Gregory Price wrote: >> >>> The nodemasks in these structures may come from a variety of sources, >>> including tasks and cpusets - and should never be modified by any code >>> when being passed around inside another context. >>> >>> Signed-off-by: Gregory Price <gourry@gourry.net> >>> --- >>> include/linux/cpuset.h | 4 ++-- >>> include/linux/mm.h | 4 ++-- >>> include/linux/mmzone.h | 6 +++--- >>> include/linux/oom.h | 2 +- >>> include/linux/swap.h | 2 +- >>> kernel/cgroup/cpuset.c | 2 +- >>> mm/internal.h | 2 +- >>> mm/mmzone.c | 5 +++-- >>> mm/page_alloc.c | 6 +++--- >>> mm/show_mem.c | 9 ++++++--- >>> mm/vmscan.c | 6 +++--- >>> 11 files changed, 26 insertions(+), 22 deletions(-) >>> >> >> LGTM and it compiles. As long as Sashiko does not complain, feel free to >> add: > > I would add caveats of: > > - Complains legitimately > - And it's about this actual patch not something unrelated > > :P > > (Not speaking for Zi of course, but I mean just in general I feel these caveats > should be implicit :)) I agree. Thank you for bringing it up. > >> >> Acked-by: Zi Yan <ziy@nvidia.com> >> >> Best Regards, >> Yan, Zi > > Cheers, Lorenzo Best Regards, Yan, Zi ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 7:39 ` Lorenzo Stoakes 2026-06-09 14:43 ` Zi Yan @ 2026-06-09 15:41 ` Gregory Price 1 sibling, 0 replies; 10+ messages in thread From: Gregory Price @ 2026-06-09 15:41 UTC (permalink / raw) To: Lorenzo Stoakes Cc: Zi Yan, linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb On Tue, Jun 09, 2026 at 08:39:22AM +0100, Lorenzo Stoakes wrote: > On Mon, Jun 08, 2026 at 09:44:42PM -0400, Zi Yan wrote: > > On 8 Jun 2026, at 20:29, Gregory Price wrote: > > > > > The nodemasks in these structures may come from a variety of sources, > > > including tasks and cpusets - and should never be modified by any code > > > when being passed around inside another context. > > > > > > Signed-off-by: Gregory Price <gourry@gourry.net> > > > --- > > > include/linux/cpuset.h | 4 ++-- > > > include/linux/mm.h | 4 ++-- > > > include/linux/mmzone.h | 6 +++--- > > > include/linux/oom.h | 2 +- > > > include/linux/swap.h | 2 +- > > > kernel/cgroup/cpuset.c | 2 +- > > > mm/internal.h | 2 +- > > > mm/mmzone.c | 5 +++-- > > > mm/page_alloc.c | 6 +++--- > > > mm/show_mem.c | 9 ++++++--- > > > mm/vmscan.c | 6 +++--- > > > 11 files changed, 26 insertions(+), 22 deletions(-) > > > > > > > LGTM and it compiles. As long as Sashiko does not complain, feel free to > > add: > > I would add caveats of: > > - Complains legitimately > - And it's about this actual patch not something unrelated > > :P > > (Not speaking for Zi of course, but I mean just in general I feel these caveats > should be implicit :)) Thank you for your contribution! Gourry AI review found 1 potential issue(s) to consider: - [High] Questioning the legitimacy of AI is grounds for excommunication -- [Severity: High] Insolence will not be suffered, take this man away. ;] (fwiw I'm getting used to Sashiko, it's doing better) ~Gregory ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 0:29 [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask Gregory Price 2026-06-09 1:44 ` Zi Yan @ 2026-06-09 7:41 ` Lorenzo Stoakes 2026-06-09 9:37 ` David Hildenbrand (Arm) 2026-06-09 15:42 ` Gregory Price 2026-06-09 7:48 ` Barry Song 2026-06-09 9:59 ` Vlastimil Babka (SUSE) 3 siblings, 2 replies; 10+ messages in thread From: Lorenzo Stoakes @ 2026-06-09 7:41 UTC (permalink / raw) To: Gregory Price Cc: linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb, ziy On Mon, Jun 08, 2026 at 08:29:19PM -0400, Gregory Price wrote: > The nodemasks in these structures may come from a variety of sources, > including tasks and cpusets - and should never be modified by any code > when being passed around inside another context. > > Signed-off-by: Gregory Price <gourry@gourry.net> Thanks for doing this, it's nice to gradually up our const correctness game (as much as C can ever be const correct :) LGTM, builds locally too, so: Reviewed-by: Lorenzo Stoakes <ljs@kernel.org> > --- > include/linux/cpuset.h | 4 ++-- > include/linux/mm.h | 4 ++-- > include/linux/mmzone.h | 6 +++--- > include/linux/oom.h | 2 +- > include/linux/swap.h | 2 +- > kernel/cgroup/cpuset.c | 2 +- > mm/internal.h | 2 +- > mm/mmzone.c | 5 +++-- > mm/page_alloc.c | 6 +++--- > mm/show_mem.c | 9 ++++++--- > mm/vmscan.c | 6 +++--- > 11 files changed, 26 insertions(+), 22 deletions(-) > > diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h > index 65d76a38974b..a80d38e752d2 100644 > --- a/include/linux/cpuset.h > +++ b/include/linux/cpuset.h > @@ -83,7 +83,7 @@ extern bool cpuset_cpus_allowed_fallback(struct task_struct *p); > extern nodemask_t cpuset_mems_allowed(struct task_struct *p); > #define cpuset_current_mems_allowed (current->mems_allowed) > void cpuset_init_current_mems_allowed(void); > -int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask); > +int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask); > > extern bool cpuset_current_node_allowed(int node, gfp_t gfp_mask); > > @@ -224,7 +224,7 @@ static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) > #define cpuset_current_mems_allowed (node_states[N_MEMORY]) > static inline void cpuset_init_current_mems_allowed(void) {} > > -static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask) > +static inline int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask) > { > return 1; > } > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 485df9c2dbdd..2101e5205fc0 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -4042,7 +4042,7 @@ extern int __meminit early_pfn_to_nid(unsigned long pfn); > extern void mem_init(void); > extern void __init mmap_init(void); > > -extern void __show_mem(unsigned int flags, nodemask_t *nodemask, int max_zone_idx); > +extern void __show_mem(unsigned int flags, const nodemask_t *nodemask, int max_zone_idx); > static inline void show_mem(void) > { > __show_mem(0, NULL, MAX_NR_ZONES - 1); > @@ -4052,7 +4052,7 @@ extern void si_meminfo(struct sysinfo * val); > extern void si_meminfo_node(struct sysinfo *val, int nid); > > extern __printf(3, 4) > -void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...); > +void warn_alloc(gfp_t gfp_mask, const nodemask_t *nodemask, const char *fmt, ...); > > extern void setup_per_cpu_pageset(void); > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index ca2712187147..919be0d9b4fa 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -1815,7 +1815,7 @@ static inline int zonelist_node_idx(const struct zoneref *zoneref) > > struct zoneref *__next_zones_zonelist(struct zoneref *z, > enum zone_type highest_zoneidx, > - nodemask_t *nodes); > + const nodemask_t *nodes); > > /** > * next_zones_zonelist - Returns the next zone at or below highest_zoneidx within the allowed nodemask using a cursor within a zonelist as a starting point > @@ -1834,7 +1834,7 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z, > */ > static __always_inline struct zoneref *next_zones_zonelist(struct zoneref *z, > enum zone_type highest_zoneidx, > - nodemask_t *nodes) > + const nodemask_t *nodes) > { > if (likely(!nodes && zonelist_zone_idx(z) <= highest_zoneidx)) > return z; > @@ -1860,7 +1860,7 @@ static __always_inline struct zoneref *next_zones_zonelist(struct zoneref *z, > */ > static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist, > enum zone_type highest_zoneidx, > - nodemask_t *nodes) > + const nodemask_t *nodes) > { > return next_zones_zonelist(zonelist->_zonerefs, > highest_zoneidx, nodes); > diff --git a/include/linux/oom.h b/include/linux/oom.h > index 7b02bc1d0a7e..00da05d227e6 100644 > --- a/include/linux/oom.h > +++ b/include/linux/oom.h > @@ -30,7 +30,7 @@ struct oom_control { > struct zonelist *zonelist; > > /* Used to determine mempolicy */ > - nodemask_t *nodemask; > + const nodemask_t *nodemask; > > /* Memory cgroup in which oom is invoked, or NULL for global oom */ > struct mem_cgroup *memcg; > diff --git a/include/linux/swap.h b/include/linux/swap.h > index 8f0f68e245ba..bf76356d94fe 100644 > --- a/include/linux/swap.h > +++ b/include/linux/swap.h > @@ -351,7 +351,7 @@ extern void swap_setup(void); > /* linux/mm/vmscan.c */ > extern unsigned long zone_reclaimable_pages(struct zone *zone); > extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, > - gfp_t gfp_mask, nodemask_t *mask); > + gfp_t gfp_mask, const nodemask_t *mask); > unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx); > > #define MEMCG_RECLAIM_MAY_SWAP (1 << 1) > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index 5c33ab20cc20..536ce591c7ba 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -4153,7 +4153,7 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk) > * > * Are any of the nodes in the nodemask allowed in current->mems_allowed? > */ > -int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask) > +int cpuset_nodemask_valid_mems_allowed(const nodemask_t *nodemask) > { > return nodes_intersects(*nodemask, current->mems_allowed); > } > diff --git a/mm/internal.h b/mm/internal.h > index 181e79f1d6a2..a2ef9512b5bc 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -668,7 +668,7 @@ void page_alloc_sysctl_init(void); > */ > struct alloc_context { > struct zonelist *zonelist; > - nodemask_t *nodemask; > + const nodemask_t *nodemask; > struct zoneref *preferred_zoneref; > int migratetype; > > diff --git a/mm/mmzone.c b/mm/mmzone.c > index 0c8f181d9d50..59dc3f2076a6 100644 > --- a/mm/mmzone.c > +++ b/mm/mmzone.c > @@ -43,7 +43,8 @@ struct zone *next_zone(struct zone *zone) > return zone; > } > > -static inline int zref_in_nodemask(struct zoneref *zref, nodemask_t *nodes) > +static inline int zref_in_nodemask(struct zoneref *zref, > + const nodemask_t *nodes) > { > #ifdef CONFIG_NUMA > return node_isset(zonelist_node_idx(zref), *nodes); > @@ -55,7 +56,7 @@ static inline int zref_in_nodemask(struct zoneref *zref, nodemask_t *nodes) > /* Returns the next zone at or below highest_zoneidx in a zonelist */ > struct zoneref *__next_zones_zonelist(struct zoneref *z, > enum zone_type highest_zoneidx, > - nodemask_t *nodes) > + const nodemask_t *nodes) > { > /* > * Find the next suitable zone to use for the allocation. > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 81a9d4d1e6c0..586524bbde9c 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3979,7 +3979,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, > return NULL; > } > > -static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask) > +static void warn_alloc_show_mem(gfp_t gfp_mask, const nodemask_t *nodemask) > { > unsigned int filter = SHOW_MEM_FILTER_NODES; > > @@ -3999,7 +3999,7 @@ static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask) > mem_cgroup_show_protected_memory(NULL); > } > > -void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...) > +void warn_alloc(gfp_t gfp_mask, const nodemask_t *nodemask, const char *fmt, ...) > { > struct va_format vaf; > va_list args; > @@ -4687,7 +4687,7 @@ check_retry_cpuset(int cpuset_mems_cookie, struct alloc_context *ac) > return false; > } > > -static void check_alloc_stall_warn(gfp_t gfp_mask, nodemask_t *nodemask, > +static void check_alloc_stall_warn(gfp_t gfp_mask, const nodemask_t *nodemask, > unsigned int order, unsigned long alloc_start_time) > { > static DEFINE_SPINLOCK(alloc_stall_lock); > diff --git a/mm/show_mem.c b/mm/show_mem.c > index 43aca5a2ac99..1b721a8ade67 100644 > --- a/mm/show_mem.c > +++ b/mm/show_mem.c > @@ -116,7 +116,8 @@ void si_meminfo_node(struct sysinfo *val, int nid) > * Determine whether the node should be displayed or not, depending on whether > * SHOW_MEM_FILTER_NODES was passed to show_free_areas(). > */ > -static bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask) > +static bool show_mem_node_skip(unsigned int flags, int nid, > + const nodemask_t *nodemask) > { > if (!(flags & SHOW_MEM_FILTER_NODES)) > return false; > @@ -177,7 +178,8 @@ static bool node_has_managed_zones(pg_data_t *pgdat, int max_zone_idx) > * SHOW_MEM_FILTER_NODES: suppress nodes that are not allowed by current's > * cpuset. > */ > -static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_idx) > +static void show_free_areas(unsigned int filter, const nodemask_t *nodemask, > + int max_zone_idx) > { > unsigned long free_pcp = 0; > int cpu, nid; > @@ -402,7 +404,8 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z > show_swap_cache_info(); > } > > -void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx) > +void __show_mem(unsigned int filter, const nodemask_t *nodemask, > + int max_zone_idx) > { > unsigned long total = 0, reserved = 0, highmem = 0; > struct zone *zone; > diff --git a/mm/vmscan.c b/mm/vmscan.c > index e8a90911bf88..47d3f3361fb9 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -79,7 +79,7 @@ struct scan_control { > * Nodemask of nodes allowed by the caller. If NULL, all nodes > * are scanned. > */ > - nodemask_t *nodemask; > + const nodemask_t *nodemask; > > /* > * The memory cgroup that hit its limit and as a result is the > @@ -6599,7 +6599,7 @@ static bool allow_direct_reclaim(pg_data_t *pgdat) > * happens, the page allocator should not consider triggering the OOM killer. > */ > static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, > - nodemask_t *nodemask) > + const nodemask_t *nodemask) > { > struct zoneref *z; > struct zone *zone; > @@ -6679,7 +6679,7 @@ static bool throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, > } > > unsigned long try_to_free_pages(struct zonelist *zonelist, int order, > - gfp_t gfp_mask, nodemask_t *nodemask) > + gfp_t gfp_mask, const nodemask_t *nodemask) > { > unsigned long nr_reclaimed; > struct scan_control sc = { > -- > 2.54.0 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 7:41 ` Lorenzo Stoakes @ 2026-06-09 9:37 ` David Hildenbrand (Arm) 2026-06-09 15:42 ` Gregory Price 1 sibling, 0 replies; 10+ messages in thread From: David Hildenbrand (Arm) @ 2026-06-09 9:37 UTC (permalink / raw) To: Lorenzo Stoakes, Gregory Price Cc: linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb, ziy On 6/9/26 09:41, Lorenzo Stoakes wrote: > On Mon, Jun 08, 2026 at 08:29:19PM -0400, Gregory Price wrote: >> The nodemasks in these structures may come from a variety of sources, >> including tasks and cpusets - and should never be modified by any code >> when being passed around inside another context. >> >> Signed-off-by: Gregory Price <gourry@gourry.net> > > Thanks for doing this, it's nice to gradually up our const correctness game > (as much as C can ever be const correct :) +1 > > LGTM, builds locally too, so: > Nice. > Reviewed-by: Lorenzo Stoakes <ljs@kernel.org> Acked-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 7:41 ` Lorenzo Stoakes 2026-06-09 9:37 ` David Hildenbrand (Arm) @ 2026-06-09 15:42 ` Gregory Price 1 sibling, 0 replies; 10+ messages in thread From: Gregory Price @ 2026-06-09 15:42 UTC (permalink / raw) To: Lorenzo Stoakes Cc: linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb, ziy On Tue, Jun 09, 2026 at 08:41:59AM +0100, Lorenzo Stoakes wrote: > On Mon, Jun 08, 2026 at 08:29:19PM -0400, Gregory Price wrote: > > The nodemasks in these structures may come from a variety of sources, > > including tasks and cpusets - and should never be modified by any code > > when being passed around inside another context. > > > > Signed-off-by: Gregory Price <gourry@gourry.net> > > Thanks for doing this, it's nice to gradually up our const correctness game > (as much as C can ever be const correct :) > I've actually been carrying this patch locally for about a year in the private nodes work. Sorry i didn't send it sooner. There is likely more work to be done here. > LGTM, builds locally too, so: > > Reviewed-by: Lorenzo Stoakes <ljs@kernel.org> > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 0:29 [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask Gregory Price 2026-06-09 1:44 ` Zi Yan 2026-06-09 7:41 ` Lorenzo Stoakes @ 2026-06-09 7:48 ` Barry Song 2026-06-09 9:59 ` Vlastimil Babka (SUSE) 3 siblings, 0 replies; 10+ messages in thread From: Barry Song @ 2026-06-09 7:48 UTC (permalink / raw) To: Gregory Price Cc: linux-mm, linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb, ziy On Tue, Jun 9, 2026 at 8:29 AM Gregory Price <gourry@gourry.net> wrote: > > The nodemasks in these structures may come from a variety of sources, > including tasks and cpusets - and should never be modified by any code > when being passed around inside another context. > > Signed-off-by: Gregory Price <gourry@gourry.net> > --- LGTM, Reviewed-by: Barry Song <baohua@kernel.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask 2026-06-09 0:29 [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask Gregory Price ` (2 preceding siblings ...) 2026-06-09 7:48 ` Barry Song @ 2026-06-09 9:59 ` Vlastimil Babka (SUSE) 3 siblings, 0 replies; 10+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-06-09 9:59 UTC (permalink / raw) To: Gregory Price, linux-mm Cc: linux-kernel, cgroups, kernel-team, longman, chenridong, akpm, david, ljs, liam, rppt, surenb, mhocko, kasong, qi.zheng, shakeel.butt, baohua, axelrasmussen, yuanchu, weixugc, rientjes, chrisl, shikemeng, nphamcs, baoquan.he, youngjun.park, tj, hannes, mkoutny, jackmanb, ziy On 6/9/26 02:29, Gregory Price wrote: > The nodemasks in these structures may come from a variety of sources, > including tasks and cpusets - and should never be modified by any code > when being passed around inside another context. > > Signed-off-by: Gregory Price <gourry@gourry.net> Nice! Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-06-09 15:43 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-09 0:29 [PATCH] mm: constify oom_control, scan_control, and alloc_context nodemask Gregory Price 2026-06-09 1:44 ` Zi Yan 2026-06-09 7:39 ` Lorenzo Stoakes 2026-06-09 14:43 ` Zi Yan 2026-06-09 15:41 ` Gregory Price 2026-06-09 7:41 ` Lorenzo Stoakes 2026-06-09 9:37 ` David Hildenbrand (Arm) 2026-06-09 15:42 ` Gregory Price 2026-06-09 7:48 ` Barry Song 2026-06-09 9:59 ` Vlastimil Babka (SUSE)
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.