[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4F33C7D7.1060801@kernel.dk>
Date: Thu, 09 Feb 2012 14:19:19 +0100
From: Jens Axboe <axboe@...nel.dk>
To: Pekka Enberg <penberg@...nel.org>
CC: Xi Wang <xi.wang@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dan Carpenter <dan.carpenter@...cle.com>,
linux-kernel@...r.kernel.org, Christoph Lameter <cl@...ux.com>,
Matt Mackall <mpm@...enic.com>,
David Rientjes <rientjes@...gle.com>
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@...il.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@...ux-foundation.org>
>> Signed-off-by: Xi Wang <xi.wang@...il.com>
>
> Are there really enough potential users to justify adding both?
Agree, lets not overdesign. kmalloc_array() sounds good to me, fwiw.
--
Jens Axboe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists