如何减少 Linux 中不可移动和不可清除的页面

如何减少 Linux 中不可移动和不可清除的页面

我们有基于 BBB 的定制主板,它有 256MB RAM 和 4GB eMMC,我们发现它存在碎片问题。
作为分析的一部分,我想了解页面缓存(或缓冲区缓存)中的页面unmovable( from /proc/pagetypeinfo)是什么?unevictable(from /proc/zoneinfo)

#  cat /proc/pagetypeinfo ; cat /proc/buddyinfo 
Page block order: 11
Pages per block:  2048

Free pages count per migrate type at order       0      1      2      3      4      5      6      7      8      9     10     11 
Node    0, zone   Normal, type    Unmovable    291    254    213    171    146     98     68     41     23     16      6      0 
Node    0, zone   Normal, type  Reclaimable      0      0      2      2      1      0      1      1      1      1      1      0 
Node    0, zone   Normal, type      Movable     32     19      5      8      4      4      3      1      1      0      1      0 
Node    0, zone   Normal, type      Reserve     30     31     22     20     23     14      7      3      0      0      0      0 
Node    0, zone   Normal, type          CMA    507    252    112     16      1      1      0      0      0      0      0      0 
Node    0, zone   Normal, type      Isolate      0      0      0      0      0      0      0      0      0      0      0      0 

Number of blocks type     Unmovable  Reclaimable      Movable      Reserve          CMA      Isolate 
Node 0, zone   Normal           20            1            8            1            2            0 
Node 0, zone   Normal    860    556    354    217    175    117     79     46     25     17      8      0 

df 输出如下

Filesystem           1024-blocks    Used Available Use% Mounted on
rootfs                  487652    136737    321219  30% /
/dev/root               487652    136737    321219  30% /
tmpfs                   125720        60    125660   0% /tmp
tmpfs                   125720         0    125720   0% /dev/shm
tmpfs                   125720        68    125652   0% /var/run
tmpfs                   125720         8    125712   0% /var/spool/cron
tmpfs                   125720         4    125716   0% /home/<app>/.ssh
tmpfs                   125720         0    125720   0% /var/sftp
tmpfs                   125720         0    125720   0% /var/monit-health-check
/dev/mmcblk0p18          55397      3480     47617   7% /var/db
/dev/mmcblk0p19         999320      1416    929092   0% /var/firmware
/dev/mmcblk0p20         379525      2094    353316   1% /var/misc
/dev/mmcblk0p21          31596      1065     27951   4% /var/log
/dev/mmcblk0p22         999320      1284    929224   0% /var/eventlog

为什么会有这么多ramfs无法移动的页面?有什么不寻常的吗?tmpfs~38MB

我们已经CONFIG_COMPACTION在内核配置中启用了。当我们看到

在基于 BBB 的 Google 群组中询问了碎片化问题,我们目前还没有解决方案。 https://groups.google.com/forum/#!topic/beagleboard/L7piqfHiyO8

用例:创建包含 4k 大小(使用 /dev/urandom)文件(85,0000)的 tar,并将其解压到已安装的分区(大小 500MB,FS=ext4)上,过一会儿,我们解压停止并且分区重新以只读方式挂载。

