All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@parallels.com>
To: David Rientjes <rientjes@google.com>
Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org, Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@cs.helsinki.fi>
Subject: Re: [PATCH] slab+slob: dup name string
Date: Tue, 22 May 2012 11:23:48 +0400	[thread overview]
Message-ID: <4FBB3F04.7040207@parallels.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1205212018230.13522@chino.kir.corp.google.com>

On 05/22/2012 07:22 AM, David Rientjes wrote:
> On Mon, 21 May 2012, Glauber Costa wrote:
>
>> diff --git a/mm/slab.c b/mm/slab.c
>> index e901a36..cabd217 100644
>> --- a/mm/slab.c
>> +++ b/mm/slab.c
>> @@ -2118,6 +2118,7 @@ static void __kmem_cache_destroy(struct kmem_cache *cachep)
>>   			kfree(l3);
>>   		}
>>   	}
>> +	kfree(cachep->name);
>>   	kmem_cache_free(&cache_cache, cachep);
>>   }
>>
>> @@ -2526,9 +2527,14 @@ kmem_cache_create (const char *name, size_t size, size_t align,
>>   		BUG_ON(ZERO_OR_NULL_PTR(cachep->slabp_cache));
>>   	}
>>   	cachep->ctor = ctor;
>> -	cachep->name = name;
>>
>> -	if (setup_cpu_cache(cachep, gfp)) {
>> +	/* Can't do strdup while kmalloc is not up */
>> +	if (g_cpucache_up>  EARLY)
>> +		cachep->name = kstrdup(name, GFP_KERNEL);
>> +	else
>> +		cachep->name = name;
>> +
>> +	if (!cachep->name || setup_cpu_cache(cachep, gfp)) {
>>   		__kmem_cache_destroy(cachep);
>>   		cachep = NULL;
>>   		goto oops;
>
> This doesn't work if you kmem_cache_destroy() a cache that was created
> when g_cpucache_cpu<= EARLY, the kfree() will explode.  That never
> happens for any existing cache created in kmem_cache_init(), but this
> would introduce the first roadblock in doing so.  So you'll need some
> magic to determine whether the cache was allocated statically and suppress
> the kfree() in such a case.

Suggestions on how to do it other than using a flag?

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Glauber Costa <glommer@parallels.com>
To: David Rientjes <rientjes@google.com>
Cc: <linux-kernel@vger.kernel.org>, <cgroups@vger.kernel.org>,
	<linux-mm@kvack.org>, Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@cs.helsinki.fi>
Subject: Re: [PATCH] slab+slob: dup name string
Date: Tue, 22 May 2012 11:23:48 +0400	[thread overview]
Message-ID: <4FBB3F04.7040207@parallels.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1205212018230.13522@chino.kir.corp.google.com>

On 05/22/2012 07:22 AM, David Rientjes wrote:
> On Mon, 21 May 2012, Glauber Costa wrote:
>
>> diff --git a/mm/slab.c b/mm/slab.c
>> index e901a36..cabd217 100644
>> --- a/mm/slab.c
>> +++ b/mm/slab.c
>> @@ -2118,6 +2118,7 @@ static void __kmem_cache_destroy(struct kmem_cache *cachep)
>>   			kfree(l3);
>>   		}
>>   	}
>> +	kfree(cachep->name);
>>   	kmem_cache_free(&cache_cache, cachep);
>>   }
>>
>> @@ -2526,9 +2527,14 @@ kmem_cache_create (const char *name, size_t size, size_t align,
>>   		BUG_ON(ZERO_OR_NULL_PTR(cachep->slabp_cache));
>>   	}
>>   	cachep->ctor = ctor;
>> -	cachep->name = name;
>>
>> -	if (setup_cpu_cache(cachep, gfp)) {
>> +	/* Can't do strdup while kmalloc is not up */
>> +	if (g_cpucache_up>  EARLY)
>> +		cachep->name = kstrdup(name, GFP_KERNEL);
>> +	else
>> +		cachep->name = name;
>> +
>> +	if (!cachep->name || setup_cpu_cache(cachep, gfp)) {
>>   		__kmem_cache_destroy(cachep);
>>   		cachep = NULL;
>>   		goto oops;
>
> This doesn't work if you kmem_cache_destroy() a cache that was created
> when g_cpucache_cpu<= EARLY, the kfree() will explode.  That never
> happens for any existing cache created in kmem_cache_init(), but this
> would introduce the first roadblock in doing so.  So you'll need some
> magic to determine whether the cache was allocated statically and suppress
> the kfree() in such a case.

Suggestions on how to do it other than using a flag?


  reply	other threads:[~2012-05-22  7:23 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 15:18 [PATCH] slab+slob: dup name string Glauber Costa
2012-05-21 15:18 ` Glauber Costa
     [not found] ` <1337613539-29108-1-git-send-email-glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-21 15:35   ` Christoph Lameter
2012-05-21 15:35     ` Christoph Lameter
2012-05-21 15:35     ` Christoph Lameter
2012-05-22  3:22 ` David Rientjes
2012-05-22  3:22   ` David Rientjes
2012-05-22  7:23   ` Glauber Costa [this message]
2012-05-22  7:23     ` Glauber Costa
2012-05-22  9:45   ` Glauber Costa
2012-05-22  9:45     ` Glauber Costa
2012-05-22 13:56   ` Christoph Lameter
2012-05-22 13:56     ` Christoph Lameter
2012-05-22 15:19     ` Glauber Costa
2012-05-22 15:19       ` Glauber Costa
     [not found]       ` <4FBBAE95.6080608-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-22 17:16         ` Christoph Lameter
2012-05-22 17:16           ` Christoph Lameter
2012-05-22 17:16           ` Christoph Lameter
2012-05-22 22:31           ` David Rientjes
2012-05-22 22:31             ` David Rientjes
2012-05-23 11:46             ` James Bottomley
2012-05-23 11:46               ` James Bottomley
2012-05-23 12:08               ` Glauber Costa
2012-05-23 12:08                 ` Glauber Costa
     [not found]                 ` <4FBCD328.6060406-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-23 12:24                   ` James Bottomley
2012-05-23 12:24                     ` James Bottomley
2012-05-23 12:24                     ` James Bottomley
2012-05-23 14:48                     ` Christoph Lameter
2012-05-23 14:48                       ` Christoph Lameter
     [not found]                       ` <alpine.DEB.2.00.1205230947490.30940-sBS69tsa9Uj/9pzu0YdTqQ@public.gmane.org>
2012-05-23 14:50                         ` Glauber Costa
2012-05-23 14:50                           ` Glauber Costa
2012-05-23 14:50                           ` Glauber Costa
     [not found]                           ` <4FBCF951.3040105-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-24  0:18                             ` Dave Chinner
2012-05-24  0:18                               ` Dave Chinner
2012-05-24  0:18                               ` Dave Chinner
2012-05-24 12:06                               ` Glauber Costa
2012-05-24 12:06                                 ` Glauber Costa
2012-05-23 15:01                       ` Glauber Costa
2012-05-23 15:01                         ` Glauber Costa
     [not found]                         ` <4FBCFBE0.2080803-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-23 15:17                           ` Christoph Lameter
2012-05-23 15:17                             ` Christoph Lameter
2012-05-23 15:17                             ` Christoph Lameter
     [not found]                             ` <alpine.DEB.2.00.1205231012330.30940-sBS69tsa9Uj/9pzu0YdTqQ@public.gmane.org>
2012-05-23 15:15                               ` Glauber Costa
2012-05-23 15:15                                 ` Glauber Costa
2012-05-23 15:15                                 ` Glauber Costa
2012-05-23 13:48             ` Christoph Lameter
2012-05-23 13:48               ` Christoph Lameter

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=4FBB3F04.7040207@parallels.com \
    --to=glommer@parallels.com \
    --cc=cgroups@vger.kernel.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=rientjes@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.