linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Wang <00107082@163.com>
To: harry.yoo@oracle.com, surenb@google.com, cachen@purestorage.com
Cc: ahuang12@lenovo.com, akpm@linux-foundation.org, bhe@redhat.com,
	hch@infradead.org, kent.overstreet@linux.dev,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org, lkp@intel.com,
	mjguzik@gmail.com, oe-lkp@lists.linux.dev, oliver.sang@intel.com,
	urezki@gmail.com
Subject: Re: Kernel crash due to alloc_tag_top_users() being called when !mem_profiling_support?
Date: Thu, 19 Jun 2025 23:08:09 +0800	[thread overview]
Message-ID: <20250619150809.69482-1-00107082@163.com> (raw)
In-Reply-To: <aFQaY4Bxle8-GT6O@harry>

> On Wed, Jun 18, 2025 at 02:25:37PM +0800, kernel test robot wrote:
> > 
> > Hello,
> > 
> > for this change, we reported
> > "[linux-next:master] [lib/test_vmalloc.c]  7fc85b92db: Mem-Info"
> > in
> > https://lore.kernel.org/all/202505071555.e757f1e0-lkp@intel.com/
> > 
> > at that time, we made some tests with x86_64 config which runs well.
> > 
> > now we noticed the commit is in mainline now.
> 
> (Re-sending due to not Ccing people and the list...)
> 
> Hi, I'm facing the same error on my testing environment.
> 
> I think this is related to memory allocation profiling & code tagging
> subsystems rather than vmalloc, so let's add related folks to Cc.
> 
> After a quick skimming of the code, it seems the condition
> to trigger this is that on 1) MEM_ALLOC_PROFILING is compiled but
> 2) not enabled by default. and 3) allocation somehow failed, calling
> alloc_tag_top_users().
> 
> I see "Memory allocation profiling is not supported!" in the dmesg,
> which means it did not alloc & inititialize alloc_tag_cttype properly,
> but alloc_tag_top_users() tries to acquire the semaphore.
> 
> I think the kernel should not call alloc_tag_top_users() at all (or it
> should return an error) if mem_profiling_support == false?
> 
> Does the following work on your testing environment?
> 
> (Only did very light testing on my QEMU, but seems to fix the issue for me.)
> 
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index d48b80f3f007..57d4d5673855 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -134,7 +134,9 @@ size_t alloc_tag_top_users(struct codetag_bytes *tags, size_t count, bool can_sl
>  	struct codetag_bytes n;
>  	unsigned int i, nr = 0;
>  
> -	if (can_sleep)
> +	if (!mem_profiling_support)
> +		return 0;
> +	else if (can_sleep)
>  		codetag_lock_module_list(alloc_tag_cttype, true);
>  	else if (!codetag_trylock_module_list(alloc_tag_cttype))
>  		return 0;

I think you are correct, this was introduced/exposed by
commit 780138b1 ("alloc_tag: check mem_profiling_support in alloc_tag_init")
(Before the commit, the BUG would only be triggered when alloc_tag_init failed)


David



  parent reply	other threads:[~2025-06-19 15:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18  6:25 [linus:master] [lib/test_vmalloc.c] 2d76e79315: Kernel_panic-not_syncing:Fatal_exception kernel test robot
2025-06-19 14:10 ` Kernel crash due to alloc_tag_top_users() being called when !mem_profiling_support? Harry Yoo
2025-06-19 15:04   ` Harry Yoo
2025-06-20  8:47     ` Uladzislau Rezki
2025-06-22 22:54       ` Suren Baghdasaryan
2025-06-23 11:29         ` Uladzislau Rezki
2025-06-19 15:08   ` David Wang [this message]
2025-06-20  1:14     ` Harry Yoo
2025-06-20  0:40 ` [PATCH] lib/alloc_tag: do not acquire nonexistent lock when mem profiling is disabled Harry Yoo
2025-06-20  3:09   ` David Wang
2025-06-20 10:40     ` [PATCH] " Harry Yoo
2025-06-20 11:33       ` Harry Yoo
2025-06-20 13:59         ` David Wang
2025-06-20 12:47       ` Harry Yoo
2025-06-20 10:02 ` CONFIG_TEST_VMALLOC=y conflict/race with alloc_tag_init David Wang
2025-06-22 22:50   ` Suren Baghdasaryan
2025-06-23  2:04     ` Harry Yoo
2025-06-23  2:45     ` David Wang
2025-06-23  3:16       ` David Wang
2025-06-23  4:39         ` David Wang
2025-06-23 11:36       ` Uladzislau Rezki
2025-06-23 13:20         ` David Wang
2025-06-20 14:24 ` [PATCH] lib/test_vmalloc.c: demote vmalloc_test_init to late_initcall David Wang
2025-06-20 19:59   ` Harry Yoo
2025-06-20 19:53 ` [PATCH v2] lib/alloc_tag: do not acquire non-existent lock in alloc_tag_top_users() Harry Yoo
2025-06-21  3:43   ` David Wang
2025-06-22 22:24     ` [PATCH " Suren Baghdasaryan
2025-06-23  2:01       ` Harry Yoo

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=20250619150809.69482-1-00107082@163.com \
    --to=00107082@163.com \
    --cc=ahuang12@lenovo.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=cachen@purestorage.com \
    --cc=harry.yoo@oracle.com \
    --cc=hch@infradead.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mjguzik@gmail.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    --cc=surenb@google.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