Re: kfree(NULL)

From: Steven Rostedt
Date: Fri Apr 21 2006 - 16:54:14 EST


On Fri, 2006-04-21 at 13:30 -0700, Vernon Mauery wrote:
> On Friday 21 April 2006 12:22, you wrote:

> > What makes you confident that the static inline version gives a time
> > saving?
>
> A static inline wrapper would mean that it wouldn't have to make a function
> call just to check if the pointer is NULL. A simple NULL check is faster
> than a function call and then a simple NULL check. In other words, there
> would be no pushing and popping the stack. In almost all cases, replacing an
> inline function with a non-inline function means a trade-off between speed
> and size.

Andrew Morton just submitted a patch to -mm that fixes the two problem
places that called kfree(NULL) more than it calls kfree(non-NULL).

Besides the places that are now fixed, the inline doesn't save much.
Since most cases kfree(non-NULL) is called, so the NULL is really an
unlikely case. Thus you just increased the size of the kernel, for
virtually no speed savings.

-- Steve


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/