On 2/15/24 17:14, Adrian Vovk wrote:
...
Typical distro configuration is:
$ sudo dmesg |grep auto-init
[ 0.018882] mem auto-init: stack:all(zero), heap alloc:on, heap
free:off
$
So this kernel zeroes all stack memory, page and heap memory on
allocation, and does nothing on free...
I see. Thank you for all the information.
So ~5% performance penalty isn't trivial, especially to protect against
And it's more like 600% or more, on some systems. For example, imagine if
someone had a memory-coherent system that included both CPUs and GPUs,
each with their own NUMA memory nodes. The GPU has fast DMA engines that
can zero a lot of that memory very very quickly, order(s) of magnitude
faster than the CPU can clear it.
So, the GPU driver is going to clear that memory before handing it
out to user space, and all is well so far.
But init_on_alloc forces the CPU to clear the memory first, because of
the belief here that this is somehow required in order to get defense
in depth. (True, if you can convince yourself that some parts of the
kernel are in a different trust boundary than others. I lack faith
here and am not a believer in such make belief boundaries.)
Anyway, this situation has wasted much time, and at this point, I
wish I could delete the whole init_on_alloc feature.
Just in case you wanted an alt perspective. :)
thanks,
--
John Hubbard
NVIDIA