I followed this method and found that clear_page_erms
generated a significant amount of overhead in the flame graph.
After searching the Internet, I learned that the purpose of this function is to zeroize pages allocated by the kernel during page fault. Considering that my workload is not a multi-tenant cloud environment and there will be no malicious software or attack behavior, can I control the kernel to relax these security features and bypass this reset operation to improve performance?
I am using kernel 5.14, AMD processor, and do not enable huge pages or transparent huge pages.
The relevant kernel parameters are all not set:
#
# Memory initialization
#
CONFIG_INIT_STACK_NONE=y
# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set
# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set
# end of Memory initialization
# end of Kernel hardening options
# end of Security options
No you cannot. While it obviously has security implications, zeroing out pages is not just a security feature, it is a well-defined basic functionality of the kernel. A normal system cannot correctly work without the kernel zeroing out pages before making them available to userspace, as userspace programs will expect them zeroed out.
If you have a custom kernel compiled with CONFIG_MMAP_ALLOW_UNINITIALIZED=y
, then userspace programs can explicitly opt-out of automatic page initialization by passing MAP_UNINITIALIZED
to mmap
, but that's about it.
Regardless though, even having CONFIG_MMAP_ALLOW_UNINITIALIZED=y
isn't really going to do much on any normal system as a whole, since normal programs usually never pass that flag and expect zeroed out memory after mmap
. In the context of a single application though it may help and make a significant difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With