mm: some questions about mm/mempool.c

From: Wang, Zhi A
Date: Thu Dec 10 2015 - 08:03:00 EST


Hi Gurus:

Currently we met some allocation failed in mempool_resize() ->

/* Grow the pool */
new_elements = kmalloc_array(new_min_nr, sizeof(*new_elements), // <---- Here
GFP_KERNEL);
if (!new_elements)
return -ENOMEM;

My questions:
1. It looks like in the pool creation path, the allocation of pool->elements is done by

mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn,
mempool_free_t *free_fn, void *pool_data,
gfp_t gfp_mask, int node_id)
{
mempool_t *pool;
pool = kzalloc_node(sizeof(*pool), gfp_mask, node_id);
if (!pool)
return NULL;
pool->elements = kmalloc_node(min_nr * sizeof(void *),
gfp_mask, node_id);

but in the mempool_resize() path, the pool->elements is allocated by kmalloc_array() without NUMA aware. Is it correct?

And I think perhaps a vzalloc here may be more reasonable, as the amount of pool->elements may be large and kmalloc here may fail.

2. Shall we need a mempool_refill() function that can recharge the pool at a certain time?

Thanks,
Zhi.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/