[LTP] [PATCH v1 1/1] libs: libltpnuma: Fix one fake failure when CXL(Compute eXpress Link) node memory is not used

Cyril Hrubis chrubis@suse.cz
Tue May 9 16:10:35 CEST 2023


Hi!
> # ./get_mempolicy01
> tst_test.c:1560: TINFO: Timeout per run is 0h 00m 30s
> tst_numa.c:208: TINFO: Found 3 NUMA memory nodes
> tst_numa.c:162: TWARN: Faield to parse '/sys/devices/system/node/node0/meminfo' MemUsed:65220292
> tst_numa.c:162: TWARN: Faield to parse '/sys/devices/system/node/node1/meminfo' MemUsed:65167784
> tst_numa.c:162: TWARN: Faield to parse '/sys/devices/system/node/node2/meminfo' MemUsed:4194304
> get_mempolicy01.c:149: TCONF: test requires at least one NUMA memory node
> Node 0 and 1 could not be tested with follow patch installed, seems when
> node2/meminfo "MemUsed: 0",sscanf("...%li", &val) will return 0 if only 0 value
> will be scaned, and the while loop will scan the char one by one and impact all
> other node meminfo scan result, it's strange.
> 
> If used my patch, I didn't meet this issue.

Ah, right the file is multiline and we match only one of the lines per
iteration...

Then we need:

diff --git a/libs/libltpnuma/tst_numa.c b/libs/libltpnuma/tst_numa.c
index ef4c8e879..c3297013b 100644
--- a/libs/libltpnuma/tst_numa.c
+++ b/libs/libltpnuma/tst_numa.c
@@ -127,8 +127,8 @@ static int node_has_enough_memory(int node, size_t min_kb)
 {
        char path[1024];
        char buf[1024];
-       long mem_total = 0;
-       long mem_used = 0;
+       long mem_total = -1;
+       long mem_used = -1;
        long file_pages = 0;
        long mem_avail;

@@ -161,7 +161,7 @@ static int node_has_enough_memory(int node, size_t min_kb)

        fclose(fp);

-       if (!mem_total || !mem_used) {
+       if (mem_total == -1 || mem_used == -1) {
                tst_res(TWARN, "Failed to parse '%s'", path);
                return 0;
        }

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list