diff mbox series

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

Message ID 20220303145032.21493-7-chrubis@suse.cz
State Accepted
Headers show
Series ksm06 and libnuma cleanups and fixes | expand

Commit Message

Cyril Hrubis March 3, 2022, 2:50 p.m. UTC
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(-)

Comments

Li Wang March 4, 2022, 2:56 a.m. UTC | #1
> -       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);
>

We'd better count that part in the output message as well.

Reviewed-by: Li Wang <liwang@redhat.com>
diff mbox series

Patch

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);