[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070319220413.GA27302@lazybastard.org>
Date: Mon, 19 Mar 2007 23:04:14 +0100
From: Jörn Engel <joern@...ybastard.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Matt Mackall <mpm@...enic.com>,
Christoph Lameter <clameter@....com>,
Pekka J Enberg <penberg@...helsinki.fi>, ast@...dv.de,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] slab: deal with NULL pointers passed to kmem_cache_free
On Mon, 19 March 2007 14:10:38 -0700, Andrew Morton wrote:
>
> Would prefer to do:
>
> static inline void kmem_cache_free_if_not_null(struct kmem_cache *cachep,
> void *objp)
> {
> if (objp)
> kmem_cache_free(cachep, objp);
> }
>
> so that we don't add extra overhead to all the thousands of existing,
> well-behaved callsites.
In principle, this would work. But two things need changing, imho:
1. Don't inline the function. kmem_cache_free() has only about 34 NULL
callers, if my grep is reliable, so this case is arguable. But in
general, out-of-line functions are better than many extra
conditionals pulled in through the inline one.
2. Switch the names. According to Rusty's benchmark, the easiest way to
use and interface should be the correct one. Every new driver
written by a rookie will call kmem_cache_free(), simply because the
name seems simpler.
void kmem_cache_free_fast(struct kmem_cache *cachep, void *objp)
{
/* old kmem_cache_free() */
}
void kmem_cache_free(struct kmem_cache *cachep, void *objp)
{
if (likely(objp))
kmem_cache_free_fast(cachep, objp);
}
Jörn
--
Correctness comes second.
Features come third.
Performance comes last.
Maintainability is easily forgotten.
-
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