From: Uladzislau Rezki <urezki@gmail.com>
To: Ye Liu <ye.liu@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Uladzislau Rezki <urezki@gmail.com>,
linux-mm@kvack.org, Ye Liu <liuye@kylinos.cn>
Subject: Re: [PATCH 2/8] mm/vmalloc: extract pcpu_release_va helper
Date: Sun, 6 Dec 2026 16:44:07 +0100 [thread overview]
Message-ID: <axWCx7jBxP6u1uTA@milan> (raw)
In-Reply-To: <20261203-vmalloc_cleanup_1-v1-2-6ebde19040f4@linux.dev>
On Thu, Dec 03, 2026 at 09:22:13AM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Extract the repeated pattern of returning a vmap_area to the free
> tree with KASAN shadow release into a pcpu_release_va() helper,
> used by both the recovery and err_free_shadow error paths in
> pcpu_get_vm_areas(). No functional change.
>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
> mm/vmalloc.c | 38 +++++++++++++++++++++-----------------
> 1 file changed, 21 insertions(+), 17 deletions(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 56f0bfc3147c..1f6ef2530e9e 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -5181,6 +5181,24 @@ pvm_determine_end_from_reverse(struct vmap_area **va, unsigned long align)
> return 0;
> }
>
> +/*
> + * Return a vmap_area to the free tree and release its KASAN shadow.
> + * Must be called with free_vmap_area_lock held.
> + */
> +static void pcpu_release_va(struct vmap_area *va)
> +{
> + unsigned long orig_start = va->va_start;
> + unsigned long orig_end = va->va_end;
> + struct vmap_area *merged;
> +
> + merged = merge_or_add_vmap_area_augment(va, &free_vmap_area_root,
> + &free_vmap_area_list);
> + if (merged)
> + kasan_release_vmalloc(orig_start, orig_end,
> + merged->va_start, merged->va_end,
> + KASAN_VMALLOC_PAGE_RANGE | KASAN_VMALLOC_TLB_FLUSH);
> +}
> +
> /**
> * pcpu_get_vm_areas - allocate vmalloc areas for percpu allocator
> * @offsets: array containing offset of each area
> @@ -5215,7 +5233,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
> struct vmap_area **vas, *va;
> struct vm_struct **vms;
> int area, area2, last_area, term_area;
> - unsigned long base, start, size, end, last_end, orig_start, orig_end;
> + unsigned long base, start, size, end, last_end;
> bool purged = false;
>
> /* verify parameters and allocate data structures */
> @@ -5382,14 +5400,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
> * and when pcpu_get_vm_areas() is success.
> */
> while (area--) {
> - orig_start = vas[area]->va_start;
> - orig_end = vas[area]->va_end;
> - va = merge_or_add_vmap_area_augment(vas[area], &free_vmap_area_root,
> - &free_vmap_area_list);
> - if (va)
> - kasan_release_vmalloc(orig_start, orig_end,
> - va->va_start, va->va_end,
> - KASAN_VMALLOC_PAGE_RANGE | KASAN_VMALLOC_TLB_FLUSH);
> + pcpu_release_va(vas[area]);
> vas[area] = NULL;
> }
>
> @@ -5433,14 +5444,7 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
> * being able to tolerate this case.
> */
> for (area = 0; area < nr_vms; area++) {
> - orig_start = vas[area]->va_start;
> - orig_end = vas[area]->va_end;
> - va = merge_or_add_vmap_area_augment(vas[area], &free_vmap_area_root,
> - &free_vmap_area_list);
> - if (va)
> - kasan_release_vmalloc(orig_start, orig_end,
> - va->va_start, va->va_end,
> - KASAN_VMALLOC_PAGE_RANGE | KASAN_VMALLOC_TLB_FLUSH);
> + pcpu_release_va(vas[area]);
> vas[area] = NULL;
> kfree(vms[area]);
> }
>
> --
> 2.25.1
>
Looks good. Shall we move the looping inside the helper as well?
I think, the helper should be renamed:
pcpu_cleanup_vas()?
--
Uladzislau Rezki
next prev parent reply other threads:[~2026-12-06 15:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 1:22 [PATCH 0/8] mm/vmalloc: assorted cleanups and minor fixes Ye Liu
2026-12-03 1:22 ` [PATCH 1/8] mm/vmalloc: use ALIGN_DOWN for vmalloc end alignment Ye Liu
2026-12-03 5:29 ` Dev Jain
2026-12-06 15:28 ` Uladzislau Rezki
2026-12-03 1:22 ` [PATCH 2/8] mm/vmalloc: extract pcpu_release_va helper Ye Liu
2026-12-06 15:44 ` Uladzislau Rezki [this message]
2026-12-03 1:22 ` [PATCH 3/8] mm/vmalloc: fix misleading pr_warn in alloc_vmap_area Ye Liu
2026-12-03 1:22 ` [PATCH 4/8] mm/vmalloc: simplify is_vn_id_valid predicate Ye Liu
2026-12-03 1:22 ` [PATCH 5/8] mm/vmalloc: move pool length update under pool_lock in decay_va_pool_node() Ye Liu
2026-12-03 1:22 ` [PATCH 6/8] mm/vmalloc: report node count when falling back to a single node Ye Liu
2026-12-03 1:22 ` [PATCH 7/8] mm/vmalloc: drop the double negation in vmap_insert_free_area() Ye Liu
2026-12-03 1:22 ` [PATCH 8/8] mm/vmalloc: compare addresses directly in vmap_init_free_space() Ye Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axWCx7jBxP6u1uTA@milan \
--to=urezki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
--cc=ye.liu@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox