From: Hao Ge <hao.ge@linux.dev>
To: Suren Baghdasaryan <surenb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [RFC PATCH 3/3] alloc_tag: remove /proc/allocinfo outside of mod_lock
Date: Mon, 17 Aug 2026 13:41:44 +0800 [thread overview]
Message-ID: <27f2ea45-cfee-40d4-8cf1-5955574c48bf@linux.dev> (raw)
In-Reply-To: <CAJuCfpGfQrYJ=Rgrar-8btsiUCg=OQotWPou0J-mpMFNzrJC6A@mail.gmail.com>
Hi Suren
On 2026/8/15 14:51, Suren Baghdasaryan wrote:
> On Thu, Aug 13, 2026 at 2:34 AM Hao Ge <hao.ge@linux.dev> wrote:
>>
>> shutdown_mem_profiling() calls remove_proc_entry() from
>> reserve_module_tags(), which runs under mod_lock held for write.
>> remove_proc_entry() waits for readers, and a reader takes mod_lock for
>> read in allocinfo_start():
>>
>> CPU0 (insmod) CPU1 (read /proc/allocinfo)
>> ---------------- ----------------------------
>> reserve_module_tags()
>> down_write(&mod_lock) [held]
>> use_pde() [in_use++]
>> allocinfo_start()
>> down_read(&mod_lock) <- blocks
>> shutdown_mem_profiling()
>> remove_proc_entry()
>> wait for in_use == 0 <- blocks
>
> Yes, this is indeed a possible race.
>
>>
>> Move remove_proc_entry() to a workqueue.
>>
>> Fixes: 4835f747d3ed ("alloc_tag: support for page allocation tag compression")
>
> I think all these issues were reported by Sashiko, so you should add a
> Reported-by tag.
>
Right, I'll add them. Patches 1 and 3 will be resent as a standalone
two-patch series with the Reported-by tags included.
Thanks a lot for all the help on this series.
Thanks
Best Regards
Hao
>> Signed-off-by: Hao Ge <hao.ge@linux.dev>
>
> LGTM
>
>> ---
>> mm/alloc_tag.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
>> index 7481180dadd2..b80f5a151f28 100644
>> --- a/mm/alloc_tag.c
>> +++ b/mm/alloc_tag.c
>> @@ -591,6 +591,13 @@ void pgalloc_tag_swap(struct folio *new, struct folio *old)
>> put_page_tag_ref(handle_new);
>> }
>>
>> +static void remove_allocinfo_file(struct work_struct *work)
>> +{
>> + remove_proc_entry(ALLOCINFO_FILE_NAME, NULL);
>> +}
>> +
>> +static DECLARE_WORK(remove_allocinfo_work, remove_allocinfo_file);
>> +
>> static void shutdown_mem_profiling(bool remove_file)
>> {
>> if (mem_alloc_profiling_enabled())
>> @@ -600,7 +607,7 @@ static void shutdown_mem_profiling(bool remove_file)
>> return;
>>
>> if (remove_file)
>> - remove_proc_entry(ALLOCINFO_FILE_NAME, NULL);
>> + schedule_work(&remove_allocinfo_work);
>> mem_profiling_support = false;
>> }
>>
>> --
>> 2.25.1
>>
prev parent reply other threads:[~2026-08-17 5:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 9:34 [RFC PATCH 0/3] alloc_tag: fix races and a leak around shutdown_mem_profiling() Hao Ge
2026-08-13 9:34 ` [RFC PATCH 1/3] alloc_tag: skip percpu counter allocation when profiling is disabled Hao Ge
2026-08-13 9:49 ` sashiko-bot
2026-08-15 6:15 ` Suren Baghdasaryan
2026-08-17 5:05 ` Hao Ge
2026-08-13 9:34 ` [RFC PATCH 2/3] module: move codetag section placement decision to layout_sections() Hao Ge
2026-08-13 9:54 ` sashiko-bot
2026-08-15 6:21 ` Suren Baghdasaryan
2026-08-17 5:37 ` Hao Ge
2026-08-13 9:34 ` [RFC PATCH 3/3] alloc_tag: remove /proc/allocinfo outside of mod_lock Hao Ge
2026-08-13 9:57 ` sashiko-bot
2026-08-15 6:51 ` Suren Baghdasaryan
2026-08-17 5:41 ` Hao Ge [this message]
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=27f2ea45-cfee-40d4-8cf1-5955574c48bf@linux.dev \
--to=hao.ge@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=atomlin@atomlin.com \
--cc=da.gomez@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
--cc=surenb@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.