libs: libltpnuma: Fix free memory estimate

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>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Li Wang <liwang@redhat.com>
diff --git a/libs/libltpnuma/tst_numa.c b/libs/libltpnuma/tst_numa.c
index 417d98c..ef4c8e8 100644
--- a/libs/libltpnuma/tst_numa.c
+++ b/libs/libltpnuma/tst_numa.c
@@ -129,6 +129,8 @@
 	char buf[1024];
 	long mem_total = 0;
 	long mem_used = 0;
+	long file_pages = 0;
+	long mem_avail;
 
 	/* Make sure there is some space for kernel upkeeping as well */
 	min_kb += 4096;
@@ -152,6 +154,9 @@
 
 		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,10 +166,12 @@
 		return 0;
 	}
 
-	if (mem_total - mem_used < (long)min_kb) {
+	mem_avail = mem_total - mem_used + (9 * file_pages)/10;
+
+	if (mem_avail < (long)min_kb) {
 		tst_res(TINFO,
 		        "Not enough free RAM on node %i, have %likB needs %zukB",
-		        node, mem_total - mem_used, min_kb);
+		        node, mem_avail, min_kb);
 		return 0;
 	}