Linux cgroups development
 help / color / mirror / Atom feed
* [PATCH v3 0/4] mm/page_alloc: couple of followups for recent cleanups
@ 2026-07-15 11:03 Brendan Jackman
  2026-07-15 11:03 ` [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK Brendan Jackman
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Brendan Jackman @ 2026-07-15 11:03 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel, sashiko-bot



---
Changes in v3:
- Fixed Sashiko Links: (Zi Yan)
- Fixed kerneldoc syntax (Sashiko)
- Removed extra VM_BUG_ON() (Sashiko)
- Link to v2: https://patch.msgid.link/20260714-spin-trylock-followup-v2-0-3c20ed032b14@google.com

Changes in v2:
- Separated from functional fixes
- Added cpuset cleanup, comment fixup, VM_BUG_ON() removal from Zi Yan's
  review of [0].
- Link to v1: https://patch.msgid.link/20260710-spin-trylock-followup-v1-0-affb5fe5ed00@google.com

Based on mm-new, these are followups to [0]

The alloc_pages_nolock_noprof() comment fixup could be squashed into
"mm/page_alloc: relax GFP WARN in nolock allocs" - currently
11770f8836f44 in mm-new.

The VM_BUG_ON() removal could be squashed into "mm: remove
__alloc_pages_node()", currently fba100a6cdfc5.
[0]: https://lore.kernel.org/all/20260703-alloc-trylock-v5-0-c87b714e19d3@google.com/

To: Andrew Morton <akpm@linux-foundation.org>
To: Vlastimil Babka <vbabka@kernel.org>
To: Suren Baghdasaryan <surenb@google.com>
To: Michal Hocko <mhocko@suse.com>
To: Brendan Jackman <jackmanb@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
To: Zi Yan <ziy@nvidia.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Clark Williams <clrkwllms@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
To: Waiman Long <longman@redhat.com>
To: Ridong Chen <ridong.chen@linux.dev>
To: Tejun Heo <tj@kernel.org>
To: Michal Koutný <mkoutny@suse.com>
To: David Hildenbrand <david@kernel.org>
To: Lorenzo Stoakes <ljs@kernel.org>
To: "Liam R. Howlett" <liam@infradead.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: cgroups@vger.kernel.org
Cc: linux-rt-devel@lists.linux.dev

---
Brendan Jackman (4):
      mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK
      cgroup/cpuset: update some comments about the page allocator
      mm/page_alloc: fixup alloc_pages_nolock_noprof() comment
      mm/page_alloc: remove a couple of VM_BUG_ON()st

 include/linux/gfp.h    |  1 -
 kernel/cgroup/cpuset.c | 13 +++++--------
 mm/page_alloc.c        | 22 +++++++++++-----------
 3 files changed, 16 insertions(+), 20 deletions(-)
---
base-commit: 59c684a9908d2e6f7a791f7f033eae57ec2b3a61
change-id: 20260710-spin-trylock-followup-332c636e0d99

Best regards,
--  
Brendan Jackman <jackmanb@google.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK
  2026-07-15 11:03 [PATCH v3 0/4] mm/page_alloc: couple of followups for recent cleanups Brendan Jackman
@ 2026-07-15 11:03 ` Brendan Jackman
  2026-07-15 13:14   ` Vlastimil Babka (SUSE)
  2026-07-15 11:03 ` [PATCH v3 2/4] cgroup/cpuset: update some comments about the page allocator Brendan Jackman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Brendan Jackman @ 2026-07-15 11:03 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

As discussed in the linked patch, the there is some inconsistency between
"trylock" and "nolock" nomenclature, let's align it. Since "nolock" is
used in the public API it seems to have more mindshare so do that.

The linked patch did this for the ALLOC_ flag but forgot about FPI_.

Link: https://lore.kernel.org/all/20260703-alloc-trylock-v5-1-c87b714e19d3@google.com/
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 mm/page_alloc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index af63558391345..c2da85e69a0f8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -90,7 +90,7 @@ typedef int __bitwise fpi_t;
 #define FPI_TO_TAIL		((__force fpi_t)BIT(1))
 
 /* Free the page without taking locks. Rely on trylock only. */
-#define FPI_TRYLOCK		((__force fpi_t)BIT(2))
+#define FPI_NOLOCK		((__force fpi_t)BIT(2))
 
 /* free_pages_prepare() has already been called for page(s) being freed. */
 #define FPI_PREPARED		((__force fpi_t)BIT(3))
@@ -1419,7 +1419,7 @@ static __always_inline bool __free_pages_prepare(struct page *page,
 	page_table_check_free(page, order);
 	pgalloc_tag_sub(page, 1 << order);
 
-	if (!PageHighMem(page) && !(fpi_flags & FPI_TRYLOCK)) {
+	if (!PageHighMem(page) && !(fpi_flags & FPI_NOLOCK)) {
 		debug_check_no_locks_freed(page_address(page),
 					   PAGE_SIZE << order);
 		debug_check_no_obj_freed(page_address(page),
@@ -1558,7 +1558,7 @@ static void free_one_page(struct zone *zone, struct page *page,
 	struct llist_head *llhead;
 	unsigned long flags;
 
-	if (unlikely(fpi_flags & FPI_TRYLOCK)) {
+	if (unlikely(fpi_flags & FPI_NOLOCK)) {
 		if (!spin_trylock_irqsave(&zone->lock, flags)) {
 			add_page_to_zone_llist(zone, page, order);
 			return;
@@ -1569,7 +1569,7 @@ static void free_one_page(struct zone *zone, struct page *page,
 
 	/* The lock succeeded. Process deferred pages. */
 	llhead = &zone->trylock_free_pages;
-	if (unlikely(!llist_empty(llhead) && !(fpi_flags & FPI_TRYLOCK))) {
+	if (unlikely(!llist_empty(llhead) && !(fpi_flags & FPI_NOLOCK))) {
 		struct llist_node *llnode;
 		struct page *p, *tmp;
 
@@ -2882,7 +2882,7 @@ static bool free_frozen_page_commit(struct zone *zone,
 	if (pcp->free_count < (batch << CONFIG_PCP_BATCH_SCALE_MAX))
 		pcp->free_count += (1 << order);
 
-	if (unlikely(fpi_flags & FPI_TRYLOCK)) {
+	if (unlikely(fpi_flags & FPI_NOLOCK)) {
 		/*
 		 * Do not attempt to take a zone lock. Let pcp->count get
 		 * over high mark temporarily.
@@ -2979,7 +2979,7 @@ static void __free_frozen_pages(struct page *page, unsigned int order,
 		migratetype = MIGRATE_MOVABLE;
 	}
 
-	if (unlikely((fpi_flags & FPI_TRYLOCK) && IS_ENABLED(CONFIG_PREEMPT_RT)
+	if (unlikely((fpi_flags & FPI_NOLOCK) && IS_ENABLED(CONFIG_PREEMPT_RT)
 		     && (in_nmi() || in_hardirq()))) {
 		add_page_to_zone_llist(zone, page, order);
 		return;
@@ -3002,7 +3002,7 @@ void free_frozen_pages(struct page *page, unsigned int order)
 
 void free_frozen_pages_nolock(struct page *page, unsigned int order)
 {
-	__free_frozen_pages(page, order, FPI_TRYLOCK);
+	__free_frozen_pages(page, order, FPI_NOLOCK);
 }
 
 /*
@@ -5399,7 +5399,7 @@ struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order,
 	if (memcg_kmem_online() && (gfp & __GFP_ACCOUNT) && page &&
 	    unlikely(__memcg_kmem_charge_page(page, gfp, order) != 0)) {
 		__free_frozen_pages(page, order,
-				    alloc_flags & ALLOC_NOLOCK ? FPI_TRYLOCK : 0);
+				    alloc_flags & ALLOC_NOLOCK ? FPI_NOLOCK : 0);
 		page = NULL;
 	}
 
@@ -5522,7 +5522,7 @@ EXPORT_SYMBOL(__free_pages);
  */
 void free_pages_nolock(struct page *page, unsigned int order)
 {
-	___free_pages(page, order, FPI_TRYLOCK);
+	___free_pages(page, order, FPI_NOLOCK);
 }
 
 /**

-- 
2.54.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 2/4] cgroup/cpuset: update some comments about the page allocator
  2026-07-15 11:03 [PATCH v3 0/4] mm/page_alloc: couple of followups for recent cleanups Brendan Jackman
  2026-07-15 11:03 ` [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK Brendan Jackman
@ 2026-07-15 11:03 ` Brendan Jackman
  2026-07-15 13:16   ` Vlastimil Babka (SUSE)
  2026-07-15 11:03 ` [PATCH v3 3/4] mm/page_alloc: fixup alloc_pages_nolock_noprof() comment Brendan Jackman
  2026-07-15 11:03 ` [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st Brendan Jackman
  3 siblings, 1 reply; 11+ messages in thread
From: Brendan Jackman @ 2026-07-15 11:03 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

These comments describing the page allocator are out of date:

- __alloc_pages() is no longer a public API and has no business being
  described outside of mm/.

- The `wait` variable is gone.

It may be out of date for other reasons too but this patch is just
fixing the issues that stood out.

To fix it:

- Instead of referring to a specific function, instead to "the page
  allocator"

- Completely drop out-of-date details of that function's internal
  behaviour, since they were irrelevant anyway.

Suggested-by: Zi Yan <ziy@nvidia.com>
Link: https://lore.kernel.org/all/DJP11T5V7BDW.2FZZZ8R6LOY4I@nvidia.com/
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 kernel/cgroup/cpuset.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 24ea2d09cdbdb..dfd0f827e3b92 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -4193,7 +4193,7 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs)
  * nearest enclosing hardwalled ancestor cpuset.
  *
  * Scanning up parent cpusets requires callback_lock.  The
- * __alloc_pages() routine only calls here with __GFP_HARDWALL bit
+ * page allocator only calls here with __GFP_HARDWALL bit
  * _not_ set if it's a GFP_KERNEL allocation, and all nodes in the
  * current tasks mems_allowed came up empty on the first pass over
  * the zonelist.  So only GFP_KERNEL allocations, if all nodes in the
@@ -4206,11 +4206,8 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs)
  * come before the __GFP_HARDWALL check, otherwise a dying task
  * would be blocked on the fast path.
  *
- * The second pass through get_page_from_freelist() doesn't even call
- * here for GFP_ATOMIC calls.  For those calls, the __alloc_pages()
- * variable 'wait' is not set, and the bit ALLOC_CPUSET is not set
- * in alloc_flags.  That logic and the checks below have the combined
- * affect that:
+ * The second pass through get_page_from_freelist() doesn't even call here for
+ * GFP_ATOMIC calls.  That, and the checks below have the combined affect that:
  *	in_interrupt - any node ok (current task context irrelevant)
  *	GFP_ATOMIC   - any node ok
  *	tsk_is_oom_victim   - any node ok
@@ -4327,8 +4324,8 @@ void cpuset_nodes_allowed(struct cgroup *cgroup, nodemask_t *mask)
  * should not be possible for the following code to return an
  * offline node.  But if it did, that would be ok, as this routine
  * is not returning the node where the allocation must be, only
- * the node where the search should start.  The zonelist passed to
- * __alloc_pages() will include all nodes.  If the slab allocator
+ * the node where the search should start.  The zonelist used by
+ * the allocator will include all nodes.  If the slab allocator
  * is passed an offline node, it will fall back to the local node.
  * See kmem_cache_alloc_node().
  */

-- 
2.54.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 3/4] mm/page_alloc: fixup alloc_pages_nolock_noprof() comment
  2026-07-15 11:03 [PATCH v3 0/4] mm/page_alloc: couple of followups for recent cleanups Brendan Jackman
  2026-07-15 11:03 ` [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK Brendan Jackman
  2026-07-15 11:03 ` [PATCH v3 2/4] cgroup/cpuset: update some comments about the page allocator Brendan Jackman
@ 2026-07-15 11:03 ` Brendan Jackman
  2026-07-15 13:17   ` Vlastimil Babka (SUSE)
  2026-07-15 11:03 ` [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st Brendan Jackman
  3 siblings, 1 reply; 11+ messages in thread
From: Brendan Jackman @ 2026-07-15 11:03 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel, sashiko-bot

Update the comment to reflect the recent change to allow flags in
gfp_nolock.

Reported-by: sashiko-bot@kernel.org
Link: https://sashiko.dev/#/patchset/20260703-alloc-trylock-v5-0-c87b714e19d3%40google.com?part=6
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 mm/page_alloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c2da85e69a0f8..25a83a57aab66 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7983,7 +7983,8 @@ struct page *alloc_frozen_pages_nolock_noprof(gfp_t gfp_flags, int nid, unsigned
 }
 /**
  * alloc_pages_nolock - opportunistic reentrant allocation from any context
- * @gfp_flags: GFP flags. Only __GFP_ACCOUNT allowed.
+ * @gfp_flags: GFP flags. Only __GFP_ACCOUNT, plus some flags that get set
+ *             internally regardless (see %gfp_nolock) are allowed.
  * @nid: node to allocate from
  * @order: allocation order size
  *

-- 
2.54.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st
  2026-07-15 11:03 [PATCH v3 0/4] mm/page_alloc: couple of followups for recent cleanups Brendan Jackman
                   ` (2 preceding siblings ...)
  2026-07-15 11:03 ` [PATCH v3 3/4] mm/page_alloc: fixup alloc_pages_nolock_noprof() comment Brendan Jackman
@ 2026-07-15 11:03 ` Brendan Jackman
  2026-07-15 13:25   ` Vlastimil Babka (SUSE)
  3 siblings, 1 reply; 11+ messages in thread
From: Brendan Jackman @ 2026-07-15 11:03 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

VM_BUG_ON() is out of favour and on the way to removal, since I recently
touched alloc_pages_node_noprof() I am removing that invocation, and
also removing the __folio_alloc_node_noprof() one for consistency. If
this precondition is violated, the system will soon crash anyway.

Suggested-by: Zi Yan <ziy@nvidia.com>
Link: https://lore.kernel.org/all/7F866265-3F2E-4765-B9D4-9AB898A9C4AC@nvidia.com/
Acked-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 include/linux/gfp.h | 1 -
 mm/page_alloc.c     | 1 -
 2 files changed, 2 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 4d57e9c0bf204..872bc53f32ec8 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -255,7 +255,6 @@ static inline void warn_if_node_offline(int this_node, gfp_t gfp_mask)
 static inline
 struct folio *__folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int nid)
 {
-	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
 	warn_if_node_offline(nid, gfp);
 
 	return __folio_alloc_noprof(gfp, order, nid, NULL);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 25a83a57aab66..4c6815f84adc6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5427,7 +5427,6 @@ struct page *alloc_pages_node_noprof(int nid, gfp_t gfp_mask, unsigned int order
 	if (nid == NUMA_NO_NODE)
 		nid = numa_mem_id();
 
-	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
 	warn_if_node_offline(nid, gfp_mask);
 
 	return __alloc_pages_noprof(gfp_mask, order, nid, NULL, ALLOC_DEFAULT);

-- 
2.54.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK
  2026-07-15 11:03 ` [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK Brendan Jackman
@ 2026-07-15 13:14   ` Vlastimil Babka (SUSE)
  0 siblings, 0 replies; 11+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-15 13:14 UTC (permalink / raw)
  To: Brendan Jackman, Andrew Morton, Suren Baghdasaryan, Michal Hocko,
	Johannes Weiner, Zi Yan, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Waiman Long, Ridong Chen,
	Tejun Heo, Michal Koutný, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

On 7/15/26 13:03, Brendan Jackman wrote:
> As discussed in the linked patch, the there is some inconsistency between
> "trylock" and "nolock" nomenclature, let's align it. Since "nolock" is
> used in the public API it seems to have more mindshare so do that.
> 
> The linked patch did this for the ALLOC_ flag but forgot about FPI_.
> 
> Link: https://lore.kernel.org/all/20260703-alloc-trylock-v5-1-c87b714e19d3@google.com/
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Brendan Jackman <jackmanb@google.com>

Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

> ---
>  mm/page_alloc.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index af63558391345..c2da85e69a0f8 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -90,7 +90,7 @@ typedef int __bitwise fpi_t;
>  #define FPI_TO_TAIL		((__force fpi_t)BIT(1))
>  
>  /* Free the page without taking locks. Rely on trylock only. */
> -#define FPI_TRYLOCK		((__force fpi_t)BIT(2))
> +#define FPI_NOLOCK		((__force fpi_t)BIT(2))
>  
>  /* free_pages_prepare() has already been called for page(s) being freed. */
>  #define FPI_PREPARED		((__force fpi_t)BIT(3))
> @@ -1419,7 +1419,7 @@ static __always_inline bool __free_pages_prepare(struct page *page,
>  	page_table_check_free(page, order);
>  	pgalloc_tag_sub(page, 1 << order);
>  
> -	if (!PageHighMem(page) && !(fpi_flags & FPI_TRYLOCK)) {
> +	if (!PageHighMem(page) && !(fpi_flags & FPI_NOLOCK)) {
>  		debug_check_no_locks_freed(page_address(page),
>  					   PAGE_SIZE << order);
>  		debug_check_no_obj_freed(page_address(page),
> @@ -1558,7 +1558,7 @@ static void free_one_page(struct zone *zone, struct page *page,
>  	struct llist_head *llhead;
>  	unsigned long flags;
>  
> -	if (unlikely(fpi_flags & FPI_TRYLOCK)) {
> +	if (unlikely(fpi_flags & FPI_NOLOCK)) {
>  		if (!spin_trylock_irqsave(&zone->lock, flags)) {
>  			add_page_to_zone_llist(zone, page, order);
>  			return;
> @@ -1569,7 +1569,7 @@ static void free_one_page(struct zone *zone, struct page *page,
>  
>  	/* The lock succeeded. Process deferred pages. */
>  	llhead = &zone->trylock_free_pages;
> -	if (unlikely(!llist_empty(llhead) && !(fpi_flags & FPI_TRYLOCK))) {
> +	if (unlikely(!llist_empty(llhead) && !(fpi_flags & FPI_NOLOCK))) {
>  		struct llist_node *llnode;
>  		struct page *p, *tmp;
>  
> @@ -2882,7 +2882,7 @@ static bool free_frozen_page_commit(struct zone *zone,
>  	if (pcp->free_count < (batch << CONFIG_PCP_BATCH_SCALE_MAX))
>  		pcp->free_count += (1 << order);
>  
> -	if (unlikely(fpi_flags & FPI_TRYLOCK)) {
> +	if (unlikely(fpi_flags & FPI_NOLOCK)) {
>  		/*
>  		 * Do not attempt to take a zone lock. Let pcp->count get
>  		 * over high mark temporarily.
> @@ -2979,7 +2979,7 @@ static void __free_frozen_pages(struct page *page, unsigned int order,
>  		migratetype = MIGRATE_MOVABLE;
>  	}
>  
> -	if (unlikely((fpi_flags & FPI_TRYLOCK) && IS_ENABLED(CONFIG_PREEMPT_RT)
> +	if (unlikely((fpi_flags & FPI_NOLOCK) && IS_ENABLED(CONFIG_PREEMPT_RT)
>  		     && (in_nmi() || in_hardirq()))) {
>  		add_page_to_zone_llist(zone, page, order);
>  		return;
> @@ -3002,7 +3002,7 @@ void free_frozen_pages(struct page *page, unsigned int order)
>  
>  void free_frozen_pages_nolock(struct page *page, unsigned int order)
>  {
> -	__free_frozen_pages(page, order, FPI_TRYLOCK);
> +	__free_frozen_pages(page, order, FPI_NOLOCK);
>  }
>  
>  /*
> @@ -5399,7 +5399,7 @@ struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order,
>  	if (memcg_kmem_online() && (gfp & __GFP_ACCOUNT) && page &&
>  	    unlikely(__memcg_kmem_charge_page(page, gfp, order) != 0)) {
>  		__free_frozen_pages(page, order,
> -				    alloc_flags & ALLOC_NOLOCK ? FPI_TRYLOCK : 0);
> +				    alloc_flags & ALLOC_NOLOCK ? FPI_NOLOCK : 0);
>  		page = NULL;
>  	}
>  
> @@ -5522,7 +5522,7 @@ EXPORT_SYMBOL(__free_pages);
>   */
>  void free_pages_nolock(struct page *page, unsigned int order)
>  {
> -	___free_pages(page, order, FPI_TRYLOCK);
> +	___free_pages(page, order, FPI_NOLOCK);
>  }
>  
>  /**
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/4] cgroup/cpuset: update some comments about the page allocator
  2026-07-15 11:03 ` [PATCH v3 2/4] cgroup/cpuset: update some comments about the page allocator Brendan Jackman
@ 2026-07-15 13:16   ` Vlastimil Babka (SUSE)
  0 siblings, 0 replies; 11+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-15 13:16 UTC (permalink / raw)
  To: Brendan Jackman, Andrew Morton, Suren Baghdasaryan, Michal Hocko,
	Johannes Weiner, Zi Yan, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Waiman Long, Ridong Chen,
	Tejun Heo, Michal Koutný, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

On 7/15/26 13:03, Brendan Jackman wrote:
> These comments describing the page allocator are out of date:
> 
> - __alloc_pages() is no longer a public API and has no business being
>   described outside of mm/.
> 
> - The `wait` variable is gone.
> 
> It may be out of date for other reasons too but this patch is just
> fixing the issues that stood out.
> 
> To fix it:
> 
> - Instead of referring to a specific function, instead to "the page
>   allocator"
> 
> - Completely drop out-of-date details of that function's internal
>   behaviour, since they were irrelevant anyway.
> 
> Suggested-by: Zi Yan <ziy@nvidia.com>
> Link: https://lore.kernel.org/all/DJP11T5V7BDW.2FZZZ8R6LOY4I@nvidia.com/
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Brendan Jackman <jackmanb@google.com>

Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

> ---
>  kernel/cgroup/cpuset.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 24ea2d09cdbdb..dfd0f827e3b92 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -4193,7 +4193,7 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs)
>   * nearest enclosing hardwalled ancestor cpuset.
>   *
>   * Scanning up parent cpusets requires callback_lock.  The
> - * __alloc_pages() routine only calls here with __GFP_HARDWALL bit
> + * page allocator only calls here with __GFP_HARDWALL bit
>   * _not_ set if it's a GFP_KERNEL allocation, and all nodes in the
>   * current tasks mems_allowed came up empty on the first pass over
>   * the zonelist.  So only GFP_KERNEL allocations, if all nodes in the
> @@ -4206,11 +4206,8 @@ static struct cpuset *nearest_hardwall_ancestor(struct cpuset *cs)
>   * come before the __GFP_HARDWALL check, otherwise a dying task
>   * would be blocked on the fast path.
>   *
> - * The second pass through get_page_from_freelist() doesn't even call
> - * here for GFP_ATOMIC calls.  For those calls, the __alloc_pages()
> - * variable 'wait' is not set, and the bit ALLOC_CPUSET is not set
> - * in alloc_flags.  That logic and the checks below have the combined
> - * affect that:
> + * The second pass through get_page_from_freelist() doesn't even call here for
> + * GFP_ATOMIC calls.  That, and the checks below have the combined affect that:
>   *	in_interrupt - any node ok (current task context irrelevant)
>   *	GFP_ATOMIC   - any node ok
>   *	tsk_is_oom_victim   - any node ok
> @@ -4327,8 +4324,8 @@ void cpuset_nodes_allowed(struct cgroup *cgroup, nodemask_t *mask)
>   * should not be possible for the following code to return an
>   * offline node.  But if it did, that would be ok, as this routine
>   * is not returning the node where the allocation must be, only
> - * the node where the search should start.  The zonelist passed to
> - * __alloc_pages() will include all nodes.  If the slab allocator
> + * the node where the search should start.  The zonelist used by
> + * the allocator will include all nodes.  If the slab allocator
>   * is passed an offline node, it will fall back to the local node.
>   * See kmem_cache_alloc_node().
>   */
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 3/4] mm/page_alloc: fixup alloc_pages_nolock_noprof() comment
  2026-07-15 11:03 ` [PATCH v3 3/4] mm/page_alloc: fixup alloc_pages_nolock_noprof() comment Brendan Jackman
@ 2026-07-15 13:17   ` Vlastimil Babka (SUSE)
  0 siblings, 0 replies; 11+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-15 13:17 UTC (permalink / raw)
  To: Brendan Jackman, Andrew Morton, Suren Baghdasaryan, Michal Hocko,
	Johannes Weiner, Zi Yan, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Waiman Long, Ridong Chen,
	Tejun Heo, Michal Koutný, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel, sashiko-bot

On 7/15/26 13:03, Brendan Jackman wrote:
> Update the comment to reflect the recent change to allow flags in
> gfp_nolock.
> 
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/patchset/20260703-alloc-trylock-v5-0-c87b714e19d3%40google.com?part=6
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Brendan Jackman <jackmanb@google.com>

Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

> ---
>  mm/page_alloc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index c2da85e69a0f8..25a83a57aab66 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -7983,7 +7983,8 @@ struct page *alloc_frozen_pages_nolock_noprof(gfp_t gfp_flags, int nid, unsigned
>  }
>  /**
>   * alloc_pages_nolock - opportunistic reentrant allocation from any context
> - * @gfp_flags: GFP flags. Only __GFP_ACCOUNT allowed.
> + * @gfp_flags: GFP flags. Only __GFP_ACCOUNT, plus some flags that get set
> + *             internally regardless (see %gfp_nolock) are allowed.
>   * @nid: node to allocate from
>   * @order: allocation order size
>   *
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st
  2026-07-15 11:03 ` [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st Brendan Jackman
@ 2026-07-15 13:25   ` Vlastimil Babka (SUSE)
  2026-07-15 13:48     ` Brendan Jackman
  0 siblings, 1 reply; 11+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-15 13:25 UTC (permalink / raw)
  To: Brendan Jackman, Andrew Morton, Suren Baghdasaryan, Michal Hocko,
	Johannes Weiner, Zi Yan, Sebastian Andrzej Siewior,
	Clark Williams, Steven Rostedt, Waiman Long, Ridong Chen,
	Tejun Heo, Michal Koutný, David Hildenbrand, Lorenzo Stoakes,
	Liam R. Howlett, Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

Subject has stray 't' at the end?

On 7/15/26 13:03, Brendan Jackman wrote:
> VM_BUG_ON() is out of favour and on the way to removal, since I recently
> touched alloc_pages_node_noprof() I am removing that invocation, and
> also removing the __folio_alloc_node_noprof() one for consistency. If
> this precondition is violated, the system will soon crash anyway.
> 
> Suggested-by: Zi Yan <ziy@nvidia.com>
> Link: https://lore.kernel.org/all/7F866265-3F2E-4765-B9D4-9AB898A9C4AC@nvidia.com/
> Acked-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Brendan Jackman <jackmanb@google.com>

Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

> ---
>  include/linux/gfp.h | 1 -
>  mm/page_alloc.c     | 1 -
>  2 files changed, 2 deletions(-)
> 
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 4d57e9c0bf204..872bc53f32ec8 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -255,7 +255,6 @@ static inline void warn_if_node_offline(int this_node, gfp_t gfp_mask)
>  static inline
>  struct folio *__folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int nid)
>  {
> -	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
>  	warn_if_node_offline(nid, gfp);
>  
>  	return __folio_alloc_noprof(gfp, order, nid, NULL);

Well if you want more cleanups, I can see in iommu_alloc_pages_node_sz():


        /*
         * __folio_alloc_node() does not handle NUMA_NO_NODE like
         * alloc_pages_node() did.
         */
        if (nid == NUMA_NO_NODE)
                nid = numa_mem_id();

        folio = __folio_alloc_node(gfp | __GFP_ZERO, order, nid);

Should we introduce folio_alloc_node() and make __folio_alloc_node()
mm-internal, for consistency?

> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 25a83a57aab66..4c6815f84adc6 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5427,7 +5427,6 @@ struct page *alloc_pages_node_noprof(int nid, gfp_t gfp_mask, unsigned int order
>  	if (nid == NUMA_NO_NODE)
>  		nid = numa_mem_id();
>  
> -	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
>  	warn_if_node_offline(nid, gfp_mask);
>  
>  	return __alloc_pages_noprof(gfp_mask, order, nid, NULL, ALLOC_DEFAULT);
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st
  2026-07-15 13:25   ` Vlastimil Babka (SUSE)
@ 2026-07-15 13:48     ` Brendan Jackman
  2026-07-15 13:56       ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 11+ messages in thread
From: Brendan Jackman @ 2026-07-15 13:48 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE), Brendan Jackman, Andrew Morton,
	Suren Baghdasaryan, Michal Hocko, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

On Wed Jul 15, 2026 at 1:25 PM UTC, Vlastimil Babka (SUSE) wrote:
> Subject has stray 't' at the end?

Thanks - will fix if we do a v3 (otherwise Andrew, please can you amend
when you apply it?)

> On 7/15/26 13:03, Brendan Jackman wrote:
>> VM_BUG_ON() is out of favour and on the way to removal, since I recently
>> touched alloc_pages_node_noprof() I am removing that invocation, and
>> also removing the __folio_alloc_node_noprof() one for consistency. If
>> this precondition is violated, the system will soon crash anyway.
>> 
>> Suggested-by: Zi Yan <ziy@nvidia.com>
>> Link: https://lore.kernel.org/all/7F866265-3F2E-4765-B9D4-9AB898A9C4AC@nvidia.com/
>> Acked-by: Zi Yan <ziy@nvidia.com>
>> Signed-off-by: Brendan Jackman <jackmanb@google.com>
>
> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
>
>> ---
>>  include/linux/gfp.h | 1 -
>>  mm/page_alloc.c     | 1 -
>>  2 files changed, 2 deletions(-)
>> 
>> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
>> index 4d57e9c0bf204..872bc53f32ec8 100644
>> --- a/include/linux/gfp.h
>> +++ b/include/linux/gfp.h
>> @@ -255,7 +255,6 @@ static inline void warn_if_node_offline(int this_node, gfp_t gfp_mask)
>>  static inline
>>  struct folio *__folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int nid)
>>  {
>> -	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
>>  	warn_if_node_offline(nid, gfp);
>>  
>>  	return __folio_alloc_noprof(gfp, order, nid, NULL);
>
> Well if you want more cleanups, I can see in iommu_alloc_pages_node_sz():
>
>
>         /*
>          * __folio_alloc_node() does not handle NUMA_NO_NODE like
>          * alloc_pages_node() did.
>          */
>         if (nid == NUMA_NO_NODE)
>                 nid = numa_mem_id();
>
>         folio = __folio_alloc_node(gfp | __GFP_ZERO, order, nid);
>
> Should we introduce folio_alloc_node() and make __folio_alloc_node()
> mm-internal, for consistency?

Ha, I literally just wrote that patch. I'm planning to do it as yet
another series as there's a little dance needed to get it all into
shape. But, also happy to just expand this one if you prefer.

Then I'm gonna add alloc_flags to the __ variant so filemap.c can set
ALLOC_UNMAPPED for AS_NO_DIRECT_MAP.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st
  2026-07-15 13:48     ` Brendan Jackman
@ 2026-07-15 13:56       ` Vlastimil Babka (SUSE)
  0 siblings, 0 replies; 11+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-07-15 13:56 UTC (permalink / raw)
  To: Brendan Jackman, Brendan Jackman, Andrew Morton,
	Suren Baghdasaryan, Michal Hocko, Johannes Weiner, Zi Yan,
	Sebastian Andrzej Siewior, Clark Williams, Steven Rostedt,
	Waiman Long, Ridong Chen, Tejun Heo, Michal Koutný,
	David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett,
	Mike Rapoport
  Cc: linux-mm, linux-kernel, cgroups, linux-rt-devel

On 7/15/26 15:48, Brendan Jackman wrote:
> On Wed Jul 15, 2026 at 1:25 PM UTC, Vlastimil Babka (SUSE) wrote:
>> Subject has stray 't' at the end?
> 
> Thanks - will fix if we do a v3 (otherwise Andrew, please can you amend
> when you apply it?)
> 
>> On 7/15/26 13:03, Brendan Jackman wrote:
>>> VM_BUG_ON() is out of favour and on the way to removal, since I recently
>>> touched alloc_pages_node_noprof() I am removing that invocation, and
>>> also removing the __folio_alloc_node_noprof() one for consistency. If
>>> this precondition is violated, the system will soon crash anyway.
>>> 
>>> Suggested-by: Zi Yan <ziy@nvidia.com>
>>> Link: https://lore.kernel.org/all/7F866265-3F2E-4765-B9D4-9AB898A9C4AC@nvidia.com/
>>> Acked-by: Zi Yan <ziy@nvidia.com>
>>> Signed-off-by: Brendan Jackman <jackmanb@google.com>
>>
>> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
>>
>>> ---
>>>  include/linux/gfp.h | 1 -
>>>  mm/page_alloc.c     | 1 -
>>>  2 files changed, 2 deletions(-)
>>> 
>>> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
>>> index 4d57e9c0bf204..872bc53f32ec8 100644
>>> --- a/include/linux/gfp.h
>>> +++ b/include/linux/gfp.h
>>> @@ -255,7 +255,6 @@ static inline void warn_if_node_offline(int this_node, gfp_t gfp_mask)
>>>  static inline
>>>  struct folio *__folio_alloc_node_noprof(gfp_t gfp, unsigned int order, int nid)
>>>  {
>>> -	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
>>>  	warn_if_node_offline(nid, gfp);
>>>  
>>>  	return __folio_alloc_noprof(gfp, order, nid, NULL);
>>
>> Well if you want more cleanups, I can see in iommu_alloc_pages_node_sz():
>>
>>
>>         /*
>>          * __folio_alloc_node() does not handle NUMA_NO_NODE like
>>          * alloc_pages_node() did.
>>          */
>>         if (nid == NUMA_NO_NODE)
>>                 nid = numa_mem_id();
>>
>>         folio = __folio_alloc_node(gfp | __GFP_ZERO, order, nid);
>>
>> Should we introduce folio_alloc_node() and make __folio_alloc_node()
>> mm-internal, for consistency?
> 
> Ha, I literally just wrote that patch. I'm planning to do it as yet
> another series as there's a little dance needed to get it all into

Cool!

> shape. But, also happy to just expand this one if you prefer.

Not necessary, another series is fine.

> Then I'm gonna add alloc_flags to the __ variant so filemap.c can set
> ALLOC_UNMAPPED for AS_NO_DIRECT_MAP.

Great!

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-07-15 13:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 11:03 [PATCH v3 0/4] mm/page_alloc: couple of followups for recent cleanups Brendan Jackman
2026-07-15 11:03 ` [PATCH v3 1/4] mm/page_alloc: rename FPI_TRYLOCK -> FPI_NOLOCK Brendan Jackman
2026-07-15 13:14   ` Vlastimil Babka (SUSE)
2026-07-15 11:03 ` [PATCH v3 2/4] cgroup/cpuset: update some comments about the page allocator Brendan Jackman
2026-07-15 13:16   ` Vlastimil Babka (SUSE)
2026-07-15 11:03 ` [PATCH v3 3/4] mm/page_alloc: fixup alloc_pages_nolock_noprof() comment Brendan Jackman
2026-07-15 13:17   ` Vlastimil Babka (SUSE)
2026-07-15 11:03 ` [PATCH v3 4/4] mm/page_alloc: remove a couple of VM_BUG_ON()st Brendan Jackman
2026-07-15 13:25   ` Vlastimil Babka (SUSE)
2026-07-15 13:48     ` Brendan Jackman
2026-07-15 13:56       ` Vlastimil Babka (SUSE)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox