On Thu, 20 Jan 2000, Tigran Aivazian wrote:
> a common code sequence of calling kmalloc() and then memset(p,0,size) can
> be optimized into a single exported interface called kzalloc() like it is
> done on other systems (kmem_zalloc()). This is a simple and harmless
> optimization - please consider it:
i'd suggest to make it an inline function, because affected code often (in
most cases) goes like this:
x = kmalloc(size);
memset(x,0,size);
x->a = 1;
x->b = 2;
x->c = 3;
which then again is (free to be) optimized by GCC to skip the zeroing for
all initialized variables. Or something like:
if (size > TRESHOLD)
__kzalloc(size);
else {
x = kmalloc(size);
memset(size);
}
because smaller structures are more likely to be initialized right after
allocation. One of the branches is always optimized away at compile time.
-- mingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:25 EST