linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Harry Yoo <harry.yoo@oracle.com>
To: Ye Bin <yebin@huaweicloud.com>
Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	vbabka@suse.cz, roman.gushchin@linux.dev, linux-mm@kvack.org,
	yebin10@huawei.com
Subject: Re: [PATCH] mm/slab: call __kmalloc_noprof() when size isn't builtin constant in kmalloc_array_noprof()
Date: Sun, 2 Mar 2025 22:30:36 +0900	[thread overview]
Message-ID: <Z8RdfF8hnIBB3hEO@harry> (raw)
In-Reply-To: <20250301083720.380063-1-yebin@huaweicloud.com>

On Sat, Mar 01, 2025 at 04:37:20PM +0800, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
> 
> If 'n' or 'size' isn't builtin constant just call __kmalloc_noprof()
> in kmalloc_array_noprof().
> 
> Fixes: 7bd230a26648 ("mm/slab: enable slab allocation tagging for kmalloc and friends")
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
>  include/linux/slab.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 3b03b31831a9..0edb8363fc4f 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -947,7 +947,7 @@ static inline __alloc_size(1, 2) void *kmalloc_array_noprof(size_t n, size_t siz
>  		return NULL;
>  	if (__builtin_constant_p(n) && __builtin_constant_p(size))
>  		return kmalloc_noprof(bytes, flags);
> -	return kmalloc_noprof(bytes, flags);
> +	return __kmalloc_noprof(bytes, flags);

Can we simply call kmalloc_noprof(bytes, flags) once instead?

The compiler should know 'bytes' is a constant if both 'n' and 'size' are
constants.

>  }
>  #define kmalloc_array(...)			alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
>  
> -- 
> 2.34.1

-- 
Cheers,
Harry


  reply	other threads:[~2025-03-02 13:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-01  8:37 Ye Bin
2025-03-02 13:30 ` Harry Yoo [this message]
2025-03-04 10:03   ` Vlastimil Babka
2025-03-04 23:32     ` 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=Z8RdfF8hnIBB3hEO@harry \
    --to=harry.yoo@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    --cc=yebin10@huawei.com \
    --cc=yebin@huaweicloud.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