Re: [PATCH RFC 1/2] scatterlist: add mempool based chained SG alloc/free api

From: Ming Lin
Date: Mon Mar 21 2016 - 02:55:34 EST


On Wed, 2016-03-16 at 09:23 +0100, Christoph Hellwig wrote:
>
> We can defintively kill this one.

We want to support different size of pools.
How can we kill this one?

Or did you mean we just create a single pool with size SG_CHUNK_SIZE?

>
> > +static __init int sg_mempool_init(void)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < SG_MEMPOOL_NR; i++) {
> > + struct sg_mempool *sgp = sg_pools + i;
> > + int size = sgp->size * sizeof(struct scatterlist);
> > +
> > + sgp->slab = kmem_cache_create(sgp->name, size, 0,
> > + SLAB_HWCACHE_ALIGN, NULL);
>
> Having these mempoools around in every kernel will make some embedded
> developers rather unhappy.ÂÂWe could either not create them at
> runtime, which would require either a check in the fast path, or
> an init call in every driver, or just move the functions you
> added into a separe file, which will be compiled only based on a
> Kconfig
> symbol, and could even be potentially modular.ÂÂI think that
> second option might be easier.

I created lib/sg_pool.c with CONFIG_SG_POOL.