/* this function only sleeps if the free_fn() function sleeps.  */
void mempool_free(void *element, mempool_t *pool)
/* this function only sleeps if the free_fn() function sleeps.  */
void mempool_free(void *element, mempool_t *pool)
{
	unsigned long flags;
	if (unlikely(element == NULL))
		return;
	smp_mb();
	if (pool->curr_nr < pool->min_nr) {
		spin_lock_irqsave(&pool->lock, flags);
		if (pool->curr_nr < pool->min_nr) {
			add_element(pool, element);
			spin_unlock_irqrestore(&pool->lock, flags);
			wake_up(&pool->wait);
			return;
		}
		spin_unlock_irqrestore(&pool->lock, flags);
	}
	pool->free(element, pool->pool_data);
}