* [PATCH 1/1] mm/slab: remove duplicate check in create_cache()
@ 2024-08-21 3:26 Zhen Lei
2024-10-02 12:09 ` Vlastimil Babka
0 siblings, 1 reply; 3+ messages in thread
From: Zhen Lei @ 2024-08-21 3:26 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
linux-mm, linux-kernel
Cc: Zhen Lei
The WARN_ON() check in static function create_cache() is done by its only
parent kmem_cache_create_usercopy() before calling it.
if (...
WARN_ON(size < usersize || size - usersize < useroffset))
usersize = useroffset = 0;
...
s = create_cache(..., size, ..., useroffset, usersize, ...);
Therefore, the WARN_ON() check in create_cache() can be safely removed.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
mm/slab_common.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 40b582a014b8f2f..3069c9095523484 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -210,9 +210,6 @@ static struct kmem_cache *create_cache(const char *name,
struct kmem_cache *s;
int err;
- if (WARN_ON(useroffset + usersize > object_size))
- useroffset = usersize = 0;
-
err = -ENOMEM;
s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL);
if (!s)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mm/slab: remove duplicate check in create_cache()
2024-08-21 3:26 [PATCH 1/1] mm/slab: remove duplicate check in create_cache() Zhen Lei
@ 2024-10-02 12:09 ` Vlastimil Babka
2024-10-08 3:29 ` Leizhen (ThunderTown)
0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2024-10-02 12:09 UTC (permalink / raw)
To: Zhen Lei, Christoph Lameter, Pekka Enberg, David Rientjes,
Joonsoo Kim, Andrew Morton, Roman Gushchin, Hyeonggon Yoo,
linux-mm, linux-kernel
On 8/21/24 05:26, Zhen Lei wrote:
> The WARN_ON() check in static function create_cache() is done by its only
> parent kmem_cache_create_usercopy() before calling it.
> if (...
> WARN_ON(size < usersize || size - usersize < useroffset))
> usersize = useroffset = 0;
> ...
> s = create_cache(..., size, ..., useroffset, usersize, ...);
>
> Therefore, the WARN_ON() check in create_cache() can be safely removed.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Hi, sorry for the late reply.
This code was heavily refactored as of 6.12-rc1. Can you check if it's still
the case and send updated patch?
Thanks,
Vlastimil
> ---
> mm/slab_common.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 40b582a014b8f2f..3069c9095523484 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -210,9 +210,6 @@ static struct kmem_cache *create_cache(const char *name,
> struct kmem_cache *s;
> int err;
>
> - if (WARN_ON(useroffset + usersize > object_size))
> - useroffset = usersize = 0;
> -
> err = -ENOMEM;
> s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL);
> if (!s)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] mm/slab: remove duplicate check in create_cache()
2024-10-02 12:09 ` Vlastimil Babka
@ 2024-10-08 3:29 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 3+ messages in thread
From: Leizhen (ThunderTown) @ 2024-10-08 3:29 UTC (permalink / raw)
To: Vlastimil Babka, Christoph Lameter, Pekka Enberg, David Rientjes,
Joonsoo Kim, Andrew Morton, Roman Gushchin, Hyeonggon Yoo,
linux-mm, linux-kernel
On 2024/10/2 20:09, Vlastimil Babka wrote:
> On 8/21/24 05:26, Zhen Lei wrote:
>> The WARN_ON() check in static function create_cache() is done by its only
>> parent kmem_cache_create_usercopy() before calling it.
>> if (...
>> WARN_ON(size < usersize || size - usersize < useroffset))
>> usersize = useroffset = 0;
>> ...
>> s = create_cache(..., size, ..., useroffset, usersize, ...);
>>
>> Therefore, the WARN_ON() check in create_cache() can be safely removed.
>>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>
> Hi, sorry for the late reply.
It doesn't matter, because the compiler will optimize it. It just saves
the reader a little time.
> This code was heavily refactored as of 6.12-rc1. Can you check if it's still
> the case and send updated patch?
It is still there. I'll post v2 later.
> Thanks,
> Vlastimil
>
>> ---
>> mm/slab_common.c | 3 ---
>> 1 file changed, 3 deletions(-)
>>
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index 40b582a014b8f2f..3069c9095523484 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -210,9 +210,6 @@ static struct kmem_cache *create_cache(const char *name,
>> struct kmem_cache *s;
>> int err;
>>
>> - if (WARN_ON(useroffset + usersize > object_size))
>> - useroffset = usersize = 0;
>> -
>> err = -ENOMEM;
>> s = kmem_cache_zalloc(kmem_cache, GFP_KERNEL);
>> if (!s)
>
> .
>
--
Regards,
Zhen Lei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-08 3:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-21 3:26 [PATCH 1/1] mm/slab: remove duplicate check in create_cache() Zhen Lei
2024-10-02 12:09 ` Vlastimil Babka
2024-10-08 3:29 ` Leizhen (ThunderTown)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox