Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756953Ab2BINUv (ORCPT ); Thu, 9 Feb 2012 08:20:51 -0500 Received: from merlin.infradead.org ([205.233.59.134]:60335 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751738Ab2BINUu (ORCPT ); Thu, 9 Feb 2012 08:20:50 -0500 Message-ID: <4F33C7D7.1060801@kernel.dk> Date: Thu, 09 Feb 2012 14:19:19 +0100 From: Jens Axboe MIME-Version: 1.0 To: Pekka Enberg CC: Xi Wang , Andrew Morton , Dan Carpenter , linux-kernel@vger.kernel.org, Christoph Lameter , Matt Mackall , David Rientjes Subject: Re: [PATCH RFC] slab: introduce knalloc/kxnalloc References: <20120207141155.GA16184@elgon.mountain> <4F323388.7040902@kernel.dk> <20120208142513.4db2493a.akpm@linux-foundation.org> <4F33BF05.208@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1267 Lines: 33 On 02/09/2012 02:05 PM, Pekka Enberg wrote: > On Thu, Feb 9, 2012 at 2:41 PM, Xi Wang 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 >> Signed-off-by: Xi Wang > > 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/