[LTP] [PATCH 6/7] libs: libltpnuma: Fix free memory estimate

Cyril Hrubis chrubis@suse.cz
Thu Mar 3 15:50:31 CET 2022


On long running systems most of the memory would be consumed by a
file page cache which is reclaimable. Because of that the numa test will
be skipped even if the system has plenty of memory. To fix this this
patch adds 90% of the memory used by the page cache to the free memory
estimate.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 libs/libltpnuma/tst_numa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libs/libltpnuma/tst_numa.c b/libs/libltpnuma/tst_numa.c
index 417d98ced..7b8c4bc79 100644
--- a/libs/libltpnuma/tst_numa.c
+++ b/libs/libltpnuma/tst_numa.c
@@ -129,6 +129,7 @@ static int node_has_enough_memory(int node, size_t min_kb)
 	char buf[1024];
 	long mem_total = 0;
 	long mem_used = 0;
+	long file_pages = 0;
 
 	/* Make sure there is some space for kernel upkeeping as well */
 	min_kb += 4096;
@@ -152,6 +153,9 @@ static int node_has_enough_memory(int node, size_t min_kb)
 
 		if (sscanf(buf, "%*s %*i MemUsed: %li", &val) == 1)
 			mem_used = val;
+
+		if (sscanf(buf, "%*s %*i FilePages: %li", &val) == 1)
+			file_pages = val;
 	}
 
 	fclose(fp);
@@ -161,7 +165,7 @@ static int node_has_enough_memory(int node, size_t min_kb)
 		return 0;
 	}
 
-	if (mem_total - mem_used < (long)min_kb) {
+	if (mem_total - mem_used + (9 * file_pages)/10 < (long)min_kb) {
 		tst_res(TINFO,
 		        "Not enough free RAM on node %i, have %likB needs %zukB",
 		        node, mem_total - mem_used, min_kb);
-- 
2.34.1



More information about the ltp mailing list