答复: [????] Re: ??: [????] Re: [PATCH v2] mm/vmalloc: use dedicated unbound workqueue for vmap area draining
From: Li,Rongqing(ACG CCN)
Date: Fri Mar 20 2026 - 01:51:16 EST
> That is true.
>
> <snip>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c index
> 61caa55a4402..81e1e74346d5 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1067,6 +1067,7 @@ static void reclaim_and_purge_vmap_areas(void);
> 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 nr_vmalloc_pages; static
> __cacheline_aligned_in_smp atomic_long_t vmap_lazy_nr; @@ -2437,6
> +2438,17 @@ static void drain_vmap_area_work(struct work_struct *work)
> mutex_unlock(&vmap_purge_lock);
> }
>
> +static void
> +schedule_drain_vmap_work(unsigned long nr_lazy, unsigned long
> +nr_lazy_max) {
> + if (unlikely(nr_lazy > nr_lazy_max)) {
> + struct workqueue_struct *wq = READ_ONCE(drain_vmap_wq);
> +
> + if (wq)
> + queue_work(wq, &drain_vmap_work);
> + }
> +}
> +
> /*
> * Free a vmap area, caller ensuring that the area has been unmapped,
> * unlinked and flush_cache_vunmap had been called for the correct @@
> -2470,8 +2482,7 @@ static void free_vmap_area_noflush(struct vmap_area
> *va)
> trace_free_vmap_area_noflush(va_start, nr_lazy, nr_lazy_max);
>
> /* 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(nr_lazy, nr_lazy_max);
> }
>
> /*
> @@ -5483,3 +5494,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);
> <snip>
>
I test the upper codes, it works for me, Do you like to send a formal patch?
Reported-and-tested-by: Li RongQing <lirongqing@xxxxxxxxx>
thanks
[Li,Rongqing]
> --
> Uladzislau Rezki