From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796183280; b=merxvB8LKRo4ufyJ0uDsHnsZmpMVO8OdQF6pBkXi3QGMul35vo5UNQ2b7rDWG4BEGAw0 FxhI4iNqgmEYUJuEbiYkirZlZPBkZ19N5m32RRsbDYP1uxgeWVSg5SDfwxc7Jigzz91Qz 1E8/iifgFc41ZkZMfq3pNshT5IiMf+2AsgEMSeztJCc5R2f1NbMioRWzwE45p9fDhWj2+ E2wP0uVCvBDD9Ll9pbcQWtS+9XApLesLeB6lPLnOnlgalDFYztBpD/+YJsBwNf7FrhoGk SAOV6Za1Hm9dosxOyb+ce+xr33RJq8uFpnSTyLaJpBLCRGT0KxjngDwnmB6rXVpYQmA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796183280; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=/X87We1ZN82e1jH8eR0lRfP0fZLS6VzsK57zxJ8EuPM=; b=fILXuOOq45ykRuVSPCvcqJknka0Fu0By5bMz7EEEYCF8ZNkXFGOIfeUa4fmE5HAUqZRm QVFXpL7HckJO4Ca9cPgEYfM+1KLG0HfFURnwCy3SK1pp/Sd9YrRRLBpJMUl86OdyLOiMY naP+GxJ9uuA2WlTGMBfqKpDma1A4fhrQTA7xckI4Qll6KVhxST9QNyFXoVFoMiZF4pYIl 9EbEiwqJ+dFwoBaKVO6XRR9YyeEpOQRxLr9i96MPlOYEL6EyExXopDIZ4R6K2cZprpPKW 8h4wjCvYvcA5UG0d7ER5chg9rNsrC4gXq8YprM6O7jbMUDLQY6vZ/JerbQudf3FFtpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=bk8cIuO7; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CED01606A325; Wed, 2 Dec 2026 03:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=bk8cIuO7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B31E1F00899; Wed, 2 Dec 2026 03:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796183280; bh=/X87We1ZN82e1jH8eR0lRfP0fZLS6VzsK57zxJ8EuPM=; h=Date:To:From:In-Reply-To:References:Subject; b=bk8cIuO7Do7GHtPIgwillWRPdOMMZ6ufXGBRviR2fc60aqfWheJgnJLx7BVfhF0/D H0b5J6kCN6LReAFavuxcRjDbhB2YpvkWWTlkgWHyyB33Im+jwEcvKkx5laIaKY3NNR Esjfq1feb+VS56O+zNlTNtRkMsLHQReJm8xGQFKo= Date: Tue, 01 Dec 2026 19:47:59 -0800 To: mm-commits@vger.kernel.org,stable@vger.kernel.org,liuye@kylinos.cn, lirongqing@baidu.com,hdanton@sina.com,dev.jain@arm.com,bhe@redhat.com, urezki@gmail.com,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20260905152717.11711-1-urezki@gmail.com> References: <20260905152717.11711-1-urezki@gmail.com> Subject: [merged mm-hotfixes-stable] mm-vmalloc-use-dedicated-unbound-workqueues-for-vmap-drain.patch removed from -mm tree Message-Id: <20261202034800.5B31E1F00899@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The quilt patch titled Subject: mm/vmalloc: use dedicated unbound workqueues for vmap drain has been removed from the -mm tree. Its filename was mm-vmalloc-use-dedicated-unbound-workqueues-for-vmap-drain.patch This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: "Uladzislau Rezki (Sony)" Subject: mm/vmalloc: use dedicated unbound workqueues for vmap drain Date: Sat, 5 Sep 2026 17:27:17 +0200 drain_vmap_area_work() function can take >10ms to complete when there are many accumulated vmap areas in a system with high CPU count, causing workqueue watchdog warnings when run via schedule_work(): workqueue: drain_vmap_area_work hogged CPU for >10000us Move the top-level drain work to a dedicated WQ_UNBOUND workqueue so the scheduler can run this background work on any available CPU, improving responsiveness. Use the WQ_MEM_RECLAIM to ensure forward progress under memory pressure. Move purge helpers to separate WQ_UNBOUND | WQ_MEM_RECLAIM workqueue. This allows drain_vmap_work to wait for helpers completion without creating dependency on the same rescuer thread and avoid a potential parent/child deadlock. Simplify purge helper scheduling by removing cpumask-based iteration to iterating directly over vmap nodes checking work_queued state. Link: https://patch.msgid.link/20260905152717.11711-1-urezki@gmail.com Fixes: 72210662c5a2 ("mm: vmalloc: offload free_vmap_area_lock lock") Signed-off-by: Uladzislau Rezki (Sony) Signed-off-by: Andrew Morton Reported-by: Li RongQing Closes: https://lore.kernel.org/all/20260319074307.2325-1-lirongqing@baidu.com/ Reviewed-by: Baoquan He Reviewed-by: Ye Liu Cc: Dev Jain Cc: Hillf Danton Cc: mm/vmalloc.c | 79 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 27 deletions(-) --- a/mm/vmalloc.c~mm-vmalloc-use-dedicated-unbound-workqueues-for-vmap-drain +++ a/mm/vmalloc.c @@ -978,6 +978,7 @@ static struct vmap_node { struct list_head purge_list; struct work_struct purge_work; unsigned long nr_purged; + bool work_queued; } single; /* @@ -1096,6 +1097,8 @@ 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_helpers_wq; +static struct workqueue_struct *drain_vmap_wq; static __cacheline_aligned_in_smp atomic_long_t vmap_lazy_nr; @@ -2357,6 +2360,16 @@ static void purge_vmap_node(struct work_ reclaim_list_global(&local_list); } +static bool +schedule_drain_vmap_work(struct workqueue_struct *wq, + struct work_struct *work) +{ + if (wq) + return queue_work(wq, work); + + return false; +} + /* * Purges all lazily-freed vmap areas. */ @@ -2364,19 +2377,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; @@ -2396,10 +2402,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); @@ -2407,29 +2412,31 @@ 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( + READ_ONCE(drain_vmap_helpers_wq), &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; } @@ -2493,7 +2500,8 @@ 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(READ_ONCE(drain_vmap_wq), + &drain_vmap_work); } /* @@ -5639,3 +5647,20 @@ 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 *drain_wq, *helpers_wq; + unsigned int flags = WQ_UNBOUND | WQ_MEM_RECLAIM; + + drain_wq = alloc_workqueue("vmap_drain", flags, 0); + WARN_ON_ONCE(drain_wq == NULL); + WRITE_ONCE(drain_vmap_wq, drain_wq); + + helpers_wq = alloc_workqueue("vmap_drain_helpers", flags, 0); + WARN_ON_ONCE(helpers_wq == NULL); + WRITE_ONCE(drain_vmap_helpers_wq, helpers_wq); + + return 0; +} +early_initcall(vmalloc_init_workqueue); _ Patches currently in -mm which might be from urezki@gmail.com are mm-vmalloc-bail-out-if-in-softirq-context.patch