Re: [LTP] [PATCH v3] lib: memutils: respect minimum memory watermark when polluting memory
From: Li Wang <hidden>
Date: 2021-10-21 08:05:59
quoted
quoted
Therically this is correct, and I believe it will work on your tested machine. But my concern is ioctl_sg01 still fails on the special system which MemAvai < MemFree. Just like the one Xinpeng mentioned before: https://lists.linux.it/pipermail/ltp/2021-January/020817.html <https://lists.linux.it/pipermail/ltp/2021-January/020817.html> [root@test-env-nm05-compute-14e5e72e38 <mailto:root@test-env-nm05-compute-14e5e72e38>~]# cat /proc/meminfo MemTotal: 526997420 kB MemFree: 520224908 kB MemAvailable: 519936744 kB ... [root@test-env-nm05-compute-14e5e72e38 <mailto:root@test-env-nm05-compute-14e5e72e38> ~]# cat /proc/sys/vm/min_free_kbytesquoted
quoted
90112 There even reserve the safety to the 128MB, still less than the gap between MemFree and MemAvailable. MemFree (520224908 kB) - MemAvailable (520224908 kB) = 288164 kB >safetyquoted
I don't have such case and I am not sure it is reasonable. As mentioned in the thread there it looks unusual to have less available memory than free. Maybe the system has some weird memory accounting because MemAvailable is counted from MemFree by adding memory which can be reclaimed. When adding a non-negative number, you should not end up with lower MemAvailable than MemFree. :) Maybe that's the reason why that patch was not accepted - the system is not vanilla, not common?OK, I found a possible explanation (on vanilla kernel) - the totalreserve_pages. This is the only subtraction from free memory when counting available. This could happen if someone was setting sysctl lowmem_reserve_ratio or min_free_kbytes.
That's exactly, beside the two controllers, you could also get such a system with enabling smaller swap space on aarch64/x86_64. (I did that and found that 'MemFree > MemAvail' is common to see)
When setting min_free_kbytes, this will be reflected in /proc/sys/vm/min_free_kbytes, so we are good. When setting vm.lowmem_reserve_ratio, this will be missed by my patch and MemAvailable could be lower than MemFree.
Yes, we have to face different kinds of system configuration in testing. Maybe we'd better keep the (info.freeram/64) in MAX() as well, Or, do a comparison between MemFree and MemAvail to choose the smaller one as baseline. -- Regards, Li Wang