相关疑难解决方法(0)

如何在内存压力下将可执行代码保存在内存中?在Linux中

这里的目标是在内存压力期间将每个正在运行的进程的可执行代码保存在内存中.
在Linux中,我能够立即(1秒)引起高内存压力,并在Qubes OS R4.0 Fedora 28 AppVM内通过stress --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 + 4000;}' < /proc/meminfo)k --vm-keep -m 4 --timeout 10s(来自此处的代码)触发OOM杀手, 最大内存为24000MB.编辑4:也许是相关的,但我忘了提及,事实是我没有启用交换(即CONFIG_SWAP未设置)

dmesg报道:

[  867.746593] Mem-Info:
[  867.746607] active_anon:1390927 inactive_anon:4670 isolated_anon:0
                active_file:94 inactive_file:72 isolated_file:0
                unevictable:13868 dirty:0 writeback:0 unstable:0
                slab_reclaimable:5906 slab_unreclaimable:12919
                mapped:1335 shmem:4805 pagetables:5126 bounce:0
                free:40680 free_pcp:978 free_cma:0
Run Code Online (Sandbox Code Playgroud)

有趣的部分是active_file:94 inactive_file:72它们以千字节为单位并且非常低.

这里的问题是,在内存压力期间,正在从磁盘重新读取可执行代码,导致磁盘抖动,从而导致操作系统冻结.(但在上述情况下,它只发生不到1秒)

我在内核中看到一个有趣的代码:mm/vmscan.c

        if (page_referenced(page, 0, sc->target_mem_cgroup,
                            &vm_flags)) {
                nr_rotated += hpage_nr_pages(page);
                /*
                 * Identify referenced, file-backed active …
Run Code Online (Sandbox Code Playgroud)

linux memory memory-management linux-kernel memory-pressure

10
推荐指数
1
解决办法
1221
查看次数