All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Tomlinson <tomlins@cam.org>
To: Andrew Morton <akpm@digeo.com>,
	John Levon <movement@marcelothewonderpenguin.com>,
	Manfred Spraul <manfred@colorfullife.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.5.39 kmem_cache bug
Date: Sun, 29 Sep 2002 09:15:52 -0400	[thread overview]
Message-ID: <200209290915.52661.tomlins@cam.org> (raw)
In-Reply-To: <3D961797.B4094994@digeo.com>

On September 28, 2002 04:56 pm, Andrew Morton wrote:
> John Levon wrote:
> > kmem_cache_destroy() is falsely reporting
> > "kmem_cache_destroy: Can't free all objects" in 2.5.39. I have
> > verified my code was freeing all allocated items correctly.
> >
> > Reverting this chunk :
> >
> > -                       list_add(&slabp->list, &cachep->slabs_free);
> > +/*                     list_add(&slabp->list, &cachep->slabs_free);     
> >       */ +                       if
> > (unlikely(list_empty(&cachep->slabs_partial))) +                         
> >      list_add(&slabp->list, &cachep->slabs_partial); +                   
> >    else
> > +                               kmem_slab_destroy(cachep, slabp);
> >
> > and the problem goes away. I haven't investigated why.
>
> Thanks.  That's the code which leaves one empty page available
> for new allocations rather than freeing it immediately.
>
> It's temporary.  Ed, I think we can just do
>
> 	if (list_empty(&cachep->slabs_free))
> 		list_add(&slabp->list, &cachep->slabs_free);
> 	else
> 		kmem_slab_destroy(cachep, slabp);
>
> there?

How about this (untested) instead.  If we can avoid using cachep->slabs_free its 
a good thing.  Why use three lists when two can do the job?  I use a loop to clean 
the partial list since its possible that for some caches we may want to have more
than one slabp of buffer.

Thoughts?
Ed

---------
diff -Nru a/mm/slab.c b/mm/slab.c
--- a/mm/slab.c	Sun Sep 29 09:08:53 2002
+++ b/mm/slab.c	Sun Sep 29 09:08:53 2002
@@ -1036,7 +1036,26 @@
 	list_del(&cachep->next);
 	up(&cache_chain_sem);
 
-	if (__kmem_cache_shrink(cachep)) {
+	/* remove any empty partial pages */
+	spin_lock_irq(&cachep->spinlock);
+	while (!cachep->growing) {
+		struct list_head *p;
+		slab_t *slabp;
+
+		p = cachep->slabs_partial.prev;
+		if (p == &cachep->slabs_partial)
+			break;
+
+		slabp = list_entry(cachep->slabs_partial.prev, slab_t, list);
+		if (slabp->inuse)
+			break;
+
+		list_del(&slabp->list);
+
+	}
+	spin_unlock_irq(&cachep->spinlock);
+
+	if (!list_empty(&cachep->slabs_full) || !list_empty(&cachep->slabs_partial)) {
 		printk(KERN_ERR "kmem_cache_destroy: Can't free all objects %p\n",
 		       cachep);
 		down(&cache_chain_sem);

---------


  parent reply	other threads:[~2002-09-29 13:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-28 20:13 2.5.39 kmem_cache bug John Levon
2002-09-28 20:56 ` Andrew Morton
2002-09-28 21:12   ` Manfred Spraul
2002-09-28 21:23   ` John Levon
2002-09-28 21:35     ` Andrew Morton
2002-09-29 11:45   ` Ed Tomlinson
2002-09-29 12:13     ` Manfred Spraul
2002-09-29 13:15   ` Ed Tomlinson [this message]
2002-09-29 13:52     ` Manfred Spraul
2002-09-29 13:53     ` John Levon
     [not found] ` <200209291137.48483.tomlins@cam.org>
     [not found]   ` <3D972828.6010807@colorfullife.com>
2002-09-30  0:20     ` Ed Tomlinson
2002-09-30  5:55       ` Manfred Spraul
2002-09-30 11:18         ` Ed Tomlinson
2002-09-30 16:33           ` Manfred Spraul

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=200209290915.52661.tomlins@cam.org \
    --to=tomlins@cam.org \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=movement@marcelothewonderpenguin.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.