linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Pei Xiao <xiaopei01@kylinos.cn>, surenb@google.com
Cc: akpm@linux-foundation.org, gehao@kylinos.cn, hao.ge@linux.dev,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	xiaopeitux@foxmail.com, xiongxin@kylinos.cn, yuzhao@google.com
Subject: Re: [PATCH] slub_kunit:fix a WARNING due to __kmalloc_cache_noprof incorretly use
Date: Wed, 23 Oct 2024 10:00:48 +0200	[thread overview]
Message-ID: <873ca7e7-5789-4e4c-b3aa-4331cf2b6638@suse.cz> (raw)
In-Reply-To: <0c215961308b0433cd76389fe53d7f7776a32dcb.1729663738.git.xiaopei01@kylinos.cn>

On 10/23/24 08:21, Pei Xiao wrote:
> 'modprobe slub_kunit',will have a warning [1].The root cause is that
> __kmalloc_cache_noprof was directly used,which resulted in no alloc_tag
> being allocated.This caused current->alloc_tag to be null,leading to
> a warning in alloc_tag_add_check.
> 
> Let's add an alloc_hook layer to __kmalloc_cache_noprof specifically
> within lib/slub_kunit.c.
> 
> [1].
> [58162.947016] WARNING: CPU: 2 PID: 6210 at
> ./include/linux/alloc_tag.h:125 alloc_tagging_slab_alloc_hook+0x268/0x27c
> [58162.957721] Call trace:
> [58162.957919]  alloc_tagging_slab_alloc_hook+0x268/0x27c
> [58162.958286]  __kmalloc_cache_noprof+0x14c/0x344
> [58162.958615]  test_kmalloc_redzone_access+0x50/0x10c [slub_kunit]
> [58162.959045]  kunit_try_run_case+0x74/0x184 [kunit]
> [58162.959401]  kunit_generic_run_threadfn_adapter+0x2c/0x4c [kunit]
> [58162.959841]  kthread+0x10c/0x118
> [58162.960093]  ret_from_fork+0x10/0x20
> [58162.960363] ---[ end trace 0000000000000000 ]---
> 
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()")

Thanks, I'm adding the fix for test_kmalloc_redzone_access() to
slab/for-6.12-rc4/fixes as a 6.12 hotfix

> Fixes: a286da323418 ("mm/slub, kunit: Add testcase for krealloc redzone and zeroing")

This is in slab/for-next so I will just adjust the new tests in place there.

> ---
>  lib/slub_kunit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c
> index 3cd1cc667988..f11691315c2f 100644
> --- a/lib/slub_kunit.c
> +++ b/lib/slub_kunit.c
> @@ -141,7 +141,7 @@ static void test_kmalloc_redzone_access(struct kunit *test)
>  {
>  	struct kmem_cache *s = test_kmem_cache_create("TestSlub_RZ_kmalloc", 32,
>  				SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE);
> -	u8 *p = __kmalloc_cache_noprof(s, GFP_KERNEL, 18);
> +	u8 *p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 18));
>  
>  	kasan_disable_current();
>  
> @@ -199,7 +199,7 @@ static void test_krealloc_redzone_zeroing(struct kunit *test)
>  	struct kmem_cache *s = test_kmem_cache_create("TestSlub_krealloc", 64,
>  				SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE);
>  
> -	p = __kmalloc_cache_noprof(s, GFP_KERNEL, 48);
> +	p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 48));
>  	memset(p, 0xff, 48);
>  
>  	kasan_disable_current();



      reply	other threads:[~2024-10-23  8:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21  6:59 [PATCH] slub/slub_kunit:fix a panic " xiaopeitux
2024-10-21 17:42 ` Suren Baghdasaryan
2024-10-22  2:19   ` Hao Ge
2024-10-22 15:27     ` Vlastimil Babka
2024-10-23  1:47       ` Hao Ge
2024-10-23  1:58         ` Suren Baghdasaryan
2024-10-23  6:21           ` [PATCH] slub_kunit:fix a WARNING " Pei Xiao
2024-10-23  8:00             ` Vlastimil Babka [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=873ca7e7-5789-4e4c-b3aa-4331cf2b6638@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=gehao@kylinos.cn \
    --cc=hao.ge@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=surenb@google.com \
    --cc=xiaopei01@kylinos.cn \
    --cc=xiaopeitux@foxmail.com \
    --cc=xiongxin@kylinos.cn \
    --cc=yuzhao@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox