All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@digeo.com>
To: David Brownell <david-b@pacbell.net>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: patch -- mempool buglet (?)
Date: Tue, 31 Dec 2002 11:27:25 -0800	[thread overview]
Message-ID: <3E11EF9D.93EBB5F4@digeo.com> (raw)
In-Reply-To: 3E11DF87.4090901@pacbell.net

David Brownell wrote:
> 
> I noticed this when reading the mempool code ... looked
> wrong to me, it was using kfree() not the de-allocator
> matching the allocation it just made.  This is on a fault
> path that likely doesn't get much use.
> 
> Compiles, untested, "looks right".
> 

Yup, thanks.  We actually need to drop the pool->lock
around the pool->free invokation to be consistent.  I'll
send in a fix.


--- 25/mm/mempool.c~mempool_resize-fix	Tue Dec 31 11:12:39 2002
+++ 25-akpm/mm/mempool.c	Tue Dec 31 11:23:15 2002
@@ -87,7 +87,13 @@ mempool_t * mempool_create(int min_nr, m
 	}
 	return pool;
 }
+EXPORT_SYMBOL(mempool_create);
 
+/*
+ * mempool_resize is disabled for now, because it has no callers.  Feel free
+ * to turn it back on if needed.
+ */
+#if 0
 /**
  * mempool_resize - resize an existing memory pool
  * @pool:       pointer to the memory pool which was allocated via
@@ -143,16 +149,21 @@ int mempool_resize(mempool_t *pool, int 
 		if (!element)
 			goto out;
 		spin_lock_irqsave(&pool->lock, flags);
-		if (pool->curr_nr < pool->min_nr)
+		if (pool->curr_nr < pool->min_nr) {
 			add_element(pool, element);
-		else
-			kfree(element);		/* Raced */
+		} else {
+			spin_unlock_irqrestore(&pool->lock, flags);
+			pool->free(element, pool->pool_data);	/* Raced */
+			spin_lock_irqsave(&pool->lock, flags);
+		}
 	}
 out_unlock:
 	spin_unlock_irqrestore(&pool->lock, flags);
 out:
 	return 0;
 }
+EXPORT_SYMBOL(mempool_resize);
+#endif
 
 /**
  * mempool_destroy - deallocate a memory pool
@@ -169,6 +180,7 @@ void mempool_destroy(mempool_t *pool)
 		BUG();		/* There were outstanding elements */
 	free_pool(pool);
 }
+EXPORT_SYMBOL(mempool_destroy);
 
 /**
  * mempool_alloc - allocate an element from a specific memory pool
@@ -230,6 +242,7 @@ repeat_alloc:
 
 	goto repeat_alloc;
 }
+EXPORT_SYMBOL(mempool_alloc);
 
 /**
  * mempool_free - return an element to the pool.
@@ -255,6 +268,7 @@ void mempool_free(void *element, mempool
 	}
 	pool->free(element, pool->pool_data);
 }
+EXPORT_SYMBOL(mempool_free);
 
 /*
  * A commonly used alloc and free fn.
@@ -264,17 +278,11 @@ void *mempool_alloc_slab(int gfp_mask, v
 	kmem_cache_t *mem = (kmem_cache_t *) pool_data;
 	return kmem_cache_alloc(mem, gfp_mask);
 }
+EXPORT_SYMBOL(mempool_alloc_slab);
 
 void mempool_free_slab(void *element, void *pool_data)
 {
 	kmem_cache_t *mem = (kmem_cache_t *) pool_data;
 	kmem_cache_free(mem, element);
 }
-
-EXPORT_SYMBOL(mempool_create);
-EXPORT_SYMBOL(mempool_resize);
-EXPORT_SYMBOL(mempool_destroy);
-EXPORT_SYMBOL(mempool_alloc);
-EXPORT_SYMBOL(mempool_free);
-EXPORT_SYMBOL(mempool_alloc_slab);
 EXPORT_SYMBOL(mempool_free_slab);

_

      reply	other threads:[~2002-12-31 19:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-31 18:18 patch -- mempool buglet (?) David Brownell
2002-12-31 19:27 ` Andrew Morton [this message]

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=3E11EF9D.93EBB5F4@digeo.com \
    --to=akpm@digeo.com \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.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.