svn commit: r333240 - in head/sys: powerpc/powerpc sys

Bruce Evans brde at optusnet.com.au
Sun May 6 07:00:24 UTC 2018


On Sat, 5 May 2018, Mateusz Guzik wrote:

> On Sat, May 5, 2018 at 2:00 PM, Alexey Dokuchaev <danfe at freebsd.org> wrote:
>
>> On Sat, May 05, 2018 at 10:38:29AM +1000, Bruce Evans wrote:
>>> ...
>>> Summary: this change wouldn't have passed my review.  I have used similar
>>> changes for 15-20 years but never made them production quality since
>> there
>>> are too many variations to consider and testing showed insignificant
>>> improvements except for micro-benchmarks.
>>
>> Perhaps Foundation could sponsor your work to make them production quality
>> Bruce.  :-)
>>
>> Seriously though, I'm a bit worried to see these commits happening at the
>> same time correctness of the implementation is still under discussion and
>> disputes.  Shall I expect that after my next -CURRENT update things would
>> suddenly stop working? [1]
>>
>> ./danfe
>>
>> [1] https://bugzilla.redhat.com/show_bug.cgi?id=638477

That was long.

> Nothing of the sort was done here. They had a memcpy function which
> internally behaved like memmove. They changed to behave like mere
> memcpy (i.e. assume non-overlapping buffers). This caused buggy code
> to run into trouble.

Especially since we are only changing the kernel now (but libc has even
sillier optimizations).

> bcopy has memmove semantics and this change keeps that. The only
> difference is that instead of always generating a call, the compiler is
> allowed to perform the copy in place in certain cases. This is precisely
> what happens almost everywhere and it was not happening in the
> kernel because of a giant hammer -fno-builtin flag (added to reduce
> changes the compiler will do stuff the kernel does not want to deal
> with).

No, -fno-builtin is only used by NOTES to get different test coverage
there.  The hammer is -ffreestanding, which is added to avoid the
certainty that gcc-old will do things like strength-reducing printf(9)
into functions like puts(3) that don't exist in the kernel.  In
retrospect, -ffreestanding is not a hammer but is technically correct
and should have been used much earlier.  It is supported by gcc-2.95.4
(aka egcs?), but wasn't used in FreeBSD until gcc-3.  The hosted case
might also miscompile entry points like write() if the compiler
knows too much about POSIX.  The good name of functions like getenv()
was broken by renaming to names like kern_getenv() long after using
-ffreestanding made this unnecessary.  printf(9) remains with its good
name since the churn for renaming it should be too painful for anyone.

Apparently no one except me noticed or cared that -ffreestanding broke
the default of -fbuiltin.  Even NOTES was broken and remains unfixed.
Its -fno-builtin is supposed to reverse the default, but it now echoes
the default.

Bruce


More information about the svn-src-all mailing list