[47364.483783] lowmem_reserve[]: 0 0 0
[47364.483797] Normal: 2529*4kB (UEMRC) 893*8kB (UEMC) 16*16kB (UM) 6*32kB (M) 0*64kB 1*128kB (M) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 17836kB
[47364.483855] 44590 total pagecache pages
[47364.483871] 0 pages in swap cache
[47364.483881] Swap cache stats: add 0, delete 0, find 0/0
[47364.483888] Free swap  = 0kB
[47364.483895] Total swap = 0kB
[47364.494968] 65536 pages of RAM
[47364.494978] 4767 free pages
[47364.494985] 2662 reserved pages
[47364.494993] 5200 slab pages
[47364.495000] 310103 pages shared
[47364.495008] 0 pages swap cached
[47368.503176] mmcqd/1: page allocation failure: order:2, mode:0x200020
[47368.503216] CPU: 0 PID: 613 Comm: mmcqd/1 Tainted: P           O 3.12.10-005-ts-armv7l #1
[47368.503282] [<c0012d24>] (unwind_backtrace+0x0/0xf4) from [<c0011130>] (show_stack+0x10/0x14)
[47368.503317] [<c0011130>] (show_stack+0x10/0x14) from [<c0087548>] (warn_alloc_failed+0xe0/0x118)
[47368.503346] [<c0087548>] (warn_alloc_failed+0xe0/0x118) from [<c008a3ac>] (__alloc_pages_nodemask+0x74c/0x8f8)
[47368.503375] [<c008a3ac>] (__alloc_pages_nodemask+0x74c/0x8f8) from [<c00b2e8c>] (cache_alloc_refill+0x328/0x620)
[47368.503398] [<c00b2e8c>] (cache_alloc_refill+0x328/0x620) from [<c00b3224>] (__kmalloc+0xa0/0xe8)
[47368.503433] [<c00b3224>] (__kmalloc+0xa0/0xe8) from [<c0212904>] (edma_prep_slave_sg+0x84/0x388)
[47368.503469] [<c0212904>] (edma_prep_slave_sg+0x84/0x388) from [<c02eeb98>] (omap_hsmmc_request+0x414/0x508)
[47368.503497] [<c02eeb98>] (omap_hsmmc_request+0x414/0x508) from [<c02d9240>] (mmc_start_request+0xc4/0xe0)
[47368.503519] [<c02d9240>] (mmc_start_request+0xc4/0xe0) from [<c02da028>] (mmc_start_req+0x2d8/0x38c)
[47368.503540] [<c02da028>] (mmc_start_req+0x2d8/0x38c) from [<c02e7310>] (mmc_blk_issue_rw_rq+0xb4/0x9d8)
[47368.503562] [<c02e7310>] (mmc_blk_issue_rw_rq+0xb4/0x9d8) from [<c02e7dd8>] (mmc_blk_issue_rq+0x1a4/0x468)
[47368.503583] [<c02e7dd8>] (mmc_blk_issue_rq+0x1a4/0x468) from [<c02e8760>] (mmc_queue_thread+0x88/0x118)
[47368.503609] [<c02e8760>] (mmc_queue_thread+0x88/0x118) from [<c004d8b8>] (kthread+0xb4/0xb8)
[47368.503633] [<c004d8b8>] (kthread+0xb4/0xb8) from [<c000e298>] (ret_from_fork+0x14/0x3c)
[47368.503644] Mem-info:
[47368.503653] Normal per-cpu:
[47368.503664] CPU    0: hi:   90, btch:  15 usd:  17
[47368.503691] active_anon:7530 inactive_anon:20 isolated_anon:0
[47368.503691]  active_file:3142 inactive_file:44610 isolated_file:0
[47368.503691]  unevictable:422 dirty:32 writeback:0 unstable:0
[47368.503691]  free:1149 slab_reclaimable:3734 slab_unreclaimable:1130
[47368.503691]  mapped:2362 shmem:43 pagetables:256 bounce:0
[47368.503691]  free_cma:207
[47368.503752] Normal free:4596kB min:2004kB low:2504kB high:3004kB active_anon:30120kB inactive_anon:80kB active_file:12568kB inactive_file:178440kB unevictable:1688kB isolated(anon):0kB isolated(file):0kB present:260096kB managed:251496kB mlocked:1688kB dirty:128kB writeback:0kB mapped:9448kB shmem:172kB slab_reclaimable:14936kB slab_unreclaimable:4520kB kernel_stack:1176kB pagetables:1024kB unstable:0kB bounce:0kB free_cma:828kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no
[47368.503765] lowmem_reserve[]: 0 0 0
[47368.503782] Normal: 833*4kB (UEMRC) 158*8kB (MC) 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 4596kB
[47368.503833] 48144 total pagecache pages
[47368.503849] 0 pages in swap cache
[47368.503858] Swap cache stats: add 0, delete 0, find 0/0
[47368.503866] Free swap  = 0kB
[47368.503873] Total swap = 0kB
[47368.503885] SLAB: Unable to allocate memory on node 0 (gfp=0x20)
[47368.503896]   cache: kmalloc-16384, object size: 16384, order: 2
[47368.503909]   node 0: slabs: 7/7, objs: 7/7, free: 0
[47368.503932] omap_hsmmc 481d8000.mmc: prep_slave_sg() failed
[47368.503945] omap_hsmmc 481d8000.mmc: MMC start dma failure
[47368.512369] mmcblk0: unknown error -1 sending read/write command, card status 0x900
[47368.512578] blk_update_request: 371 callbacks suppressed
[47368.512591] end_request: I/O error, dev mmcblk0, sector 1371894
[47368.512613] Buffer I/O error on device mmcblk0p16, logical block 145275
[47368.512623] lost page write due to I/O error on mmcblk0p16
[47368.512892] end_request: I/O error, dev mmcblk0, sector 1371896
[47368.512906] Buffer I/O error on device mmcblk0p16, logical block 145276
[47368.512916] lost page write due to I/O error on mmcblk0p16
[47368.513011] end_request: I/O error, dev mmcblk0, sector 1371898
[47368.513024] Buffer I/O error on device mmcblk0p16, logical block 145277
[47368.513034] lost page write due to I/O error on mmcblk0p16
[47368.513107] end_request: I/O error, dev mmcblk0, sector 1371900
[47368.513179] end_request: I/O error, dev mmcblk0, sector 1371902
[47368.513251] end_request: I/O error, dev mmcblk0, sector 1371904
[47368.513322] end_request: I/O error, dev mmcblk0, sector 1371906
[47368.513405] end_request: I/O error, dev mmcblk0, sector 1371908
[47368.513478] end_request: I/O error, dev mmcblk0, sector 1371910
[47368.513549] end_request: I/O error, dev mmcblk0, sector 1371912
[47368.796212] Aborting journal on device mmcblk0p16-8.
[47368.802513] EXT4-fs error (device mmcblk0p16): ext4_journal_check_start:56: Detected aborted journal
[47368.812303] EXT4-fs (mmcblk0p16): Remounting filesystem read-only
[47369.669029] Mem-info:
[47369.669043] Normal per-cpu:
[47369.669057] CPU    0: hi:   90, btch:  15 usd:  47
[47369.669085] active_anon:7486 inactive_anon:20 isolated_anon:0
[47369.669085]  active_file:3150 inactive_file:44775 isolated_file:0
[47369.669085]  unevictable:422 dirty:37 writeback:0 unstable:0
[47369.669085]  free:1041 slab_reclaimable:3730 slab_unreclaimable:1105
[47369.669085]  mapped:2367 shmem:43 pagetables:250 bounce:0
[47369.669085]  free_cma:176
[47369.669147] Normal free:4164kB min:2004kB low:2504kB high:3004kB active_anon:29944kB inactive_anon:80kB active_file:12600kB inactive_file:179100kB unevictable:1688kB isolated(anon):0kB isolated(file):0kB present:260096kB managed:251496kB mlocked:1688kB dirty:148kB writeback:0kB mapped:9468kB shmem:172kB slab_reclaimable:14920kB slab_unreclaimable:4420kB kernel_stack:1168kB pagetables:1000kB unstable:0kB bounce:0kB free_cma:704kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no
[47369.669159] lowmem_reserve[]: 0 0 0
[47369.669173] Normal: 733*4kB (UEMRC) 92*8kB (MC) 11*16kB (UMC) 6*32kB (UMC) 2*64kB (U) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 4164kB

同样的问题是无法在 BBB 中重现的(使用 Linux 3.8 和 angstrom)。我在测试时还将 RAM 大小更改为 256M。

相关内容