[PATCH v2 04/10] mm/vmalloc: Avoid cond_resched() when blocking is not permitted

From: Uladzislau Rezki (Sony)

Date: Mon Sep 15 2025 - 09:40:48 EST


vm_area_alloc_pages() contains the only voluntary reschedule points
along vmalloc() allocation path. They are needed to ensure forward
progress on PREEMPT_NONE kernels under contention for vmap metadata
(e.g. alloc_vmap_area()).

However, yielding should only be done if the given GFP flags allow
blocking. This patch avoids calling cond_resched() when allocation
context is non-blocking(GFP_ATOMIC, GFP_NOWAIT).

Signed-off-by: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx>
---
mm/vmalloc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 49a0f81930a8..b77e8be75f10 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3633,7 +3633,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
pages + nr_allocated);

nr_allocated += nr;
- cond_resched();
+
+ if (gfpflags_allow_blocking(gfp))
+ cond_resched();

/*
* If zero or pages were obtained partly,
@@ -3675,7 +3677,9 @@ vm_area_alloc_pages(gfp_t gfp, int nid,
for (i = 0; i < (1U << order); i++)
pages[nr_allocated + i] = page + i;

- cond_resched();
+ if (gfpflags_allow_blocking(gfp))
+ cond_resched();
+
nr_allocated += 1U << order;
}

--
2.47.3