<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 2, 2020 at 5:51 PM Harish <<a href="mailto:harish@linux.ibm.com">harish@linux.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In few systems, the node numbering is not necessarily ordered.<br>
E.g.<br>
<br>
Per-node process memory usage (in MBs) for PID 2069 (systemd-udevd)<br>
                           Node 0          Node 8           Total<br>
                  --------------- --------------- ---------------<br>
...<br>
...<br>
----------------  --------------- --------------- ---------------<br>
Total                       17.50            0.00           17.50<br>
<br>
Patch fixes parsing numastat for given node by finding its awk<br>
index so that proper value is utilized in the test.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Thanks for fixing this Harish, but I'm afraid you have to rebase your code on Petr's last patch.</div><div class="gmail_default" style="font-size:small"><a href="http://lists.linux.it/pipermail/ltp/2020-July/017893.html">http://lists.linux.it/pipermail/ltp/2020-July/017893.html</a></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Anyway, this patch makes sense to me.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Signed-off-by: Harish <<a href="mailto:harish@linux.ibm.com" target="_blank">harish@linux.ibm.com</a>><br>
---<br>
 testcases/kernel/numa/numa01.sh | 19 +++++++++++++++----<br>
 1 file changed, 15 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh<br>
index 1d626327d..fd437cd15 100755<br>
--- a/testcases/kernel/numa/numa01.sh<br>
+++ b/testcases/kernel/numa/numa01.sh<br>
@@ -25,15 +25,26 @@ TST_NEEDS_CMDS="awk bc numactl numastat"<br>
<br>
 . tst_test.sh<br>
<br>
+# Awk the field matching the node value for numastat<br>
+# $1 - Pid number<br>
+# $2 - Node number<br>
+get_node_index()<br>
+{<br>
+       local pid=$1<br>
+       local nid="Node $2"<br>
+       echo $(numastat -p $pid | sed '3q;d' | awk -F '[[:space:]][[:space:]]+' \<br>
+               -v node="$nid" '{ for (i = 1; i <= NF; ++i) if($i==node) print i; exit }')<br>
+}<br>
+<br>
 # Extracts the value of given numa node from the `numastat -p` output.<br>
 # $1 - Pid number.<br>
 # $2 - Node number.<br>
 extract_numastat_p()<br>
 {<br>
        local pid=$1<br>
-       local node=$(($2 + 2))<br>
+       local index=$(echo "$(get_node_index $pid $2)")<br>
<br>
-       echo $(numastat -p $pid |awk '/^Total/ {print $'$node'}')<br>
+       echo $(numastat -p $pid |awk '/^Total/ {print $'$index'}')<br>
 }<br>
<br>
 check_for_support_numa()<br>
@@ -341,8 +352,8 @@ test9()<br>
                numactl --cpunodebind=$node --membind=$node support_numa alloc_1huge_page &<br>
                pid=$!<br>
                TST_RETRY_FUNC "check_for_support_numa $pid" 0<br>
-<br>
-               Mem_huge=$(echo $(numastat -p $pid |awk '/^Huge/ {print $'$((node+2))'}'))<br>
+               local index=$(echo "$(get_node_index $pid $node)")<br>
+               Mem_huge=$(echo $(numastat -p $pid |awk '/^Huge/ {print $'$index'}'))<br>
                Mem_huge=$((${Mem_huge%.*} * 1024))<br>
<br>
                if [ "$Mem_huge" -lt "$HPAGE_SIZE" ]; then<br>
-- <br>
2.25.4<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>