* [to-be-updated] mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain.patch removed from -mm tree
@ 2026-03-30 19:13 Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-03-30 19:13 UTC (permalink / raw)
To: mm-commits, lirongqing, bhe, urezki, akpm
The quilt patch titled
Subject: mm/vmalloc: use dedicated unbound workqueue for vmap purge/drain
has been removed from the -mm tree. Its filename was
mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Subject: mm/vmalloc: use dedicated unbound workqueue for vmap purge/drain
Date: Mon, 30 Mar 2026 19:58:24 +0200
The drain_vmap_area_work() function can take >10ms to complete when there
are many accumulated vmap areas in a system with a high CPU count, causing
workqueue watchdog warnings when run via schedule_work():
[ 2069.796205] workqueue: drain_vmap_area_work hogged CPU for >10000us 4 times, consider switching to WQ_UNBOUND
[ 2192.823225] workqueue: drain_vmap_area_work hogged CPU for >10000us 5 times, consider switching to WQ_UNBOUND
Switch to a dedicated WQ_UNBOUND workqueue to allow the scheduler to run
this background task on any available CPU, improving responsiveness. Use
WQ_MEM_RECLAIM to ensure forward progress under memory pressure.
If queuing work to the dedicated workqueue is not possible(during early
boot), fall back to processing locally to avoid losing progress.
Also simplify purge helper scheduling by removing cpumask-based iteration
in favour to iterating directly over vmap nodes with pending work.
Link: https://lkml.kernel.org/r/20260330175824.2777270-1-urezki@gmail.com
Link: https://lore.kernel.org/all/20260319074307.2325-1-lirongqing@baidu.com/
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/vmalloc.c | 74 +++++++++++++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 27 deletions(-)
--- a/mm/vmalloc.c~mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain
+++ a/mm/vmalloc.c
@@ -949,6 +949,7 @@ static struct vmap_node {
struct list_head purge_list;
struct work_struct purge_work;
unsigned long nr_purged;
+ bool work_queued;
} single;
/*
@@ -1067,6 +1068,7 @@ static void reclaim_and_purge_vmap_areas
static BLOCKING_NOTIFIER_HEAD(vmap_notify_list);
static void drain_vmap_area_work(struct work_struct *work);
static DECLARE_WORK(drain_vmap_work, drain_vmap_area_work);
+static struct workqueue_struct *drain_vmap_wq;
static __cacheline_aligned_in_smp atomic_long_t vmap_lazy_nr;
@@ -2329,6 +2331,19 @@ static void purge_vmap_node(struct work_
reclaim_list_global(&local_list);
}
+static bool
+schedule_drain_vmap_work(struct work_struct *work)
+{
+ struct workqueue_struct *wq = READ_ONCE(drain_vmap_wq);
+
+ if (wq) {
+ queue_work(wq, work);
+ return true;
+ }
+
+ return false;
+}
+
/*
* Purges all lazily-freed vmap areas.
*/
@@ -2336,19 +2351,12 @@ static bool __purge_vmap_area_lazy(unsig
bool full_pool_decay)
{
unsigned long nr_purged_areas = 0;
+ unsigned int nr_purge_nodes = 0;
unsigned int nr_purge_helpers;
- static cpumask_t purge_nodes;
- unsigned int nr_purge_nodes;
struct vmap_node *vn;
- int i;
lockdep_assert_held(&vmap_purge_lock);
- /*
- * Use cpumask to mark which node has to be processed.
- */
- purge_nodes = CPU_MASK_NONE;
-
for_each_vmap_node(vn) {
INIT_LIST_HEAD(&vn->purge_list);
vn->skip_populate = full_pool_decay;
@@ -2368,10 +2376,9 @@ static bool __purge_vmap_area_lazy(unsig
end = max(end, list_last_entry(&vn->purge_list,
struct vmap_area, list)->va_end);
- cpumask_set_cpu(node_to_id(vn), &purge_nodes);
+ nr_purge_nodes++;
}
- nr_purge_nodes = cpumask_weight(&purge_nodes);
if (nr_purge_nodes > 0) {
flush_tlb_kernel_range(start, end);
@@ -2379,29 +2386,30 @@ static bool __purge_vmap_area_lazy(unsig
nr_purge_helpers = atomic_long_read(&vmap_lazy_nr) / lazy_max_pages();
nr_purge_helpers = clamp(nr_purge_helpers, 1U, nr_purge_nodes) - 1;
- for_each_cpu(i, &purge_nodes) {
- vn = &vmap_nodes[i];
+ for_each_vmap_node(vn) {
+ vn->work_queued = false;
+
+ if (list_empty(&vn->purge_list))
+ continue;
if (nr_purge_helpers > 0) {
INIT_WORK(&vn->purge_work, purge_vmap_node);
+ vn->work_queued = schedule_drain_vmap_work(&vn->purge_work);
- if (cpumask_test_cpu(i, cpu_online_mask))
- schedule_work_on(i, &vn->purge_work);
- else
- schedule_work(&vn->purge_work);
-
- nr_purge_helpers--;
- } else {
- vn->purge_work.func = NULL;
- purge_vmap_node(&vn->purge_work);
- nr_purged_areas += vn->nr_purged;
+ if (vn->work_queued) {
+ nr_purge_helpers--;
+ continue;
+ }
}
- }
- for_each_cpu(i, &purge_nodes) {
- vn = &vmap_nodes[i];
+ /* Sync path. Process locally. */
+ purge_vmap_node(&vn->purge_work);
+ nr_purged_areas += vn->nr_purged;
+ }
- if (vn->purge_work.func) {
+ /* Wait for completion if queued any. */
+ for_each_vmap_node(vn) {
+ if (vn->work_queued) {
flush_work(&vn->purge_work);
nr_purged_areas += vn->nr_purged;
}
@@ -2465,7 +2473,7 @@ static void free_vmap_area_noflush(struc
/* After this point, we may free va at any time */
if (unlikely(nr_lazy > nr_lazy_max))
- schedule_work(&drain_vmap_work);
+ schedule_drain_vmap_work(&drain_vmap_work);
}
/*
@@ -5483,3 +5491,15 @@ void __init vmalloc_init(void)
vmap_node_shrinker->scan_objects = vmap_node_shrink_scan;
shrinker_register(vmap_node_shrinker);
}
+
+static int __init vmalloc_init_workqueue(void)
+{
+ struct workqueue_struct *wq;
+
+ wq = alloc_workqueue("vmap_drain", WQ_UNBOUND | WQ_MEM_RECLAIM, 0);
+ WARN_ON(wq == NULL);
+ WRITE_ONCE(drain_vmap_wq, wq);
+
+ return 0;
+}
+early_initcall(vmalloc_init_workqueue);
_
Patches currently in -mm which might be from urezki@gmail.com are
^ permalink raw reply [flat|nested] 2+ messages in thread* [to-be-updated] mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain.patch removed from -mm tree
@ 2026-04-01 21:27 Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-04-01 21:27 UTC (permalink / raw)
To: mm-commits, lirongqing, bhe, urezki, akpm
The quilt patch titled
Subject: mm/vmalloc: use dedicated unbound workqueue for vmap purge/drain
has been removed from the -mm tree. Its filename was
mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Subject: mm/vmalloc: use dedicated unbound workqueue for vmap purge/drain
Date: Mon, 30 Mar 2026 19:58:24 +0200
The drain_vmap_area_work() function can take >10ms to complete when there
are many accumulated vmap areas in a system with a high CPU count, causing
workqueue watchdog warnings when run via schedule_work():
[ 2069.796205] workqueue: drain_vmap_area_work hogged CPU for >10000us 4 times, consider switching to WQ_UNBOUND
[ 2192.823225] workqueue: drain_vmap_area_work hogged CPU for >10000us 5 times, consider switching to WQ_UNBOUND
Switch to a dedicated WQ_UNBOUND workqueue to allow the scheduler to run
this background task on any available CPU, improving responsiveness. Use
WQ_MEM_RECLAIM to ensure forward progress under memory pressure.
If queuing work to the dedicated workqueue is not possible(during early
boot), fall back to processing locally to avoid losing progress.
Also simplify purge helper scheduling by removing cpumask-based iteration
in favour to iterating directly over vmap nodes with pending work.
Link: https://lkml.kernel.org/r/20260330175824.2777270-1-urezki@gmail.com
Link: https://lore.kernel.org/all/20260319074307.2325-1-lirongqing@baidu.com/
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/vmalloc.c | 74 +++++++++++++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 27 deletions(-)
--- a/mm/vmalloc.c~mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain
+++ a/mm/vmalloc.c
@@ -949,6 +949,7 @@ static struct vmap_node {
struct list_head purge_list;
struct work_struct purge_work;
unsigned long nr_purged;
+ bool work_queued;
} single;
/*
@@ -1067,6 +1068,7 @@ static void reclaim_and_purge_vmap_areas
static BLOCKING_NOTIFIER_HEAD(vmap_notify_list);
static void drain_vmap_area_work(struct work_struct *work);
static DECLARE_WORK(drain_vmap_work, drain_vmap_area_work);
+static struct workqueue_struct *drain_vmap_wq;
static __cacheline_aligned_in_smp atomic_long_t vmap_lazy_nr;
@@ -2329,6 +2331,19 @@ static void purge_vmap_node(struct work_
reclaim_list_global(&local_list);
}
+static bool
+schedule_drain_vmap_work(struct work_struct *work)
+{
+ struct workqueue_struct *wq = READ_ONCE(drain_vmap_wq);
+
+ if (wq) {
+ queue_work(wq, work);
+ return true;
+ }
+
+ return false;
+}
+
/*
* Purges all lazily-freed vmap areas.
*/
@@ -2336,19 +2351,12 @@ static bool __purge_vmap_area_lazy(unsig
bool full_pool_decay)
{
unsigned long nr_purged_areas = 0;
+ unsigned int nr_purge_nodes = 0;
unsigned int nr_purge_helpers;
- static cpumask_t purge_nodes;
- unsigned int nr_purge_nodes;
struct vmap_node *vn;
- int i;
lockdep_assert_held(&vmap_purge_lock);
- /*
- * Use cpumask to mark which node has to be processed.
- */
- purge_nodes = CPU_MASK_NONE;
-
for_each_vmap_node(vn) {
INIT_LIST_HEAD(&vn->purge_list);
vn->skip_populate = full_pool_decay;
@@ -2368,10 +2376,9 @@ static bool __purge_vmap_area_lazy(unsig
end = max(end, list_last_entry(&vn->purge_list,
struct vmap_area, list)->va_end);
- cpumask_set_cpu(node_to_id(vn), &purge_nodes);
+ nr_purge_nodes++;
}
- nr_purge_nodes = cpumask_weight(&purge_nodes);
if (nr_purge_nodes > 0) {
flush_tlb_kernel_range(start, end);
@@ -2379,29 +2386,30 @@ static bool __purge_vmap_area_lazy(unsig
nr_purge_helpers = atomic_long_read(&vmap_lazy_nr) / lazy_max_pages();
nr_purge_helpers = clamp(nr_purge_helpers, 1U, nr_purge_nodes) - 1;
- for_each_cpu(i, &purge_nodes) {
- vn = &vmap_nodes[i];
+ for_each_vmap_node(vn) {
+ vn->work_queued = false;
+
+ if (list_empty(&vn->purge_list))
+ continue;
if (nr_purge_helpers > 0) {
INIT_WORK(&vn->purge_work, purge_vmap_node);
+ vn->work_queued = schedule_drain_vmap_work(&vn->purge_work);
- if (cpumask_test_cpu(i, cpu_online_mask))
- schedule_work_on(i, &vn->purge_work);
- else
- schedule_work(&vn->purge_work);
-
- nr_purge_helpers--;
- } else {
- vn->purge_work.func = NULL;
- purge_vmap_node(&vn->purge_work);
- nr_purged_areas += vn->nr_purged;
+ if (vn->work_queued) {
+ nr_purge_helpers--;
+ continue;
+ }
}
- }
- for_each_cpu(i, &purge_nodes) {
- vn = &vmap_nodes[i];
+ /* Sync path. Process locally. */
+ purge_vmap_node(&vn->purge_work);
+ nr_purged_areas += vn->nr_purged;
+ }
- if (vn->purge_work.func) {
+ /* Wait for completion if queued any. */
+ for_each_vmap_node(vn) {
+ if (vn->work_queued) {
flush_work(&vn->purge_work);
nr_purged_areas += vn->nr_purged;
}
@@ -2465,7 +2473,7 @@ static void free_vmap_area_noflush(struc
/* After this point, we may free va at any time */
if (unlikely(nr_lazy > nr_lazy_max))
- schedule_work(&drain_vmap_work);
+ schedule_drain_vmap_work(&drain_vmap_work);
}
/*
@@ -5483,3 +5491,15 @@ void __init vmalloc_init(void)
vmap_node_shrinker->scan_objects = vmap_node_shrink_scan;
shrinker_register(vmap_node_shrinker);
}
+
+static int __init vmalloc_init_workqueue(void)
+{
+ struct workqueue_struct *wq;
+
+ wq = alloc_workqueue("vmap_drain", WQ_UNBOUND | WQ_MEM_RECLAIM, 0);
+ WARN_ON(wq == NULL);
+ WRITE_ONCE(drain_vmap_wq, wq);
+
+ return 0;
+}
+early_initcall(vmalloc_init_workqueue);
_
Patches currently in -mm which might be from urezki@gmail.com are
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-01 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 19:13 [to-be-updated] mm-vmalloc-use-dedicated-unbound-workqueue-for-vmap-purge-drain.patch removed from -mm tree Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2026-04-01 21:27 Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox