lkml.org 
[lkml]   [2007]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: SLUB: Return ZERO_SIZE_PTR for kmalloc(0)
On Fri, Jun 01, 2007 at 09:45:15PM -0700, Christoph Lameter wrote:
> On Fri, 1 Jun 2007, Andrew Morton wrote:
>
> > They are different instances which happen to have the same length (zero).
>
> I guess one could use the slab allocators as a type of reservation
> ticket generator with zero sized objects. Hmmm.... But is that really a
> useful thing to do?

Yes. Old kmalloc(0) gives you a unique pointer that you can use as a
cookie. Which you can then use for all the things you'd use a cookie
for.

But I'd be pretty surprised if anyone was actually doing that. Because
it's easy enough to simply alloc some actual space and stuff some
actual data in it that corresponds to the cookie and use the pointer
to the actual space as the cookie.

On architectures where we have more address space, we could have a
dedicated lala-land for these things.

> > I agree the risk is low, but if something _does_ blow up, it will do so subtly.

Arguable the proposed badptr behavior is correct. It's basically "how many
angels can dance on the head of a pin"? All the returned pointers are
at least 0 bytes away from the previous one.

--
Mathematics is the supreme nostalgia of our time.
-
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/

\
 
 \ /
  Last update: 2007-06-03 18:19    [W:3.049 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site