lkml.org 
[lkml]   [2012]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [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



    \
     
     \ /
      Last update: 2012-02-09 14:23    [W:0.022 / U:66.012 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site