Re: [PATCH 2/2] alloc_tag: remove /proc/allocinfo outside of mod_lock
From: Suren Baghdasaryan
Date: Mon Aug 24 2026 - 12:46:52 EST
On Sun, Aug 16, 2026 at 11:27 PM Hao Ge <hao.ge@xxxxxxxxx> 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
>
> Move remove_proc_entry() to a workqueue.
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Fixes: 4835f747d3ed ("alloc_tag: support for page allocation tag compression")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Hao Ge <hao.ge@xxxxxxxxx>
Acked-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> ---
> mm/alloc_tag.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
> index 80eccaca665a..b1d48532a25a 100644
> --- a/mm/alloc_tag.c
> +++ b/mm/alloc_tag.c
> @@ -15,6 +15,7 @@
> #include <linux/seq_file.h>
> #include <linux/string_choices.h>
> #include <linux/vmalloc.h>
> +#include <linux/workqueue.h>
> #include <linux/kmemleak.h>
> #include <uapi/linux/alloc_tag.h>
>
> @@ -591,6 +592,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 +608,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
>