min_free_kbytes是内存最安全值的阈值,然后这个值是怎么影响到系统内存回收的呢?
min_free_kbytes
内存域水印值:min_free_kbytes
当不设置的时候:sqrt(16M)=4k 4k*4 = 16k
设置内存水印值的函数是:
6792 /* 6793 * Initialise min_free_kbytes. 6794 * 6795 * For small machines we want it small (128k min). For large machinemis 6796 * we want it large (64MB max). But it is not linear, because network 6797 * bandwidth does not increase linearly with machine size. We use 6798 * 6799 * min_free_kbytes = 4 * sqrt(lowmem_kbytes), for better accuracy: 6800 * min_free_kbytes = sqrt(lowmem_kbytes * 16) 6801 * 6802 * which yields 6803 * 6804 * 16MB: 512k 6805 * 32MB: 724k 6806 * 64MB: 1024k 6807 * 128MB: 1448k 6808 * 256MB: 2048k 6809 * 512MB: 2896k 6810 * 1024MB: 4096k 6811 * 2048MB: 5792k 6812 * 4096MB: 8192k 6813 * 8192MB: 11584k 6814 * 16384MB: 16384k 6815 */ 6
__setup_per_zone_wmarks 中会设置每个内存zone中的min/low/high水印
内存域的这些值都是怎么玩的?
突然间发现了一个函数,可以看到每个内存域的各种内存的信息:show_free_areas竟然是printk,只有在内存很低的时候才打印!
min: 在vmscan时会用到:pfmemalloc_watermark_ok , __zone_watermark_ok这里会判断是不是超过了内存的水位。
./include/linux/mmzone.h:258:#define min_wmark_pages(z) (z->watermark[WMARK_MIN])
low:
high