Re:[newbie alert] How does FreeBSD support hardware?

From: mayuresh@kathe.in <mayuresh_at_kathe.in>
Date: Tue, 30 Nov 2021 06:10:09 UTC
On Tuesday, November 30, 2021 11:08 AM IST, Steve O'Hara-Smith <steve@sohara.org> wrote: 
 
> On Tue, 30 Nov 2021 05:19:35 +0100
> "mayuresh@kathe.in" <mayuresh@kathe.in> wrote:
> 
> > I am confused about how FreeBSD supports every new generation of
> > processors, e.g. from Intel. I guess, FreeBSD uses GNU "gas" to which
> > Intel actively contributes code to keep that assembler updated for every
> > iteration (model) of Intel's processors. So when the kernel and userland
> > are built, Clang/LLVM uses "gas" to generate binaries to support newer
> > instructions as provided by the processor. But, what is the magic within
> > FreeBSD that makes the whole system be aware of changed instructions such
> 
> 	The magic (to the extent that it is used) is in the compiler which
> can generate code optimised with newer instructions. However the FreeBSD
> binaries you download will be built to a lowest common denominator and for
> the most part only use those instructions that are on all supported
> processors.

So the developers of Clang/LLVM too have to keep in step with enhancements introduced by processor vendors, right? That would be in addition to GNU "gas" being updated.

Does any part of FreeBSD use "ifunc" (https://jasoncc.github.io/gnu_gcc_glibc/gnu-ifunc.html) to provide multiple highly optimized processor model specific functionality?
If I'm not wrong, it might be handy for the crypto functions which keep getting enhanced with almost every iteration of processors brought out by Intel.


> 	Heavily optimising the OS code is usually a waste of time because
> the system should be spending most of the time running application code and
> much of the time the system performance is dominated by I/O not CPU so even
> optimising application code to the CPU is often not worthwhile. Only when
> the code is CPU bound (video transcoding, crypto-currency mining ...) does
> it make a lot of difference.

Would a library like "libcmb" (https://github.com/FrauBSD/pkgcenter/tree/master/depend/libcmb) written by Ms. Devin Teske of FreeBSD, be an ideal candidate for optimizations tailored per processor iteration?

Thanks,

~Mayuresh