From: Jeongjun Park <aha310510@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: urezki@gmail.com, edumazet@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] mm/vmalloc: fix data race in show_numa_info()
Date: Thu, 8 May 2025 13:47:32 +0900 [thread overview]
Message-ID: <CAO9qdTEL1xhBOXbSR4KHgmh0vpEeiia5ii9Ae959ahFHLVycRQ@mail.gmail.com> (raw)
In-Reply-To: <20250507153325.48726051dbbff4f3936a83ff@linux-foundation.org>
Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Wed, 7 May 2025 23:25:52 +0900 Jeongjun Park <aha310510@gmail.com> wrote:
>
> > The following data-race was found in show_numa_info():
> >
> > ...
> >
> >
> > According to this report, there is a read/write data-race because m->private
> > is accessible to multiple CPUs. To fix this, instead of allocating the heap
> > in proc_vmalloc_init() and passing the heap address to m->private,
> > show_numa_info() should allocate the heap.
> >
> > One thing to note is that show_numa_info() is called in a critical section
> > of a spinlock, so it must be allocated on the heap with GFP_ATOMIC flag.
>
> GFP_ATOMIC is unfortunate. Can vmalloc_info_show() allocate the
> storage outside the lock and pass that pointer into show_numa_info()?
> That way will be more efficient also, less allocating and freeing.
>
>
That's good idea! Definitely, if you modify vmalloc_info_show() to
allocate the heap before taking the spinlock and initialize the heap
to 0 at the beginning of the loop, we don't need to use GFP_ATOMIC,
and we only need to allocate the heap once, which is much more efficient.
I'll send you v4 patch that reflects this right away.
Regards,
Jeongjun Park
next prev parent reply other threads:[~2025-05-08 4:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 14:25 Jeongjun Park
2025-05-07 22:33 ` Andrew Morton
2025-05-08 4:47 ` Jeongjun Park [this message]
2025-05-08 7:56 ` Ozgur Kara
2025-05-07 22:50 ` Ozgur Kara
[not found] ` <01100196acf1ede5-ae116361-04f2-4e8f-b7a4-7079d6158ffb-000000@eu-north-1.amazonses.com>
2025-05-08 5:04 ` Jeongjun Park
2025-05-08 6:18 ` Jeongjun Park
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=CAO9qdTEL1xhBOXbSR4KHgmh0vpEeiia5ii9Ae959ahFHLVycRQ@mail.gmail.com \
--to=aha310510@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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