Re: [RFC] [PATCH] cpuset operations causes Badness at mm/slab.c:777 warning

Linus Torvalds
2007-06-01T23:57:44Z

On Fri, 1 Jun 2007, Christoph Lameter wrote:
>
> A too large alloc is >32MB or MAX_ORDER << PAGE_SIZE. A BUG_ON in
> kmalloc_slab() will trigger.

Did we use to BUG_ON()? I think that's wrong. There are ways for users to
potentially ask the kernel to do big allocations, and the correct response
is to say "no can do", not to crash!

> Here is the updated patch. It works fine here:
>
> SLUB: Return BADPTR instead of warning for kmalloc(0)

Looks fine to me. My only comment is that

> - if (!x)
> + if (!x || x == BADPTR)
> return;

This could be micro-optimized (again, non-standard, but it should be
"practically portable") to have just a single test using something like

if ((unsigned long)x <= 16)
return;

but I guess it doesn't really matter much.

I think this is better than what we have now, but I also suspect it's
*not* something we should try this late in the -rc sequence ;)

Andrew, want to take this patch to -mm to see if it triggers anything?

Linus