From: Baoquan He <bhe@redhat.com>
To: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Oleksiy Avramchenko <oleksiy.avramchenko@sony.com>
Subject: Re: [PATCH] vmalloc: Use atomic_long_add_return_relaxed()
Date: Tue, 15 Apr 2025 22:38:38 +0800 [thread overview]
Message-ID: <Z/5vbrTJPvQ2lA8R@MiWiFi-R3L-srv> (raw)
In-Reply-To: <20250415112646.113091-1-urezki@gmail.com>
On 04/15/25 at 01:26pm, Uladzislau Rezki (Sony) wrote:
> Switch from the atomic_long_add_return() to its relaxed version.
>
> We do not need a full memory barrier or any memory ordering during
> increasing the "vmap_lazy_nr" variable. What we only need is to do it
> atomically. This is what atomic_long_add_return_relaxed() guarantees.
>
> AARCH64:
>
> <snip>
> Default:
> 40ec: d34cfe94 lsr x20, x20, #12
> 40f0: 14000044 b 4200 <free_vmap_area_noflush+0x19c>
> 40f4: 94000000 bl 0 <__sanitizer_cov_trace_pc>
> 40f8: 90000000 adrp x0, 0 <__traceiter_alloc_vmap_area>
> 40fc: 91000000 add x0, x0, #0x0
> 4100: f8f40016 ldaddal x20, x22, [x0]
> 4104: 8b160296 add x22, x20, x22
>
> Relaxed:
> 40ec: d34cfe94 lsr x20, x20, #12
> 40f0: 14000044 b 4200 <free_vmap_area_noflush+0x19c>
> 40f4: 94000000 bl 0 <__sanitizer_cov_trace_pc>
> 40f8: 90000000 adrp x0, 0 <__traceiter_alloc_vmap_area>
> 40fc: 91000000 add x0, x0, #0x0
> 4100: f8340016 ldadd x20, x22, [x0]
> 4104: 8b160296 add x22, x20, x22
> <snip>
>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
> mm/vmalloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 7bb32f498d39..9d4027041a3f 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2370,7 +2370,7 @@ static void free_vmap_area_noflush(struct vmap_area *va)
> if (WARN_ON_ONCE(!list_empty(&va->list)))
> return;
>
> - nr_lazy = atomic_long_add_return(va_size(va) >> PAGE_SHIFT,
> + nr_lazy = atomic_long_add_return_relaxed(va_size(va) >> PAGE_SHIFT,
> &vmap_lazy_nr);
LGTM,
Reviewed-by: Baoquan He <bhe@redhat.com>
next prev parent reply other threads:[~2025-04-15 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 11:26 Uladzislau Rezki (Sony)
2025-04-15 14:38 ` Baoquan He [this message]
2025-04-15 17:37 ` Mateusz Guzik
2025-04-16 7:58 ` Uladzislau Rezki
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=Z/5vbrTJPvQ2lA8R@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleksiy.avramchenko@sony.com \
--cc=urezki@gmail.com \
/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