[lkml]   [2012]   [Feb]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Uninline kcalloc
    On Feb 14, 2012, at 5:08 PM, Christoph Lameter wrote:
    > kcalloc is still there. Certainly useful for legacy purposes. But I'd feel
    > better if I had fine grained control over the size of my allocation rather
    > than rely on the slab allocators to check up on my multiplication.
    > With these patches both is possible. And if you want the check of an
    > allocation that is not zeroed then you can do so because you have a
    > function that will perform the size check for you without calling into the
    > slab allocator.

    In the code you proposed, where calculate_array_size() returns 0
    for overflow, one has to write:

    size_t s = calculate_array_size(n, size);
    if (s)
    p = kmalloc(s, ...);

    This "if" thing is just too verbose --- you need three lines to
    allocate an array.

    We could change calculate_array_size() to return ULONG_MAX or some
    large number with which kmalloc() would fail. Then one would write:

    p = kmalloc(calculate_array_size(n, size), ...);

    This looks better to me. The advantage is that we don't need another
    allocator (and avoid this name picking game). The disadvantage is
    that the semantics of calculate_array_size(), returning ULONG_MAX
    on overflow, sounds sort of strange.

    - xi

     \ /
      Last update: 2012-02-15 20:17    [W:0.033 / U:62.764 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site