linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Gong Ruiqi <gongruiqi1@huawei.com>
Cc: <linux-mm@kvack.org>, <linux-hardening@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>, <kasan-dev@googlegroups.com>,
	Wang Weiyang <wangweiyang2@huawei.com>,
	"Xiu Jianfeng" <xiujianfeng@huawei.com>,
	Pedro Falcato <pedro.falcato@gmail.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Christoph Lameter <cl@linux.com>,
	"David Rientjes" <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH RFC v2] Randomized slab caches for kmalloc()
Date: Tue, 16 May 2023 14:43:46 +0200	[thread overview]
Message-ID: <45db388c-781b-b6e7-ca9a-fc4526f8fad6@intel.com> (raw)
In-Reply-To: <fe79912f-3232-ffba-a191-477c80c703f4@huawei.com>

From: Gong Ruiqi <gongruiqi1@huawei.com>
Date: Mon, 15 May 2023 14:26:31 +0800

> 
> On 2023/05/11 22:54, Alexander Lobakin wrote:

[...]

> I tried this way of implementation but it didn't work: it did not
> propagate from 16 to 1, but stopped in the middle. I think it's because
> the macro is somehow (indirectly) self-referential and the preprocessor
> won't expand it. Check this for more info:
> 
> https://gcc.gnu.org/onlinedocs/cpp/Self-Referential-Macros.html

Ooops, I missed that, sorry. Thanks for the link!

> 
>> Also I'd rather not put commas ',' at the end of each macro, they're
>> usually put outside where the macro is used.
> 
> It seems here we have to put commas at the end. Not only it's to align
> with how KMALLOC_{RCL,CGROUP,DMA}_NAME are implemented, but also
> otherwise the expansion of INIT_KMALLOC_INFO would in some cases be like:
> 
> {
> 	.name[KMALLOC_NORMAL]  = "kmalloc-" #__short_size,
> 	, // an empty entry with a comma
> }
> 
> which would cause compilation error in kmalloc_info[]'s initialization.

+

> 
>>> +#endif
>>> +#else // CONFIG_RANDOM_KMALLOC_CACHES
>>> +#define KMALLOC_RANDOM_NAME(N, sz)
>>> +#endif
>>> +
>>>  #define INIT_KMALLOC_INFO(__size, __short_size)			\
>>>  {								\
>>>  	.name[KMALLOC_NORMAL]  = "kmalloc-" #__short_size,	\
>>>  	KMALLOC_RCL_NAME(__short_size)				\
>>>  	KMALLOC_CGROUP_NAME(__short_size)			\
>>>  	KMALLOC_DMA_NAME(__short_size)				\
>>> +	KMALLOC_RANDOM_NAME(CONFIG_RANDOM_KMALLOC_CACHES_NR, __short_size)	\
>>
>> Can't those names be __initconst and here you'd just do one loop from 1
>> to KMALLOC_CACHES_NR, which would assign names? I'm not sure compilers
>> will expand that one to a compile-time constant and assigning 69
>> different string pointers per one kmalloc size is a bit of a waste to me.
> 
> I'm not sure if I understand the question correctly, but I believe these
> names have been __initconst since kmalloc_info[] is already marked with
> it. Please let me know if it doesn't answer your question.

Ah okay, it's just me trying to show off without looking at the code. I
thought INIT_KMALLOC_INFO() is used somewhere in a function (from its
name), but it's used to initialize const array, okay.

> 
>>>  	.size = __size,						\
>>>  }
[...]

Thanks,
Olek



  reply	other threads:[~2023-05-16 12:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08  7:55 GONG, Ruiqi
2023-05-10 18:43 ` Hyeonggon Yoo
2023-05-10 19:32   ` Pedro Falcato
2023-05-12 10:11   ` Gong Ruiqi
2023-05-14  9:30     ` Vlastimil Babka
2023-05-15  8:20       ` Gong Ruiqi
2023-05-16 22:35     ` Hyeonggon Yoo
2023-05-22  7:35       ` Gong Ruiqi
2023-05-22  8:03         ` Hyeonggon Yoo
2023-05-22  8:58           ` GONG, Ruiqi
2023-05-24  5:54             ` Hyeonggon Yoo
2023-05-31  3:47               ` GONG, Ruiqi
2023-05-11 12:30 ` xiujianfeng
2023-05-11 14:54 ` Alexander Lobakin
2023-05-15  6:26   ` Gong Ruiqi
2023-05-16 12:43     ` Alexander Lobakin [this message]
2023-05-16 19:34 ` Kees Cook
2023-05-31  7:59   ` Gong Ruiqi

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=45db388c-781b-b6e7-ca9a-fc4526f8fad6@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=gongruiqi1@huawei.com \
    --cc=gustavoars@kernel.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jmorris@namei.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paul@paul-moore.com \
    --cc=pedro.falcato@gmail.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=serge@hallyn.com \
    --cc=vbabka@suse.cz \
    --cc=wangweiyang2@huawei.com \
    --cc=xiujianfeng@huawei.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