Messages in this thread | | | From | chi wu <> | Date | Wed, 15 Jun 2022 20:41:34 +0800 | Subject | Re: [PATCH] lib/genalloc: Set chunk size to real size which gen_pool managed. |
| |
Andrew Morton <akpm@linux-foundation.org> 于2022年6月15日周三 01:53写道: > > On Tue, 14 Jun 2022 13:20:08 +0800 chi wu <wuchi.zero@gmail.com> wrote: > > > > If we're going to do this then gen_pool_add_owner() no longer needs its > > > `size' argument. > > > > > > > > Sorry, What point did I misunderstand? > > I mean we can now do this: > > --- a/lib/genalloc.c~lib-genalloc-set-chunk-size-to-real-size-which-gen_pool-managed-fix > +++ a/lib/genalloc.c > @@ -181,13 +181,14 @@ EXPORT_SYMBOL(gen_pool_create); > * > * Returns 0 on success or a -ve errno on failure. > */ > -int gen_pool_add_owner(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, > - size_t size, int nid, void *owner) > +int gen_pool_add_owner(struct gen_pool *pool, unsigned long virt, > + phys_addr_t phys, int nid, void *owner) > { > struct gen_pool_chunk *chunk; > unsigned long nbits = size >> pool->min_alloc_order; [1]
The arg @size is in bytes of the memory chunk to add to pool, we really need that, [1] here we get nbits by size. [2] later we will alloc bitmap by nbits... If we remove the arg @size, we will have no way to get the size of memory which we will manage.
> unsigned long nbytes = sizeof(struct gen_pool_chunk) + > BITS_TO_LONGS(nbits) * sizeof(long); [1] > + size_t size; > > chunk = vzalloc_node(nbytes, nid); > if (unlikely(chunk == NULL)) > _ >
Thanks for Andrew's time
| |