Re: linux/mm.h breaks memset()

Linus Torvalds (Linus.Torvalds@cs.helsinki.fi)
Thu, 19 Oct 1995 08:08:02 +0200


David Mosberger-Tang: "Re: linux/mm.h breaks memset()" (Oct 18, 18:03):
> >>>>> On Wed, 18 Oct 1995 18:34:27 -0400, "David S. Miller" <davem@caip.rutgers.edu> said:
>
> ewt> [compiling without -O results in undefined reference to
> ewt> __constant_c_memset]
>
> David> Does turning on '-O2' make the problem go away? Gcc looks
> David> like it isn't inlining the functions the linker is
> David> complaining about, and the gcc docs explicitly state that
> David> inlining isn't guarenteed to occur with optimizations off.
>
> Correct, but I still think it's a bug. IMHO, it is OK to require -O
> for kernel compiles, but it should be possible to compile user-level
> programs without -O.

Yup, it's a bug. I guess we should do a "ifndef __KERNEL__" around it
somewhere..

> Also, I'm not convinced that the __constant_c_memset is such a great
> idea---it results in a 64-bit constant being loaded from memory, which
> is potentially much slower on a cache-miss than the few instructions
> that it takes to replicate the byte eight times (except for the
> important special case where the constant is zero, of course).

This is probably something that we should take up with the gcc/alpha
maintainer.. The C code is fine, the and is the "correct" thing to do.
The fact that gcc then compiles it to suboptimal code is a misfortune,
but I'd generally feel that it's better to leave the code as-is and hope
that the compiler improves.

(Actually, I'd like to get the linker optimizing the call sequences away
first. Wasn't somebody working on this? _That_ would make function call
overhead shrink to a small percentage of what it is now)

Linus