Motivation
I wrote an answer here: How large are the "watermark" memory reservations on my system? The "min" watermark for the "Normal" zone appeared as 31449 pages. This is 125796 KiB - larger than my entire min_free_kbytes
(67584).
Resetting min_free_kbytes
sets the min
watermark of this zone to an expected level (e.g. 9582 pages). But after a while, it goes back to the higher level.
I am confident this is due to boost_watermark(). It boosts "min", "low", and "high" watermarks by the same amount. watermark_boost_factor is 15000, so the maximum boost should be 150% of the original "high" watermark...
Question
Why is my "high" watermark so high in the first place? (and also the "low" watermark):
Since my watermark_scale_factor is 10, the distance between "min", "low", and "high" is supposed to be only 0.1% of the zone size. But if I look immediately after resetting min_free_kbytes
, the difference between "min" and "low" is 2% of the zone size. Why?
(Also the difference between "low" and "high" is 0.2% of the zone size. So this is not what we expect either!).
The code that I thought sets up the watermarks is in __setup_per_zone_wmarks().
Kernel version: 5.0.17-200.fc29.x86_64
From /proc/zoneinfo
:
Node 0, zone Normal
pages free 74597
min 9582
low 34505
high 36900
spanned 1173504
present 1173504
managed 1140349
I don't see this massive discrepancy in the DMA32 zone. It doen't look like the "min" watermark get boosted in the DMA32 zone either, maybe because the kernel prefers to allocate from the "Normal" zone.
Node 0, zone DMA
...
pages free 3961
min 33
low 41
high 49
spanned 4095
present 3996
managed 3961
...
Node 0, zone DMA32
pages free 334671
min 7280
low 9100
high 10920
spanned 1044480
present 888973
managed 866356