Messages in this thread | | | Date | Thu, 09 Feb 2012 14:19:19 +0100 | From | Jens Axboe <> | Subject | Re: [PATCH RFC] slab: introduce knalloc/kxnalloc |
| |
On 02/09/2012 02:05 PM, Pekka Enberg wrote: > On Thu, Feb 9, 2012 at 2:41 PM, Xi Wang <xi.wang@gmail.com> wrote: >> This patch introduces knalloc/kxnalloc wrappers that perform integer >> overflow checks without zeroing the memory. >> >> knalloc(n, size, flags) is the non-zeroing version of kcalloc(), >> which allocates n * size bytes. >> >> kxnalloc(xsize, n, size, flags) allocates xsize + n * size bytes. >> It is useful to allocate a structure ending with a zero-length array, >> which is a commonly used pattern. For example, in posix_acl_alloc() >> to allocate a posix_acl object one could call >> >> kxnalloc(sizeof(struct posix_acl), >> count, sizeof(struct posix_acl_entry), flags); >> >> to avoid overflowing the allocation size. >> >> Suggested-by: Andrew Morton <akpm@linux-foundation.org> >> Signed-off-by: Xi Wang <xi.wang@gmail.com> > > Are there really enough potential users to justify adding both?
Agree, lets not overdesign. kmalloc_array() sounds good to me, fwiw.
-- Jens Axboe
| |