In article <[EMAIL PROTECTED]> (at Sun, 20 Mar 2005 13:31:43 +0000), Ralph Corderoy <[EMAIL PROTECTED]> says:
> > the short version also have the real bennefits of generating shorter > > and faster code as well as being shorter "on-screen". > > Faster code? I'd have thought avoiding the function call outweighed the > overhead of checking before calling. Modern CPU can run nicely (expecially with register parameters). Even if even matters, we can check inline like this: Signed-off-by: Hideaki YOSHIFUJI <[EMAIL PROTECTED]> ===== include/linux/slab.h 1.40 vs edited ===== --- 1.40/include/linux/slab.h 2005-03-12 05:32:31 +09:00 +++ edited/include/linux/slab.h 2005-03-20 22:47:57 +09:00 @@ -106,8 +106,17 @@ } extern void *kcalloc(size_t, size_t, int); -extern void kfree(const void *); +extern void __kfree(const void *); extern unsigned int ksize(const void *); + +static inline void kfree(const void *p) +{ +#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE + if (!p) + return; +#endif + __kfree(p); +} extern int FASTCALL(kmem_cache_reap(int)); extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr)); ===== mm/slab.c 1.156 vs edited ===== --- 1.156/mm/slab.c 2005-03-10 17:38:21 +09:00 +++ edited/mm/slab.c 2005-03-20 22:42:45 +09:00 @@ -2561,7 +2561,7 @@ EXPORT_SYMBOL(kcalloc); /** - * kfree - free previously allocated memory + * __kfree - free previously allocated memory * @objp: pointer returned by kmalloc. * * Don't free memory not originally allocated by kmalloc() @@ -2572,8 +2572,10 @@ kmem_cache_t *c; unsigned long flags; +#ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE if (!objp) return; +#endif local_irq_save(flags); kfree_debugcheck(objp); c = GET_PAGE_CACHE(virt_to_page(objp)); @@ -2581,7 +2583,7 @@ local_irq_restore(flags); } -EXPORT_SYMBOL(kfree); +EXPORT_SYMBOL(__kfree); #ifdef CONFIG_SMP /** - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/