Kernel/Compiler bug

Bryan Drewery bdrewery at FreeBSD.org
Thu Oct 2 15:48:52 UTC 2014


On 10/2/2014 9:02 AM, Larry Baird wrote:
>>> Is this something that can be bumped in the tree for GENERIC?
>>
>> The cost of the increased size for kernel stack is significant, even
>> on architectures with ample KVA.  This must not be done just because 
>> some non-default kernel settings cause stack overflow.  If somebody
>> feels himself qualified enough to tune compiler options, it must
>> understand the consequences and do other required adjustments,
>> including kernel stack size tuning.
>>
>> FWIW, there was old reason why -O0 did not worked for the kernel.
>> The cpufunc.h inlines are not provided in non-inline version, and
>> at least gcc at -O0 level sometimes generated the call to nonexisting
>> function, leading to linking failure.  It is curious that clang always
>> inlines at -O0, but it is possible, although unlikely, that kernel
>> source was changed to be immune.
> 
> Overall I aggree with  your comments.  The fact is that I have been using
> -O0 and -O1 on custom kernels for years. It makes using kgdb much more
> effective.  Both optimization levels work for a custom kernel I have for
> FreeBSD 10.0 but do not work for FreeBSD 10.1. I just tried turning off
> optimization for a FreeBSD 10.0 release GENERIC kernel. Same issue.  My
> concern is that opimized kernels may be close to the edge as well.  Since
> people have been runing 10.0 for a while without issue, maybe me concern
> is unfounded.  Anybody have any thoughts on how to instrument a kernel
> build option to check for maximum used stack depth? It would be nice to
> prove that my concern is unfounded.
> 
> Larry
> 

I think at the very least we should have a DISABLE_OPTIMIZATION option
that sets -O0 and increases stack size.

I built a kernel with -O0 some months ago and hit a panic on boot and
did not look into why. It makes sense now though. It would have been
nice if it were more obviously documented or automatically handled.

-- 
Regards,
Bryan Drewery

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20141002/24e684d4/attachment.sig>


More information about the freebsd-hackers mailing list