如果可用記憶體量 (vm.min_free_kbytes) 太低會發生什麼事?

如果可用記憶體量 (vm.min_free_kbytes) 太低會發生什麼事?

我在核心設定(在 sysctl 中)中遇到了以下參數:

vm.min_free_kbytes

這是無論如何都始終可用的可用記憶體 (RAM) 量。就我而言,我只有 1 GiB 的 RAM,並且此參數設定為大約 64MiB。我認為這相當高,所以到目前為止我將其降低到 8MiB。我不知道是否可以進一步降低它,或者降低到 8MiB 是否會造成任何麻煩,所以問題是如果可用內存量太低會發生什麼?我可以安全地將值降低到 1MiB 嗎?

答案1

應該是安全的,但不能保證。來自內核文檔:

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.

本質上,如果將其設為低值,則會出現記憶體分配問題。

相關內容