----- Original Message -----
> From: "Greg KH" <g...@kroah.com>
> To: "CAI Qian" <caiq...@redhat.com>
> Cc: stable@vger.kernel.org, "Christoph Lameter" <c...@linux.com>, "Joonsoo 
> Kim" <js1...@gmail.com>, "Paul Hargrove"
> <phhargr...@lbl.gov>
> Sent: Friday, February 1, 2013 8:49:00 PM
> Subject: Re: [PATCH] slub: assign refcount for kmalloc_caches
> 
> On Thu, Jan 24, 2013 at 10:50:09PM -0500, CAI Qian wrote:
> > This is for stable-3.7.y only and this problem has already been
> > solved
> > in mainline through some slab/slub re-work which isn't suitable to
> > backport here. See create_kmalloc_cache() in mm/slab_common.c
> > there.
> > 
> > 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 erroneous 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 destroy 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
> > erroneous situation.
> > 
> > Cc: <stable@vger.kernel.org> # v3.7
> > Cc: Christoph Lameter <c...@linux.com>
> > Reported-by: Paul Hargrove <phhargr...@lbl.gov>
> > Signed-off-by: Joonsoo Kim <js1...@gmail.com>
> > Signed-off-by: CAI Qian <caiq...@redhat.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,
> >     if (kmem_cache_open(s, flags))
> >             goto panic;
> >  
> > +   s->refcount = 1;
> >     list_add(&s->list, &slab_caches);
> >     return s;
> > --
> 
> Your email client dropped the last line of the patch, so I had to
> hand-edit it.
> 
> Ugh, please fix your email client, again...
Ah, thanks for fixing that, Greg. Thought it won't matter for the
last empty line. Oh, well, I'll add that to my check-list.

Regards,
CAI Qian
> 
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe stable" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to