On Mon, Jun 28, 2021 at 10:23:47AM -0700, Thiago Macieira wrote: > On Monday, 28 June 2021 10:11:16 PDT Peter Zijlstra wrote: > > > Consequence: CPU feature checking is done *very* early, often before > > > main(). > > For the linker based ones, yes. IIRC the ifunc() attribute is > > particularly useful here. > > Exactly. ifunc was designed for this exact purpose. And hence the fact that > CPUID initialisation will be done very, very early. > > Anyway, if the AMX state is a sticky "set once per process", it's likely going > to get set early for every process that *may* use AMX. And this is assuming we > do the library right and only set it if has AMX code at all, instead of all > the time. This, AFAIU. If the ifunc() resolver finds we haz AMX it can do the prctl() and on success pick the AMX routine. Assuming of course, that if a program links with a library that supports AMX, it will actually end up using it.