4

I came across the following parameter in kernel settings (in sysctl):

vm.min_free_kbytes

This is the amount of free memory (RAM) that's always free no matter what. In my case, I have only 1 GiB of RAM, and this parameter was set to about 64MiB. I thought that's pretty high, so I lowered it to 8MiB so far. I don't know if I can lower it any further, or if lowering it to 8MiB can cause any troubles, so the question is what would happen if the amount of the free memory was too low? Can I safely lower the value to 1MiB?

8

Should be safe but can't guarentee it. From kernel docs:

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.

Essentially if you set it to low you'll have problems with memory allocation.

  • 1
    PF_MEMALLOC is used in low memory situations if kernel processes that try to free e.g. disk caches need some work memory. If the kernel cannot get memory in that case the whole system may hang. If you're lucky, you may get visible kernel panic or something in syslog. Otherwise, you have set the limit too low if system just hangs with no explanation. Note that this only makes difference when RAM is almost full so you need to test with highest RAM comsumption you're going to expect. – Mikko Rantalainen Dec 17 '17 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.