[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070604180519.GF15426@holomorphy.com>
Date: Mon, 4 Jun 2007 11:05:19 -0700
From: William Lee Irwin III <wli@...omorphy.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Alan Cox <alan@...rguk.ukuu.org.uk>,
Pekka Enberg <penberg@...helsinki.fi>,
Christoph Lameter <clameter@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, jeremy@...p.org
Subject: Re: SLUB: Return ZERO_SIZE_PTR for kmalloc(0)
On Mon, Jun 04, 2007 at 10:50:41AM -0700, Linus Torvalds wrote:
> The exception is if you use the memory allocator as a "ID allocator", but
> quite frankly, if you use a size of zero, it's your own damn problem.
> Insane code is not an argument for insane behaviour.
> If people can't be bothered to create a "random ID generator" themselves,
> they had damn well better use "kmalloc(1)" rather than "kmalloc(0)" to get
> a unique cookie. Asking the allocator to do something idiotic because some
> idiot thinks a memory allocator is a cookie allocator is just crazy.
It's not such a great idea in general. Maybe it's a dumb device to cut
down on lines of code for merging or some such.
On Mon, Jun 04, 2007 at 10:50:41AM -0700, Linus Torvalds wrote:
> I can understand that things like user-level libraries have to take crazy
> people into account, but the kernel internal libraries definitely do not.
> (Right now we warn once for zero-sized allocations anyway, and all the
> cases we've found so far are either bugs that would have been found with
> ZERO_ALLOC_PTR or would have been perfectly fine with it, so I don't think
> anybody really _is_ that insane in the kernel)
There are always drivers for that, but I doubt any were sufficiently
creative to pick up on this. At least I've not see any.
-- wli
-
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