From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx155.postini.com [74.125.245.155]) by kanga.kvack.org (Postfix) with SMTP id 19A606B005D for ; Thu, 10 Jan 2013 23:47:52 -0500 (EST) Received: by mail-qc0-f199.google.com with SMTP id b40so2403055qcq.6 for ; Thu, 10 Jan 2013 20:47:40 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <1356449082-3016-1-git-send-email-js1304@gmail.com> Date: Thu, 10 Jan 2013 20:47:39 -0800 Message-ID: Subject: Re: [PATCH] slub: assign refcount for kmalloc_caches From: Paul Hargrove Content-Type: multipart/alternative; boundary=20cf3071c8aac8813304d2fbfee9 Sender: owner-linux-mm@kvack.org List-ID: To: JoonSoo Kim Cc: Pekka Enberg , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Lameter --20cf3071c8aac8813304d2fbfee9 Content-Type: text/plain; charset=ISO-8859-1 I just had a look at patch-3.7.2-rc1, and this change doesn't appear to have made it in yet. Am I missing something? -Paul On Tue, Dec 25, 2012 at 7:30 AM, JoonSoo Kim wrote: > 2012/12/26 Joonsoo Kim : > > commit cce89f4f6911286500cf7be0363f46c9b0a12ce0('Move kmem_cache > > refcounting to common code') moves some refcount manipulation code to > > common code. Unfortunately, it also removed refcount assignment for > > kmalloc_caches. So, kmalloc_caches's refcount is initially 0. > > This makes errornous situation. > > > > Paul Hargrove report that when he create a 8-byte kmem_cache and > > destory it, he encounter below message. > > 'Objects remaining in kmalloc-8 on kmem_cache_close()' > > > > 8-byte kmem_cache merge with 8-byte kmalloc cache and refcount is > > increased by one. So, resulting refcount is 1. When destory it, it hit > > refcount = 0, then kmem_cache_close() is executed and error message is > > printed. > > > > This patch assign initial refcount 1 to kmalloc_caches, so fix this > > errornous situtation. > > > > Cc: # v3.7 > > Cc: Christoph Lameter > > Reported-by: Paul Hargrove > > Signed-off-by: Joonsoo Kim > > > > diff --git a/mm/slub.c b/mm/slub.c > > index a0d6984..321afab 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -3279,6 +3279,7 @@ static struct kmem_cache *__init > create_kmalloc_cache(const char *name, > > if (kmem_cache_open(s, flags)) > > goto panic; > > > > + s->refcount = 1; > > list_add(&s->list, &slab_caches); > > return s; > > > > -- > > 1.7.9.5 > > > > I missed some explanation. > In v3.8-rc1, this problem is already solved. > See create_kmalloc_cache() in mm/slab_common.c. > So this patch is just for v3.7 stable. > -- Paul H. Hargrove PHHargrove@lbl.gov Future Technologies Group Computer and Data Sciences Department Tel: +1-510-495-2352 Lawrence Berkeley National Laboratory Fax: +1-510-486-6900 --20cf3071c8aac8813304d2fbfee9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I just had a look at=A0patch-3.7.2-rc1, and this change do= esn't appear to have made it in yet.
Am I missing something?

-Paul

On Tue, Dec 25, 2012 at 7:30 AM, JoonSoo Kim <js= 1304@gmail.com> wrote:
2012/12/26 Joonsoo Kim <js1304@gmail= .com>:
> commit cce89f4f6911286500cf7be0363f46c9b0a12ce0('Move kmem_cache > refcounting to common code') moves some refcount manipulation code= to
> common code. Unfortunately, it also removed refcount assignment for > kmalloc_caches. So, kmalloc_caches's refcount is initially 0.
> This makes errornous situation.
>
> Paul Hargrove report that when he create a 8-byte kmem_cache and
> destory it, he encounter below message.
> 'Objects remaining in kmalloc-8 on kmem_cache_close()'
>
> 8-byte kmem_cache merge with 8-byte kmalloc cache and refcount is
> increased by one. So, resulting refcount is 1. When destory it, it hit=
> refcount =3D 0, then kmem_cache_close() is executed and error message = is
> printed.
>
> This patch assign initial refcount 1 to kmalloc_caches, so fix this > errornous situtation.
>
> Cc: <stable@vger.kernel.o= rg> # v3.7
> Cc: Christoph Lameter <cl@linux.com= >
> Reported-by: Paul Hargrove <p= hhargrove@lbl.gov>
> Signed-off-by: Joonsoo Kim <js1= 304@gmail.com>
>
> diff --git a/mm/slub.c b/mm/slub.c
> index a0d6984..321afab 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3279,6 +3279,7 @@ static struct kmem_cache *__init create_kmalloc_= cache(const char *name,
> =A0 =A0 =A0 =A0 if (kmem_cache_open(s, flags))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto panic;
>
> + =A0 =A0 =A0 s->refcount =3D 1;
> =A0 =A0 =A0 =A0 list_add(&s->list, &slab_caches);
> =A0 =A0 =A0 =A0 return s;
>
> --
> 1.7.9.5
>

I missed some explanation.
In v3.8-rc1, this problem is already solved.
See create_kmalloc_cache() in mm/slab_common.c.
So this patch is just for v3.7 stable.



--
Paul H. Hargrove =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0PHHargrove@lbl.gov
Future Technologies Group
Computer and Data Sciences Departm= ent =A0 =A0 Tel: +1-510-495-2352
Lawrence Berkeley National Labor= atory =A0 =A0 Fax: +1-510-486-6900
--20cf3071c8aac8813304d2fbfee9-- -- 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: email@kvack.org