3

在禁用 CONFIG-MIGRATION 和 CONFIG-COMPACTION 时,Linux 内核是否可以使用一些方法来确定页面分配失败的概率?

除了增加 min_free_bytes 的值和执行之外,是否有一些系统设置可以实现这个目标echo 2 > /proc/sys/vm/drop_caches

这是页面分配失败的示例日志:

Hello: page allocation failure: order:9, mode:0x60c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null)
Hello cpuset=/ mems_allowed=0
Mem-Info:
active_anon:56054 inactive_anon:109301 isolated_anon:0
 active_file:110190 inactive_file:91980 isolated_file:0
 unevictable:9375 dirty:1 writeback:0 unstable:0
 slab_reclaimable:22463 slab_unreclaimable:19122
 mapped:101678 shmem:25642 pagetables:7663 bounce:0
 free:456443 free_pcp:0 free_cma:0
Node 0 active_anon:224216kB inactive_anon:437204kB active_file:440760kB inactive_file:367920kB unevictable:37500kB isolated(anon):0kB isolated(file):0kB mapped:406712kB dirty:4kB writeback:0kB shmem:102568kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
Node 0 DMA free:15892kB min:32kB low:44kB high:56kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15892kB mlocked:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 2804 3762 3762
Node 0 DMA32 free:1798624kB min:5836kB low:8704kB high:11572kB active_anon:188040kB inactive_anon:219400kB active_file:184156kB inactive_file:346776kB unevictable:24900kB writepending:0kB present:3017476kB managed:2927216kB mlocked:24900kB kernel_stack:1712kB pagetables:7564kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 0 958 958
Node 0 Normal free:11256kB min:1992kB low:2972kB high:3952kB active_anon:36084kB inactive_anon:218100kB active_file:257220kB inactive_file:21148kB unevictable:12600kB writepending:4kB present:1048576kB managed:981268kB mlocked:12600kB kernel_stack:5280kB pagetables:23088kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 0 0 0
Node 0 DMA: 3*4kB (U) 3*8kB (U) 1*16kB (U) 1*32kB (U) 3*64kB (U) 0*128kB 1*256kB (U) 0*512kB 1*1024kB (U) 1*2048kB (M) 3*4096kB (M) = 15892kB
Node 0 DMA32: 14912*4kB (UME) 13850*8kB (UME) 9325*16kB (UME) 5961*32kB (UME) 3622*64kB (UME) 2359*128kB (UME) 1128*256kB (UME) 524*512kB (M) 194*1024kB (UM) 0*2048kB 0*4096kB = 1799872kB
Node 0 Normal: 1643*4kB (UME) 71*8kB (UME) 47*16kB (UM) 35*32kB (M) 38*64kB (M) 1*128kB (M) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 11572kB
Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
232507 total pagecache pages
7 pages in swap cache
Swap cache stats: add 1015, delete 1008, find 0/1
Free swap  = 995068kB
Total swap = 999420kB
1020511 pages RAM
0 pages HighMem/MovableOnly
39417 pages reserved
0 pages hwpoisoned
4

1 回答 1

1

您可以使用 vm.min_free_kbytes 来告诉内核在任何情况下都保持这些内存空闲(单位是 kB)。

文件:

min_free_kbytes:

This is used to force the Linux VM to keep a minimum number of kilobytes free. The VM uses this number to compute a watermark[WMARK_MIN] value for each lowmem zone in the system. Each lowmem zone gets a number of reserved free pages based proportionally on its size.

Some minimal amount of memory is needed to satisfy PF_MEMALLOC allocations; if you set this to lower than 1024KB, your system will become subtly broken, and prone to deadlock under high loads.

Setting this too high will OOM your machine instantly.

要永久更改此设置,您可以执行以下操作(降低到 16MB):

echo "vm.min_free_kbytes=16384" >> /etc/sysctl.conf

要玩并测试它一切正常,您可以仅为当前会话更改它:

sysctl -w vm.min_free_kbytes=16384

信息的来源是 kernel.org文档

于 2020-12-31T18:57:19.660 回答