接前一篇文章:Linux内核中内存管理相关配置项的详细解析7
十一、Enable KSM for page merging
对应配置变量为:CONFIG_KSM。
此项只有选中和不选中两种状态,默认为选中。
内核源码详细解释为:
Enable Kernel Samepage Merging: KSM periodically scans those areas
of an application's address space that an app has advised may be
mergeable. When it finds pages of identical content, it replaces
the many instances by a single page with that content, so
saving memory until one or another app needs to modify the content.
Recommended for use with KVM, or with other duplicative applications.
See Documentation/mm/ksm.rst for more information: KSM is inactive
until a program has madvised that an area is MADV_MERGEABLE, and
root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
使能内核Samepage合并:KSM周期性地扫描应用程序地址空间中应用程序建议可以合并的那些区域。当发现内容相同的页面时,它(KSM)会用该内容的单个页面替换许多实例,从而节省内存,直到一个或另一个应用程序需要修改内容为止。建议与KVM或其它重复应用程序一起使用。
有关更多信息,请参阅文档/mm/ksm.rst:KSM处于inactive状态,直到程序madvice某个区域是MADV_MERGEABLE的,并且root用户已经设置/sys/kernel/mm/ksm/run为1(CONFIG_SYSFS设置的情况下)。
十二、Low address space to protect from user allocation
对应配置变量为:CONFIG_DEFAULT_MMAP_MIN_ADDR。
此项为数值项而非选择项。默认推荐值为65536。
内核源码详细解释为:
This is the portion of low virtual memory which should be protected
from userspace allocation. Keeping a user from writing to low pages
can help reduce the impact of kernel NULL pointer bugs.
For most ia64, ppc64 and x86 users with lots of address space
a value of 65536 is reasonable and should cause no problems.
On arm and other archs it should not be higher than 32768.
Programs which use vm86 functionality or have some need to map
this low address space will need CAP_SYS_RAWIO or disable this
protection by setting the value to 0.
This value can be changed after boot using the
/proc/sys/vm/mmap_min_addr tunable.
这是低端虚拟内存的一部分,应该保护它不受用户空间分配的影响。防止用户向低页写入有助于减少内核NULL指针错误的影响。
对于大多数拥有大量地址空间的ia64、ppc64和x86用户来说,65536的值是合理的,应该不会造成任何问题。在arm及其它架构中其应该不高于32768。使用vm86功能或需要映射此低地址空间的程序将需要CAP_SYS_RAWIO,或者通过将值设置为0来禁用此保护。
此值可以在引导(启动)后使用/proc/sys/vm/mmap_min_addr进行调整。