* [PATCH] slab: add a check for the first kmem_cache not to be destroyed
@ 2017-01-16 7:04 Kyunghwan Kwon
2017-01-17 1:33 ` Joonsoo Kim
0 siblings, 1 reply; 5+ messages in thread
From: Kyunghwan Kwon @ 2017-01-16 7:04 UTC (permalink / raw)
To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
Andrew Morton
Cc: linux-mm, linux-kernel, Kyunghwan Kwon
The first kmem_cache created at booting up is supposed neither mergeable
nor destroyable but was possible to destroy. So prevent it.
Signed-off-by: Kyunghwan Kwon <kwon@toanyone.net>
---
mm/slab_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 1dfc209..2d30ace 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -744,7 +744,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
bool need_rcu_barrier = false;
int err;
- if (unlikely(!s))
+ if (unlikely(!s) || s->refcount == -1)
return;
get_online_cpus();
--
2.9.3 (Apple Git-75)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add a check for the first kmem_cache not to be destroyed
2017-01-16 7:04 [PATCH] slab: add a check for the first kmem_cache not to be destroyed Kyunghwan Kwon
@ 2017-01-17 1:33 ` Joonsoo Kim
2017-01-17 3:32 ` kwon
0 siblings, 1 reply; 5+ messages in thread
From: Joonsoo Kim @ 2017-01-17 1:33 UTC (permalink / raw)
To: Kyunghwan Kwon
Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Andrew Morton,
linux-mm, linux-kernel
On Mon, Jan 16, 2017 at 04:04:59PM +0900, Kyunghwan Kwon wrote:
> The first kmem_cache created at booting up is supposed neither mergeable
> nor destroyable but was possible to destroy. So prevent it.
>
> Signed-off-by: Kyunghwan Kwon <kwon@toanyone.net>
> ---
> mm/slab_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 1dfc209..2d30ace 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -744,7 +744,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
> bool need_rcu_barrier = false;
> int err;
>
> - if (unlikely(!s))
> + if (unlikely(!s) || s->refcount == -1)
> return;
Hello, Kyunghwan.
Few lines below, s->refcount is checked.
if (s->refcount)
goto unlock;
Am I missing something?
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add a check for the first kmem_cache not to be destroyed
2017-01-17 1:33 ` Joonsoo Kim
@ 2017-01-17 3:32 ` kwon
2017-01-17 22:54 ` David Rientjes
0 siblings, 1 reply; 5+ messages in thread
From: kwon @ 2017-01-17 3:32 UTC (permalink / raw)
To: Joonsoo Kim
Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Andrew Morton,
linux-mm, linux-kernel
> On Jan 17, 2017, at 10:33 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
>
> On Mon, Jan 16, 2017 at 04:04:59PM +0900, Kyunghwan Kwon wrote:
>> The first kmem_cache created at booting up is supposed neither mergeable
>> nor destroyable but was possible to destroy. So prevent it.
>>
>> Signed-off-by: Kyunghwan Kwon <kwon@toanyone.net>
>> ---
>> mm/slab_common.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index 1dfc209..2d30ace 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -744,7 +744,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
>> bool need_rcu_barrier = false;
>> int err;
>>
>> - if (unlikely(!s))
>> + if (unlikely(!s) || s->refcount == -1)
>> return;
>
> Hello, Kyunghwan.
>
> Few lines below, s->refcount is checked.
>
> if (s->refcount)
> goto unlock;
>
> Am I missing something?
>
> Thanks.
Hello, Joonsoo.
In case it is called the number of int size times. refcount would finally reach
to 0 since decreased every time the function called.
When refcount is -1, the count will not change in the patch so no lock would be
need to be taken prior, I believe.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add a check for the first kmem_cache not to be destroyed
2017-01-17 3:32 ` kwon
@ 2017-01-17 22:54 ` David Rientjes
2017-01-18 2:36 ` kwon
0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2017-01-17 22:54 UTC (permalink / raw)
To: kwon
Cc: Joonsoo Kim, Christoph Lameter, Pekka Enberg, Andrew Morton,
linux-mm, linux-kernel
On Tue, 17 Jan 2017, kwon wrote:
> >> diff --git a/mm/slab_common.c b/mm/slab_common.c
> >> index 1dfc209..2d30ace 100644
> >> --- a/mm/slab_common.c
> >> +++ b/mm/slab_common.c
> >> @@ -744,7 +744,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
> >> bool need_rcu_barrier = false;
> >> int err;
> >>
> >> - if (unlikely(!s))
> >> + if (unlikely(!s) || s->refcount == -1)
> >> return;
> >
> > Hello, Kyunghwan.
> >
> > Few lines below, s->refcount is checked.
> >
> > if (s->refcount)
> > goto unlock;
> >
> > Am I missing something?
> >
> > Thanks.
>
> Hello, Joonsoo.
>
> In case it is called the number of int size times. refcount would finally reach
> to 0 since decreased every time the function called.
>
The only thing using create_boot_cache() should be the slab implementation
itself, so I don't think we need to protect ourselves from doing something
like kmem_cache_destroy(kmem_cache) or
kmem_cache_destroy(kmem_cache_node) even a single time.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] slab: add a check for the first kmem_cache not to be destroyed
2017-01-17 22:54 ` David Rientjes
@ 2017-01-18 2:36 ` kwon
0 siblings, 0 replies; 5+ messages in thread
From: kwon @ 2017-01-18 2:36 UTC (permalink / raw)
To: David Rientjes
Cc: Joonsoo Kim, Christoph Lameter, Pekka Enberg, Andrew Morton,
linux-mm, linux-kernel
> On Jan 18, 2017, at 7:54 AM, David Rientjes <rientjes@google.com> wrote:
>
> On Tue, 17 Jan 2017, kwon wrote:
>
>>>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>>>> index 1dfc209..2d30ace 100644
>>>> --- a/mm/slab_common.c
>>>> +++ b/mm/slab_common.c
>>>> @@ -744,7 +744,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
>>>> bool need_rcu_barrier = false;
>>>> int err;
>>>>
>>>> - if (unlikely(!s))
>>>> + if (unlikely(!s) || s->refcount == -1)
>>>> return;
>>>
>>> Hello, Kyunghwan.
>>>
>>> Few lines below, s->refcount is checked.
>>>
>>> if (s->refcount)
>>> goto unlock;
>>>
>>> Am I missing something?
>>>
>>> Thanks.
>>
>> Hello, Joonsoo.
>>
>> In case it is called the number of int size times. refcount would finally reach
>> to 0 since decreased every time the function called.
>>
>
> The only thing using create_boot_cache() should be the slab implementation
> itself, so I don't think we need to protect ourselves from doing something
> like kmem_cache_destroy(kmem_cache) or
> kmem_cache_destroy(kmem_cache_node) even a single time.
Agreed. I was aware of that though, I thought it would make its logic firm not
giving performance disadvantages. Sorry for distraction.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-18 2:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 7:04 [PATCH] slab: add a check for the first kmem_cache not to be destroyed Kyunghwan Kwon
2017-01-17 1:33 ` Joonsoo Kim
2017-01-17 3:32 ` kwon
2017-01-17 22:54 ` David Rientjes
2017-01-18 2:36 ` kwon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).