87cc1f
diff -Naurp pcp-4.3.2.wip/qa/1393 pcp-4.3.2/qa/1393
87cc1f
--- pcp-4.3.2.wip/qa/1393	1970-01-01 10:00:00.000000000 +1000
87cc1f
+++ pcp-4.3.2/qa/1393	2020-02-17 17:29:39.572489770 +1100
87cc1f
@@ -0,0 +1,64 @@
87cc1f
+#!/bin/sh
87cc1f
+# PCP QA Test No. 1393
87cc1f
+# Test sparse and non-contiguous numa-nodes and CPUs
87cc1f
+# RHBZ#1730492 - Some numa nodes have no instances.
87cc1f
+#
87cc1f
+# Copyright (c) 2019 Red Hat.  All Rights Reserved.
87cc1f
+#
87cc1f
+
87cc1f
+seq=`basename $0`
87cc1f
+echo "QA output created by $seq"
87cc1f
+
87cc1f
+# get standard environment, filters and checks
87cc1f
+. ./common.product
87cc1f
+. ./common.filter
87cc1f
+. ./common.check
87cc1f
+
87cc1f
+[ $PCP_PLATFORM = linux ] || _notrun "Linux-specific PMDA testing"
87cc1f
+
87cc1f
+_cleanup()
87cc1f
+{
87cc1f
+    cd $here
87cc1f
+    $sudo rm -rf $tmp $tmp.*
87cc1f
+}
87cc1f
+
87cc1f
+status=1	# failure is the default!
87cc1f
+$sudo rm -rf $tmp $tmp.* $seq.full
87cc1f
+trap "_cleanup; exit \$status" 0 1 2 3 15
87cc1f
+
87cc1f
+_sort_instname()
87cc1f
+{
87cc1f
+    tee $tmp.sort | sed -n 2p
87cc1f
+    awk '/inst / {print "  ", $4, $6}' $tmp.sort | sed -e 's/\]//' | LC_COLLATE=POSIX sort
87cc1f
+}
87cc1f
+
87cc1f
+# real QA test starts here
87cc1f
+mkdir -p $tmp
87cc1f
+tar -C $tmp -xf linux/sysfs-numa-001.tgz
87cc1f
+pmda=$PCP_PMDAS_DIR/linux/pmda_linux.$DSO_SUFFIX,linux_init
87cc1f
+export LINUX_STATSPATH="$tmp"
87cc1f
+
87cc1f
+metrics="hinv.map.cpu_node hinv.node.online \
87cc1f
+  kernel.percpu.cpu.idle kernel.percpu.cpu.user kernel.pernode.cpu.idle \
87cc1f
+  kernel.pernode.cpu.user mem.numa.alloc.local_node mem.numa.util.total \
87cc1f
+  mem.numa.util.free mem.numa.util.used"
87cc1f
+
87cc1f
+echo == check basic numa metrics 4 nodes, 8 CPUs
87cc1f
+pminfo -L -K clear -K add,60,$pmda -f hinv.nnode hinv.ncpu
87cc1f
+for m in $metrics; do pminfo -L -K clear -K add,60,$pmda -f $m| _sort_instname; done
87cc1f
+
87cc1f
+echo;echo ==;echo == delete node2, leaving node0, node1 and node3;echo ==
87cc1f
+rm -rf $LINUX_STATSPATH/sys/devices/system/node/node2
87cc1f
+rm -rf $LINUX_STATSPATH/sys/devices/system/memory/memory*/node2
87cc1f
+echo '0,1,3' >$LINUX_STATSPATH/sys/devices/system/node/online
87cc1f
+echo '0,1,3' >$LINUX_STATSPATH/sys/devices/system/node/possible
87cc1f
+rm -rf $LINUX_STATSPATH/sys/devices/system/cpu/cpu{4,5}
87cc1f
+sed -i '/^cpu[45]$/d' $LINUX_STATSPATH/proc/stat
87cc1f
+echo '0,1,2,3,6,7' >$LINUX_STATSPATH/sys/devices/system/cpu/online
87cc1f
+echo '0,1,2,3,6,7' >$LINUX_STATSPATH/sys/devices/system/cpu/present
87cc1f
+pminfo -L -K clear -K add,60,$pmda -f hinv.nnode hinv.ncpu
87cc1f
+for m in $metrics; do pminfo -L -K clear -K add,60,$pmda -f $m| _sort_instname; done
87cc1f
+
87cc1f
+# success, all done
87cc1f
+status=0
87cc1f
+exit
87cc1f
diff -Naurp pcp-4.3.2.wip/qa/1393.out pcp-4.3.2/qa/1393.out
87cc1f
--- pcp-4.3.2.wip/qa/1393.out	1970-01-01 10:00:00.000000000 +1000
87cc1f
+++ pcp-4.3.2/qa/1393.out	2020-02-17 17:28:43.162140076 +1100
87cc1f
@@ -0,0 +1,129 @@
87cc1f
+QA output created by 1393
87cc1f
+== check basic numa metrics 4 nodes, 8 CPUs
87cc1f
+
87cc1f
+hinv.nnode
87cc1f
+    value 4
87cc1f
+
87cc1f
+hinv.ncpu
87cc1f
+    value 8
87cc1f
+hinv.map.cpu_node
87cc1f
+   "cpu0" 0
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 1
87cc1f
+   "cpu3" 1
87cc1f
+   "cpu4" 2
87cc1f
+   "cpu5" 2
87cc1f
+   "cpu6" 3
87cc1f
+   "cpu7" 3
87cc1f
+hinv.node.online
87cc1f
+   "node0" 1
87cc1f
+   "node1" 1
87cc1f
+   "node2" 1
87cc1f
+   "node3" 1
87cc1f
+kernel.percpu.cpu.idle
87cc1f
+   "cpu0" 82176250
87cc1f
+   "cpu1" 82246600
87cc1f
+   "cpu2" 82152810
87cc1f
+   "cpu3" 82283820
87cc1f
+   "cpu4" 82098120
87cc1f
+   "cpu5" 82009220
87cc1f
+   "cpu6" 82276330
87cc1f
+   "cpu7" 82191150
87cc1f
+kernel.percpu.cpu.user
87cc1f
+   "cpu0" 373300
87cc1f
+   "cpu1" 349760
87cc1f
+   "cpu2" 363240
87cc1f
+   "cpu3" 369770
87cc1f
+   "cpu4" 412040
87cc1f
+   "cpu5" 419270
87cc1f
+   "cpu6" 344030
87cc1f
+   "cpu7" 433650
87cc1f
+kernel.pernode.cpu.idle
87cc1f
+   "node0" 164422850
87cc1f
+   "node1" 164436630
87cc1f
+   "node2" 164107340
87cc1f
+   "node3" 164467480
87cc1f
+kernel.pernode.cpu.user
87cc1f
+   "node0" 723060
87cc1f
+   "node1" 733010
87cc1f
+   "node2" 831310
87cc1f
+   "node3" 777680
87cc1f
+mem.numa.alloc.local_node
87cc1f
+   "node0" 32241822
87cc1f
+   "node1" 32048777
87cc1f
+   "node2" 35574473
87cc1f
+   "node3" 32921660
87cc1f
+mem.numa.util.total
87cc1f
+   "node0" 1030924
87cc1f
+   "node1" 1031416
87cc1f
+   "node2" 965616
87cc1f
+   "node3" 1006408
87cc1f
+mem.numa.util.free
87cc1f
+   "node0" 354088
87cc1f
+   "node1" 557252
87cc1f
+   "node2" 229456
87cc1f
+   "node3" 271916
87cc1f
+mem.numa.util.used
87cc1f
+   "node0" 676836
87cc1f
+   "node1" 474164
87cc1f
+   "node2" 736160
87cc1f
+   "node3" 734492
87cc1f
+
87cc1f
+==
87cc1f
+== delete node2, leaving node0, node1 and node3
87cc1f
+==
87cc1f
+
87cc1f
+hinv.nnode
87cc1f
+    value 3
87cc1f
+
87cc1f
+hinv.ncpu
87cc1f
+    value 6
87cc1f
+hinv.map.cpu_node
87cc1f
+   "cpu0" 0
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 1
87cc1f
+   "cpu3" 1
87cc1f
+   "cpu6" 3
87cc1f
+   "cpu7" 3
87cc1f
+hinv.node.online
87cc1f
+   "node0" 1
87cc1f
+   "node1" 1
87cc1f
+   "node3" 1
87cc1f
+kernel.percpu.cpu.idle
87cc1f
+   "cpu0" 82176250
87cc1f
+   "cpu1" 82246600
87cc1f
+   "cpu2" 82152810
87cc1f
+   "cpu3" 82283820
87cc1f
+   "cpu6" 82276330
87cc1f
+   "cpu7" 82191150
87cc1f
+kernel.percpu.cpu.user
87cc1f
+   "cpu0" 373300
87cc1f
+   "cpu1" 349760
87cc1f
+   "cpu2" 363240
87cc1f
+   "cpu3" 369770
87cc1f
+   "cpu6" 344030
87cc1f
+   "cpu7" 433650
87cc1f
+kernel.pernode.cpu.idle
87cc1f
+   "node0" 164422850
87cc1f
+   "node1" 164436630
87cc1f
+   "node3" 164467480
87cc1f
+kernel.pernode.cpu.user
87cc1f
+   "node0" 723060
87cc1f
+   "node1" 733010
87cc1f
+   "node3" 777680
87cc1f
+mem.numa.alloc.local_node
87cc1f
+   "node0" 32241822
87cc1f
+   "node1" 32048777
87cc1f
+   "node3" 32921660
87cc1f
+mem.numa.util.total
87cc1f
+   "node0" 1030924
87cc1f
+   "node1" 1031416
87cc1f
+   "node3" 1006408
87cc1f
+mem.numa.util.free
87cc1f
+   "node0" 354088
87cc1f
+   "node1" 557252
87cc1f
+   "node3" 271916
87cc1f
+mem.numa.util.used
87cc1f
+   "node0" 676836
87cc1f
+   "node1" 474164
87cc1f
+   "node3" 734492
87cc1f
diff -Naurp pcp-4.3.2.wip/qa/747 pcp-4.3.2/qa/747
87cc1f
--- pcp-4.3.2.wip/qa/747	2017-11-30 12:48:48.000000000 +1100
87cc1f
+++ pcp-4.3.2/qa/747	2020-02-17 17:28:43.161140088 +1100
87cc1f
@@ -19,27 +19,10 @@ status=1	# failure is the default!
87cc1f
 $sudo rm -rf $tmp.* $seq.full
87cc1f
 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
87cc1f
 
87cc1f
-# deal with non-determinism in the order in which the per cpu indom
87cc1f
-# is populated
87cc1f
-# input is assumed to be in the format ...
87cc1f
-# 	head ...
87cc1f
-# 	stuff to fix ...
87cc1f
-# 	tail ...
87cc1f
-#
87cc1f
-_fix_percpu_indom()
87cc1f
+_sort_instname()
87cc1f
 {
87cc1f
-    rm -f $tmp.head $tmp.percpu $tmp.tail
87cc1f
-    $PCP_AWK_PROG '
87cc1f
-/^hinv\.cpu\.online/		{ state = 1 }
87cc1f
-/^kernel\.percpu\./		{ state = 1 }
87cc1f
-state == 0			{ print >"'"$tmp.head"'"; next }
87cc1f
-state == 1			{ print >"'"$tmp.percpu"'" }
87cc1f
-state == 2			{ print >"'"$tmp.tail"'"; next }
87cc1f
-state == 1 && NF == 0		{ state = 2 }'
87cc1f
-    [ -f $tmp.head ] && cat $tmp.head
87cc1f
-    [ -f $tmp.percpu ] && $here/src/sortinst -i <$tmp.percpu \
87cc1f
-			  | sed -e 's/cpu[0-9][0-9]*/cpuN/'
87cc1f
-    [ -f $tmp.tail ] && cat $tmp.tail
87cc1f
+    tee $tmp.sort | sed -n 2p
87cc1f
+    awk '/inst / {print "  ", $4, $6}' $tmp.sort | sed -e 's/\]//' | LC_COLLATE=POSIX sort
87cc1f
 }
87cc1f
 
87cc1f
 # real QA test starts here
87cc1f
@@ -54,7 +37,7 @@ allcpu_metrics=`pminfo $local kernel.all
87cc1f
 percpu_metrics=`pminfo $local kernel.percpu.cpu | LC_COLLATE=POSIX sort`
87cc1f
 pernode_metrics=`pminfo $local kernel.pernode.cpu | LC_COLLATE=POSIX sort`
87cc1f
 
87cc1f
-for tgz in $here/linux/sysdev-*.tgz
87cc1f
+for tgz in $here/linux/sysdev-*.tgz $here/linux/sysfs-numa-001.tgz
87cc1f
 do
87cc1f
     rm -fr $root
87cc1f
     mkdir $root || _fail "root in use when processing $tgz"
87cc1f
@@ -65,7 +48,7 @@ do
87cc1f
     echo "== Checking hinv metric values - $base"
87cc1f
     for m in $hinv_metrics
87cc1f
     do
87cc1f
-	pminfo $local -f $m | _fix_percpu_indom
87cc1f
+	pminfo $local -f $m | _sort_instname
87cc1f
     done
87cc1f
     echo && echo "== done" && echo
87cc1f
 
87cc1f
@@ -76,12 +59,15 @@ do
87cc1f
     echo "== Checking per-CPU metric values - $base"
87cc1f
     for m in $percpu_metrics
87cc1f
     do
87cc1f
-	pminfo $local -f $m | _fix_percpu_indom
87cc1f
+	pminfo $local -f $m | _sort_instname
87cc1f
     done
87cc1f
     echo && echo "== done" && echo
87cc1f
 
87cc1f
     echo "== Checking per-node CPU metric values - $base"
87cc1f
-    pminfo $local -f $pernode_metrics
87cc1f
+    for m in $pernode_metrics
87cc1f
+    do
87cc1f
+	pminfo $local -f $m | _sort_instname
87cc1f
+    done
87cc1f
     echo && echo "== done" && echo
87cc1f
 
87cc1f
     cd $here
87cc1f
diff -Naurp pcp-4.3.2.wip/qa/747.out pcp-4.3.2/qa/747.out
87cc1f
--- pcp-4.3.2.wip/qa/747.out	2017-11-30 12:48:48.000000000 +1100
87cc1f
+++ pcp-4.3.2/qa/747.out	2020-02-17 17:28:43.161140088 +1100
87cc1f
@@ -1,14 +1,12 @@
87cc1f
 QA output created by 747
87cc1f
 == Checking hinv metric values - sysdev-root-001.tgz
87cc1f
-
87cc1f
 hinv.cpu.online
87cc1f
-    inst [0 or "cpuN"] value 1
87cc1f
-    inst [1 or "cpuN"] value 1
87cc1f
-    inst [2 or "cpuN"] value 0
87cc1f
-    inst [3 or "cpuN"] value 1
87cc1f
-
87cc1f
+   "cpu0" 1
87cc1f
+   "cpu1" 1
87cc1f
+   "cpu2" 0
87cc1f
+   "cpu3" 1
87cc1f
 hinv.node.online
87cc1f
-    inst [0 or "node0"] value 1
87cc1f
+   "node0" 1
87cc1f
 
87cc1f
 == done
87cc1f
 
87cc1f
@@ -56,127 +54,352 @@ kernel.all.cpu.wait.total
87cc1f
 == done
87cc1f
 
87cc1f
 == Checking per-CPU metric values - sysdev-root-001.tgz
87cc1f
-
87cc1f
 kernel.percpu.cpu.guest
87cc1f
-    inst [0 or "cpuN"] value 20
87cc1f
-    inst [1 or "cpuN"] value 0
87cc1f
-    inst [2 or "cpuN"] value 0
87cc1f
-    inst [3 or "cpuN"] value 0
87cc1f
-
87cc1f
+   "cpu0" 20
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 0
87cc1f
+   "cpu3" 0
87cc1f
 kernel.percpu.cpu.guest_nice
87cc1f
-    inst [0 or "cpuN"] value 30
87cc1f
-    inst [1 or "cpuN"] value 0
87cc1f
-    inst [2 or "cpuN"] value 0
87cc1f
-    inst [3 or "cpuN"] value 0
87cc1f
-
87cc1f
+   "cpu0" 30
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 0
87cc1f
+   "cpu3" 0
87cc1f
 kernel.percpu.cpu.idle
87cc1f
-    inst [0 or "cpuN"] value 286728520
87cc1f
-    inst [1 or "cpuN"] value 286695100
87cc1f
-    inst [2 or "cpuN"] value 286198490
87cc1f
-    inst [3 or "cpuN"] value 287003820
87cc1f
-
87cc1f
+   "cpu0" 286728520
87cc1f
+   "cpu1" 286695100
87cc1f
+   "cpu2" 286198490
87cc1f
+   "cpu3" 287003820
87cc1f
 kernel.percpu.cpu.intr
87cc1f
-    inst [0 or "cpuN"] value 36540
87cc1f
-    inst [1 or "cpuN"] value 25500
87cc1f
-    inst [2 or "cpuN"] value 51900
87cc1f
-    inst [3 or "cpuN"] value 31930
87cc1f
-
87cc1f
+   "cpu0" 36540
87cc1f
+   "cpu1" 25500
87cc1f
+   "cpu2" 51900
87cc1f
+   "cpu3" 31930
87cc1f
 kernel.percpu.cpu.irq.hard
87cc1f
-    inst [0 or "cpuN"] value 13940
87cc1f
-    inst [1 or "cpuN"] value 10830
87cc1f
-    inst [2 or "cpuN"] value 18940
87cc1f
-    inst [3 or "cpuN"] value 12030
87cc1f
-
87cc1f
+   "cpu0" 13940
87cc1f
+   "cpu1" 10830
87cc1f
+   "cpu2" 18940
87cc1f
+   "cpu3" 12030
87cc1f
 kernel.percpu.cpu.irq.soft
87cc1f
-    inst [0 or "cpuN"] value 22600
87cc1f
-    inst [1 or "cpuN"] value 14670
87cc1f
-    inst [2 or "cpuN"] value 32960
87cc1f
-    inst [3 or "cpuN"] value 19900
87cc1f
-
87cc1f
+   "cpu0" 22600
87cc1f
+   "cpu1" 14670
87cc1f
+   "cpu2" 32960
87cc1f
+   "cpu3" 19900
87cc1f
 kernel.percpu.cpu.nice
87cc1f
-    inst [0 or "cpuN"] value 4620
87cc1f
-    inst [1 or "cpuN"] value 1380
87cc1f
-    inst [2 or "cpuN"] value 630
87cc1f
-    inst [3 or "cpuN"] value 550
87cc1f
-
87cc1f
+   "cpu0" 4620
87cc1f
+   "cpu1" 1380
87cc1f
+   "cpu2" 630
87cc1f
+   "cpu3" 550
87cc1f
 kernel.percpu.cpu.steal
87cc1f
-    inst [0 or "cpuN"] value 10
87cc1f
-    inst [1 or "cpuN"] value 0
87cc1f
-    inst [2 or "cpuN"] value 0
87cc1f
-    inst [3 or "cpuN"] value 0
87cc1f
-
87cc1f
+   "cpu0" 10
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 0
87cc1f
+   "cpu3" 0
87cc1f
 kernel.percpu.cpu.sys
87cc1f
-    inst [0 or "cpuN"] value 105050
87cc1f
-    inst [1 or "cpuN"] value 146320
87cc1f
-    inst [2 or "cpuN"] value 109360
87cc1f
-    inst [3 or "cpuN"] value 146920
87cc1f
-
87cc1f
+   "cpu0" 105050
87cc1f
+   "cpu1" 146320
87cc1f
+   "cpu2" 109360
87cc1f
+   "cpu3" 146920
87cc1f
 kernel.percpu.cpu.user
87cc1f
-    inst [0 or "cpuN"] value 101190
87cc1f
-    inst [1 or "cpuN"] value 359270
87cc1f
-    inst [2 or "cpuN"] value 113190
87cc1f
-    inst [3 or "cpuN"] value 275520
87cc1f
-
87cc1f
+   "cpu0" 101190
87cc1f
+   "cpu1" 359270
87cc1f
+   "cpu2" 113190
87cc1f
+   "cpu3" 275520
87cc1f
 kernel.percpu.cpu.vnice
87cc1f
-    inst [0 or "cpuN"] value 4590
87cc1f
-    inst [1 or "cpuN"] value 1380
87cc1f
-    inst [2 or "cpuN"] value 630
87cc1f
-    inst [3 or "cpuN"] value 550
87cc1f
-
87cc1f
+   "cpu0" 4590
87cc1f
+   "cpu1" 1380
87cc1f
+   "cpu2" 630
87cc1f
+   "cpu3" 550
87cc1f
 kernel.percpu.cpu.vuser
87cc1f
-    inst [0 or "cpuN"] value 101170
87cc1f
-    inst [1 or "cpuN"] value 359270
87cc1f
-    inst [2 or "cpuN"] value 113190
87cc1f
-    inst [3 or "cpuN"] value 275520
87cc1f
-
87cc1f
+   "cpu0" 101170
87cc1f
+   "cpu1" 359270
87cc1f
+   "cpu2" 113190
87cc1f
+   "cpu3" 275520
87cc1f
 kernel.percpu.cpu.wait.total
87cc1f
-    inst [0 or "cpuN"] value 877160
87cc1f
-    inst [1 or "cpuN"] value 649420
87cc1f
-    inst [2 or "cpuN"] value 1373400
87cc1f
-    inst [3 or "cpuN"] value 420180
87cc1f
+   "cpu0" 877160
87cc1f
+   "cpu1" 649420
87cc1f
+   "cpu2" 1373400
87cc1f
+   "cpu3" 420180
87cc1f
 
87cc1f
 == done
87cc1f
 
87cc1f
 == Checking per-node CPU metric values - sysdev-root-001.tgz
87cc1f
-
87cc1f
 kernel.pernode.cpu.guest
87cc1f
-    inst [0 or "node0"] value 20
87cc1f
-
87cc1f
+   "node0" 20
87cc1f
 kernel.pernode.cpu.guest_nice
87cc1f
-    inst [0 or "node0"] value 30
87cc1f
-
87cc1f
+   "node0" 30
87cc1f
 kernel.pernode.cpu.idle
87cc1f
-    inst [0 or "node0"] value 1146625930
87cc1f
-
87cc1f
+   "node0" 1146625930
87cc1f
 kernel.pernode.cpu.intr
87cc1f
-    inst [0 or "node0"] value 145870
87cc1f
-
87cc1f
+   "node0" 145870
87cc1f
 kernel.pernode.cpu.irq.hard
87cc1f
-    inst [0 or "node0"] value 55740
87cc1f
-
87cc1f
+   "node0" 55740
87cc1f
 kernel.pernode.cpu.irq.soft
87cc1f
-    inst [0 or "node0"] value 90130
87cc1f
-
87cc1f
+   "node0" 90130
87cc1f
 kernel.pernode.cpu.nice
87cc1f
-    inst [0 or "node0"] value 7180
87cc1f
-
87cc1f
+   "node0" 7180
87cc1f
 kernel.pernode.cpu.steal
87cc1f
-    inst [0 or "node0"] value 10
87cc1f
-
87cc1f
+   "node0" 10
87cc1f
 kernel.pernode.cpu.sys
87cc1f
-    inst [0 or "node0"] value 507650
87cc1f
-
87cc1f
+   "node0" 507650
87cc1f
 kernel.pernode.cpu.user
87cc1f
-    inst [0 or "node0"] value 849170
87cc1f
-
87cc1f
+   "node0" 849170
87cc1f
 kernel.pernode.cpu.vnice
87cc1f
-    inst [0 or "node0"] value 7150
87cc1f
-
87cc1f
+   "node0" 7150
87cc1f
 kernel.pernode.cpu.vuser
87cc1f
-    inst [0 or "node0"] value 849150
87cc1f
+   "node0" 849150
87cc1f
+kernel.pernode.cpu.wait.total
87cc1f
+   "node0" 3320160
87cc1f
+
87cc1f
+== done
87cc1f
+
87cc1f
+== Checking hinv metric values - sysfs-numa-001.tgz
87cc1f
+hinv.cpu.online
87cc1f
+   "cpu0" 1
87cc1f
+   "cpu1" 1
87cc1f
+   "cpu2" 1
87cc1f
+   "cpu3" 1
87cc1f
+   "cpu4" 1
87cc1f
+   "cpu5" 1
87cc1f
+   "cpu6" 1
87cc1f
+   "cpu7" 1
87cc1f
+hinv.node.online
87cc1f
+   "node0" 1
87cc1f
+   "node1" 1
87cc1f
+   "node2" 1
87cc1f
+   "node3" 1
87cc1f
+
87cc1f
+== done
87cc1f
+
87cc1f
+== Checking aggregate CPU metric values - sysfs-numa-001.tgz
87cc1f
+
87cc1f
+kernel.all.cpu.guest
87cc1f
+    value 0
87cc1f
+
87cc1f
+kernel.all.cpu.guest_nice
87cc1f
+    value 0
87cc1f
+
87cc1f
+kernel.all.cpu.idle
87cc1f
+    value 657434330
87cc1f
+
87cc1f
+kernel.all.cpu.intr
87cc1f
+    value 368500
87cc1f
+
87cc1f
+kernel.all.cpu.irq.hard
87cc1f
+    value 252590
87cc1f
 
87cc1f
+kernel.all.cpu.irq.soft
87cc1f
+    value 115910
87cc1f
+
87cc1f
+kernel.all.cpu.nice
87cc1f
+    value 41160
87cc1f
+
87cc1f
+kernel.all.cpu.steal
87cc1f
+    value 143770
87cc1f
+
87cc1f
+kernel.all.cpu.sys
87cc1f
+    value 1200190
87cc1f
+
87cc1f
+kernel.all.cpu.user
87cc1f
+    value 3065100
87cc1f
+
87cc1f
+kernel.all.cpu.vnice
87cc1f
+    value 41160
87cc1f
+
87cc1f
+kernel.all.cpu.vuser
87cc1f
+    value 3065100
87cc1f
+
87cc1f
+kernel.all.cpu.wait.total
87cc1f
+    value 979420
87cc1f
+
87cc1f
+== done
87cc1f
+
87cc1f
+== Checking per-CPU metric values - sysfs-numa-001.tgz
87cc1f
+kernel.percpu.cpu.guest
87cc1f
+   "cpu0" 0
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 0
87cc1f
+   "cpu3" 0
87cc1f
+   "cpu4" 0
87cc1f
+   "cpu5" 0
87cc1f
+   "cpu6" 0
87cc1f
+   "cpu7" 0
87cc1f
+kernel.percpu.cpu.guest_nice
87cc1f
+   "cpu0" 0
87cc1f
+   "cpu1" 0
87cc1f
+   "cpu2" 0
87cc1f
+   "cpu3" 0
87cc1f
+   "cpu4" 0
87cc1f
+   "cpu5" 0
87cc1f
+   "cpu6" 0
87cc1f
+   "cpu7" 0
87cc1f
+kernel.percpu.cpu.idle
87cc1f
+   "cpu0" 82176250
87cc1f
+   "cpu1" 82246600
87cc1f
+   "cpu2" 82152810
87cc1f
+   "cpu3" 82283820
87cc1f
+   "cpu4" 82098120
87cc1f
+   "cpu5" 82009220
87cc1f
+   "cpu6" 82276330
87cc1f
+   "cpu7" 82191150
87cc1f
+kernel.percpu.cpu.intr
87cc1f
+   "cpu0" 31120
87cc1f
+   "cpu1" 27570
87cc1f
+   "cpu2" 65310
87cc1f
+   "cpu3" 32900
87cc1f
+   "cpu4" 30160
87cc1f
+   "cpu5" 74500
87cc1f
+   "cpu6" 69300
87cc1f
+   "cpu7" 37570
87cc1f
+kernel.percpu.cpu.irq.hard
87cc1f
+   "cpu0" 18700
87cc1f
+   "cpu1" 18690
87cc1f
+   "cpu2" 42080
87cc1f
+   "cpu3" 22020
87cc1f
+   "cpu4" 19450
87cc1f
+   "cpu5" 49820
87cc1f
+   "cpu6" 57240
87cc1f
+   "cpu7" 24550
87cc1f
+kernel.percpu.cpu.irq.soft
87cc1f
+   "cpu0" 12420
87cc1f
+   "cpu1" 8880
87cc1f
+   "cpu2" 23230
87cc1f
+   "cpu3" 10880
87cc1f
+   "cpu4" 10710
87cc1f
+   "cpu5" 24680
87cc1f
+   "cpu6" 12060
87cc1f
+   "cpu7" 13020
87cc1f
+kernel.percpu.cpu.nice
87cc1f
+   "cpu0" 2920
87cc1f
+   "cpu1" 3150
87cc1f
+   "cpu2" 2220
87cc1f
+   "cpu3" 4210
87cc1f
+   "cpu4" 7660
87cc1f
+   "cpu5" 9690
87cc1f
+   "cpu6" 2090
87cc1f
+   "cpu7" 9170
87cc1f
+kernel.percpu.cpu.steal
87cc1f
+   "cpu0" 16870
87cc1f
+   "cpu1" 13990
87cc1f
+   "cpu2" 26210
87cc1f
+   "cpu3" 17510
87cc1f
+   "cpu4" 15000
87cc1f
+   "cpu5" 16110
87cc1f
+   "cpu6" 18960
87cc1f
+   "cpu7" 19090
87cc1f
+kernel.percpu.cpu.sys
87cc1f
+   "cpu0" 124510
87cc1f
+   "cpu1" 156270
87cc1f
+   "cpu2" 125800
87cc1f
+   "cpu3" 133860
87cc1f
+   "cpu4" 189540
87cc1f
+   "cpu5" 192970
87cc1f
+   "cpu6" 133390
87cc1f
+   "cpu7" 143810
87cc1f
+kernel.percpu.cpu.user
87cc1f
+   "cpu0" 373300
87cc1f
+   "cpu1" 349760
87cc1f
+   "cpu2" 363240
87cc1f
+   "cpu3" 369770
87cc1f
+   "cpu4" 412040
87cc1f
+   "cpu5" 419270
87cc1f
+   "cpu6" 344030
87cc1f
+   "cpu7" 433650
87cc1f
+kernel.percpu.cpu.vnice
87cc1f
+   "cpu0" 2920
87cc1f
+   "cpu1" 3150
87cc1f
+   "cpu2" 2220
87cc1f
+   "cpu3" 4210
87cc1f
+   "cpu4" 7660
87cc1f
+   "cpu5" 9690
87cc1f
+   "cpu6" 2090
87cc1f
+   "cpu7" 9170
87cc1f
+kernel.percpu.cpu.vuser
87cc1f
+   "cpu0" 373300
87cc1f
+   "cpu1" 349760
87cc1f
+   "cpu2" 363240
87cc1f
+   "cpu3" 369770
87cc1f
+   "cpu4" 412040
87cc1f
+   "cpu5" 419270
87cc1f
+   "cpu6" 344030
87cc1f
+   "cpu7" 433650
87cc1f
+kernel.percpu.cpu.wait.total
87cc1f
+   "cpu0" 179200
87cc1f
+   "cpu1" 105950
87cc1f
+   "cpu2" 88480
87cc1f
+   "cpu3" 79880
87cc1f
+   "cpu4" 166720
87cc1f
+   "cpu5" 196030
87cc1f
+   "cpu6" 78000
87cc1f
+   "cpu7" 85130
87cc1f
+
87cc1f
+== done
87cc1f
+
87cc1f
+== Checking per-node CPU metric values - sysfs-numa-001.tgz
87cc1f
+kernel.pernode.cpu.guest
87cc1f
+   "node0" 0
87cc1f
+   "node1" 0
87cc1f
+   "node2" 0
87cc1f
+   "node3" 0
87cc1f
+kernel.pernode.cpu.guest_nice
87cc1f
+   "node0" 0
87cc1f
+   "node1" 0
87cc1f
+   "node2" 0
87cc1f
+   "node3" 0
87cc1f
+kernel.pernode.cpu.idle
87cc1f
+   "node0" 164422850
87cc1f
+   "node1" 164436630
87cc1f
+   "node2" 164107340
87cc1f
+   "node3" 164467480
87cc1f
+kernel.pernode.cpu.intr
87cc1f
+   "node0" 58690
87cc1f
+   "node1" 98210
87cc1f
+   "node2" 104660
87cc1f
+   "node3" 106870
87cc1f
+kernel.pernode.cpu.irq.hard
87cc1f
+   "node0" 37390
87cc1f
+   "node1" 64100
87cc1f
+   "node2" 69270
87cc1f
+   "node3" 81790
87cc1f
+kernel.pernode.cpu.irq.soft
87cc1f
+   "node0" 21300
87cc1f
+   "node1" 34110
87cc1f
+   "node2" 35390
87cc1f
+   "node3" 25080
87cc1f
+kernel.pernode.cpu.nice
87cc1f
+   "node0" 6070
87cc1f
+   "node1" 6430
87cc1f
+   "node2" 17350
87cc1f
+   "node3" 11260
87cc1f
+kernel.pernode.cpu.steal
87cc1f
+   "node0" 30860
87cc1f
+   "node1" 43720
87cc1f
+   "node2" 31110
87cc1f
+   "node3" 38050
87cc1f
+kernel.pernode.cpu.sys
87cc1f
+   "node0" 280780
87cc1f
+   "node1" 259660
87cc1f
+   "node2" 382510
87cc1f
+   "node3" 277200
87cc1f
+kernel.pernode.cpu.user
87cc1f
+   "node0" 723060
87cc1f
+   "node1" 733010
87cc1f
+   "node2" 831310
87cc1f
+   "node3" 777680
87cc1f
+kernel.pernode.cpu.vnice
87cc1f
+   "node0" 6070
87cc1f
+   "node1" 6430
87cc1f
+   "node2" 17350
87cc1f
+   "node3" 11260
87cc1f
+kernel.pernode.cpu.vuser
87cc1f
+   "node0" 723060
87cc1f
+   "node1" 733010
87cc1f
+   "node2" 831310
87cc1f
+   "node3" 777680
87cc1f
 kernel.pernode.cpu.wait.total
87cc1f
-    inst [0 or "node0"] value 3320160
87cc1f
+   "node0" 285150
87cc1f
+   "node1" 168360
87cc1f
+   "node2" 362750
87cc1f
+   "node3" 163130
87cc1f
 
87cc1f
 == done
87cc1f
 
87cc1f
diff -Naurp pcp-4.3.2.wip/qa/group pcp-4.3.2/qa/group
87cc1f
--- pcp-4.3.2.wip/qa/group	2020-02-17 12:19:02.743341620 +1100
87cc1f
+++ pcp-4.3.2/qa/group	2020-02-17 17:28:43.161140088 +1100
87cc1f
@@ -1651,6 +1651,7 @@ BAD
87cc1f
 1388 pmwebd local
87cc1f
 1389 pmwebd local
87cc1f
 1390 atop local
87cc1f
+1393 pmda.linux local
87cc1f
 1395 pmda.prometheus local python
87cc1f
 1396 pcp python pidstat local BAD @vm34
87cc1f
 1397 pmda.smart local valgrind
87cc1f
diff -Naurp pcp-4.3.2.wip/src/pmdas/linux/linux.h pcp-4.3.2/src/pmdas/linux/linux.h
87cc1f
--- pcp-4.3.2.wip/src/pmdas/linux/linux.h	2019-01-25 11:25:19.000000000 +1100
87cc1f
+++ pcp-4.3.2/src/pmdas/linux/linux.h	2020-02-17 17:28:43.155140157 +1100
87cc1f
@@ -277,20 +277,23 @@ typedef struct {
87cc1f
 } softnet_t;
87cc1f
 
87cc1f
 typedef struct {
87cc1f
-    unsigned int	cpuid;
87cc1f
-    unsigned int	nodeid;
87cc1f
+    unsigned int	nodeid; /* node%d instance name */
87cc1f
+    unsigned int	instid; /* internal instance id */
87cc1f
+    cpuacct_t		stat;
87cc1f
+    struct linux_table	*meminfo;
87cc1f
+    struct linux_table	*memstat;
87cc1f
+    double		bandwidth;
87cc1f
+} pernode_t;
87cc1f
+
87cc1f
+typedef struct {
87cc1f
+    unsigned int	cpuid;  /* cpu%d instance name */
87cc1f
+    unsigned int	instid; /* internal instance id */
87cc1f
+    pernode_t		*node;
87cc1f
     char		*name;
87cc1f
     cpuacct_t		stat;
87cc1f
     cpuinfo_t		info;
87cc1f
     softnet_t		*softnet;
87cc1f
 } percpu_t;
87cc1f
 
87cc1f
-typedef struct {
87cc1f
-    unsigned int	nodeid;
87cc1f
-    cpuacct_t		stat;
87cc1f
-    struct linux_table	*meminfo;
87cc1f
-    struct linux_table	*memstat;
87cc1f
-    double		bandwidth;
87cc1f
-} pernode_t;
87cc1f
 
87cc1f
 #endif /* LINUX_PMDA_H */
87cc1f
diff -Naurp pcp-4.3.2.wip/src/pmdas/linux/numa_meminfo.c pcp-4.3.2/src/pmdas/linux/numa_meminfo.c
87cc1f
--- pcp-4.3.2.wip/src/pmdas/linux/numa_meminfo.c	2018-03-05 18:14:58.000000000 +1100
87cc1f
+++ pcp-4.3.2/src/pmdas/linux/numa_meminfo.c	2020-02-17 17:28:43.152140192 +1100
87cc1f
@@ -113,14 +113,14 @@ refresh_numa_meminfo(void)
87cc1f
 	    continue;
87cc1f
 
87cc1f
 	pmsprintf(buf, sizeof(buf), "%s/sys/devices/system/node/node%d/meminfo",
87cc1f
-		linux_statspath, i);
87cc1f
+		linux_statspath, np->nodeid);
87cc1f
 	if ((fp = fopen(buf, "r")) != NULL) {
87cc1f
 	    linux_table_scan(fp, np->meminfo);
87cc1f
 	    fclose(fp);
87cc1f
 	}
87cc1f
 
87cc1f
 	pmsprintf(buf, sizeof(buf), "%s/sys/devices/system/node/node%d/numastat",
87cc1f
-		linux_statspath, i);
87cc1f
+		linux_statspath, np->nodeid);
87cc1f
 	if ((fp = fopen(buf, "r")) != NULL) {
87cc1f
 	    linux_table_scan(fp, np->memstat);
87cc1f
 	    fclose(fp);
87cc1f
diff -Naurp pcp-4.3.2.wip/src/pmdas/linux/pmda.c pcp-4.3.2/src/pmdas/linux/pmda.c
87cc1f
--- pcp-4.3.2.wip/src/pmdas/linux/pmda.c	2020-02-17 12:19:15.146197738 +1100
87cc1f
+++ pcp-4.3.2/src/pmdas/linux/pmda.c	2020-02-17 17:28:43.156140146 +1100
87cc1f
@@ -6098,6 +6098,7 @@ linux_fetchCallBack(pmdaMetric *mdesc, u
87cc1f
     net_addr_t		*addrp;
87cc1f
     net_interface_t	*netip;
87cc1f
     scsi_entry_t	*scsi_entry;
87cc1f
+    char		*name;
87cc1f
 
87cc1f
     if (mdesc->m_user != NULL) {
87cc1f
 	/* 
87cc1f
@@ -7306,7 +7307,7 @@ linux_fetchCallBack(pmdaMetric *mdesc, u
87cc1f
 	    atom->cp = get_machine_info(kernel_uname.machine);
87cc1f
 	    break;
87cc1f
 	case 8: /* hinv.map.cpu_node */
87cc1f
-	    atom->ul = cp->nodeid;
87cc1f
+	    atom->ul = cp->node->nodeid;
87cc1f
 	    break;
87cc1f
 	case 9: /* hinv.cpu.model_name */
87cc1f
 	    if ((i = cp->info.model_name) < 0)
87cc1f
@@ -7333,14 +7334,14 @@ linux_fetchCallBack(pmdaMetric *mdesc, u
87cc1f
     case CLUSTER_SYSFS_DEVICES:
87cc1f
 	switch (item) {
87cc1f
 	case 0: /* hinv.cpu.online */
87cc1f
-	    if (pmdaCacheLookup(INDOM(CPU_INDOM), inst, NULL, NULL) < 0)
87cc1f
+	    if (pmdaCacheLookup(INDOM(CPU_INDOM), inst, &name, NULL) < 0)
87cc1f
 		return PM_ERR_INST;
87cc1f
-	    atom->ul = refresh_sysfs_online(inst, "cpu");
87cc1f
+	    atom->ul = refresh_sysfs_online(name, "cpu");
87cc1f
 	    break;
87cc1f
 	case 1: /* hinv.node.online */
87cc1f
-	    if (pmdaCacheLookup(INDOM(NODE_INDOM), inst, NULL, NULL) < 0)
87cc1f
+	    if (pmdaCacheLookup(INDOM(NODE_INDOM), inst, &name, NULL) < 0)
87cc1f
 		return PM_ERR_INST;
87cc1f
-	    atom->ul = refresh_sysfs_online(inst, "node");
87cc1f
+	    atom->ul = refresh_sysfs_online(name, "node");
87cc1f
 	    break;
87cc1f
 
87cc1f
 	default:
87cc1f
diff -Naurp pcp-4.3.2.wip/src/pmdas/linux/proc_cpuinfo.c pcp-4.3.2/src/pmdas/linux/proc_cpuinfo.c
87cc1f
--- pcp-4.3.2.wip/src/pmdas/linux/proc_cpuinfo.c	2018-03-05 18:14:58.000000000 +1100
87cc1f
+++ pcp-4.3.2/src/pmdas/linux/proc_cpuinfo.c	2020-02-17 17:28:43.156140146 +1100
87cc1f
@@ -28,7 +28,7 @@
87cc1f
  * CPU or NUMA node ("node" parameter).
87cc1f
  */
87cc1f
 int
87cc1f
-refresh_sysfs_online(unsigned int node_num, const char *node)
87cc1f
+refresh_sysfs_online(char *instname, const char *node_or_cpu)
87cc1f
 {
87cc1f
     const char *sysfs_path = "sys/devices/system";
87cc1f
     char path[MAXPATHLEN];
87cc1f
@@ -36,8 +36,8 @@ refresh_sysfs_online(unsigned int node_n
87cc1f
     FILE *fp;
87cc1f
     int n;
87cc1f
 
87cc1f
-    pmsprintf(path, sizeof(path), "%s/%s/%s/%s%u/online",
87cc1f
-		linux_statspath, sysfs_path, node, node, node_num);
87cc1f
+    pmsprintf(path, sizeof(path), "%s/%s/%s/%s/online",
87cc1f
+		linux_statspath, sysfs_path, node_or_cpu, instname);
87cc1f
     if ((fp = fopen(path, "r")) == NULL)
87cc1f
 	return 1;
87cc1f
     n = fscanf(fp, "%u", &online);
87cc1f
diff -Naurp pcp-4.3.2.wip/src/pmdas/linux/proc_cpuinfo.h pcp-4.3.2/src/pmdas/linux/proc_cpuinfo.h
87cc1f
--- pcp-4.3.2.wip/src/pmdas/linux/proc_cpuinfo.h	2017-11-30 12:48:48.000000000 +1100
87cc1f
+++ pcp-4.3.2/src/pmdas/linux/proc_cpuinfo.h	2020-02-17 17:28:43.156140146 +1100
87cc1f
@@ -19,4 +19,4 @@
87cc1f
  */
87cc1f
 
87cc1f
 extern int refresh_proc_cpuinfo(void);
87cc1f
-extern int refresh_sysfs_online(unsigned int, const char *);
87cc1f
+extern int refresh_sysfs_online(char *, const char *);
87cc1f
diff -Naurp pcp-4.3.2.wip/src/pmdas/linux/proc_stat.c pcp-4.3.2/src/pmdas/linux/proc_stat.c
87cc1f
--- pcp-4.3.2.wip/src/pmdas/linux/proc_stat.c	2018-09-18 16:41:15.000000000 +1000
87cc1f
+++ pcp-4.3.2/src/pmdas/linux/proc_stat.c	2020-02-17 17:28:43.157140134 +1100
87cc1f
@@ -60,7 +60,7 @@ setup_cpu_info(cpuinfo_t *cip)
87cc1f
 }
87cc1f
 
87cc1f
 static void
87cc1f
-cpu_add(pmInDom cpus, unsigned int cpuid, unsigned int nodeid)
87cc1f
+cpu_add(pmInDom cpus, unsigned int cpuid, pernode_t *np)
87cc1f
 {
87cc1f
     percpu_t	*cpu;
87cc1f
     char	name[64];
87cc1f
@@ -68,23 +68,24 @@ cpu_add(pmInDom cpus, unsigned int cpuid
87cc1f
     if ((cpu = (percpu_t *)calloc(1, sizeof(percpu_t))) == NULL)
87cc1f
 	return;
87cc1f
     cpu->cpuid = cpuid;
87cc1f
-    cpu->nodeid = nodeid;
87cc1f
+    cpu->node = np;
87cc1f
     setup_cpu_info(&cpu->info);
87cc1f
     pmsprintf(name, sizeof(name)-1, "cpu%u", cpuid);
87cc1f
-    pmdaCacheStore(cpus, PMDA_CACHE_ADD, name, (void*)cpu);
87cc1f
+    cpu->instid = pmdaCacheStore(cpus, PMDA_CACHE_ADD, name, (void*)cpu);
87cc1f
 }
87cc1f
 
87cc1f
-static void
87cc1f
+static pernode_t *
87cc1f
 node_add(pmInDom nodes, unsigned int nodeid)
87cc1f
 {
87cc1f
     pernode_t	*node;
87cc1f
     char	name[64];
87cc1f
 
87cc1f
     if ((node = (pernode_t *)calloc(1, sizeof(pernode_t))) == NULL)
87cc1f
-	return;
87cc1f
+	return NULL;
87cc1f
     node->nodeid = nodeid;
87cc1f
     pmsprintf(name, sizeof(name)-1, "node%u", nodeid);
87cc1f
-    pmdaCacheStore(nodes, PMDA_CACHE_ADD, name, (void*)node);
87cc1f
+    node->instid = pmdaCacheStore(nodes, PMDA_CACHE_ADD, name, (void*)node);
87cc1f
+    return node;
87cc1f
 }
87cc1f
 
87cc1f
 void
87cc1f
@@ -98,6 +99,7 @@ cpu_node_setup(void)
87cc1f
     DIR			*cpu_dir;
87cc1f
     int			i, count;
87cc1f
     char		path[MAXPATHLEN];
87cc1f
+    pernode_t		*np;
87cc1f
     static int		setup;
87cc1f
 
87cc1f
     if (setup)
87cc1f
@@ -112,16 +114,16 @@ cpu_node_setup(void)
87cc1f
     count = scandir(path, &node_files, NULL, versionsort);
87cc1f
     if (!node_files || (linux_test_mode & LINUX_TEST_NCPUS)) {
87cc1f
 	/* QA mode or no sysfs support, assume single NUMA node */
87cc1f
-	node_add(nodes, 0);	/* default to just node zero */
87cc1f
+	np = node_add(nodes, 0);	/* default to just node zero */
87cc1f
 	for (cpu = 0; cpu < _pm_ncpus; cpu++)
87cc1f
-	    cpu_add(cpus, cpu, 0);	/* all in node zero */
87cc1f
+	    cpu_add(cpus, cpu, np);	/* all in node zero */
87cc1f
 	goto done;
87cc1f
     }
87cc1f
 
87cc1f
     for (i = 0; i < count; i++) {
87cc1f
 	if (sscanf(node_files[i]->d_name, "node%u", &node) != 1)
87cc1f
 	    continue;
87cc1f
-	node_add(nodes, node);
87cc1f
+	np = node_add(nodes, node);
87cc1f
 	pmsprintf(path, sizeof(path), "%s/%s/%s",
87cc1f
 		 linux_statspath, node_path, node_files[i]->d_name);
87cc1f
 	if ((cpu_dir = opendir(path)) == NULL)
87cc1f
@@ -129,7 +131,7 @@ cpu_node_setup(void)
87cc1f
 	while ((cpu_entry = readdir(cpu_dir)) != NULL) {
87cc1f
 	    if (sscanf(cpu_entry->d_name, "cpu%u", &cpu) != 1)
87cc1f
 		continue;
87cc1f
-	    cpu_add(cpus, cpu, node);
87cc1f
+	    cpu_add(cpus, cpu, np);
87cc1f
 	}
87cc1f
 	closedir(cpu_dir);
87cc1f
     }
87cc1f
@@ -172,6 +174,7 @@ refresh_proc_stat(proc_stat_t *proc_stat
87cc1f
     percpu_t	*cp;
87cc1f
     pmInDom	cpus, nodes;
87cc1f
     char	buf[MAXPATHLEN], *name, *sp, **bp;
87cc1f
+    char	cpuname[32];
87cc1f
     int		n = 0, i, size;
87cc1f
 
87cc1f
     static int fd = -1; /* kept open until exit(), unless testing */
87cc1f
@@ -282,7 +285,8 @@ refresh_proc_stat(proc_stat_t *proc_stat
87cc1f
 	    cp = NULL;
87cc1f
 	    np = NULL;
87cc1f
 	    i = atoi(&bufindex[n][3]);	/* extract CPU identifier */
87cc1f
-	    if (pmdaCacheLookup(cpus, i, &name, (void **)&cp) < 0 || !cp)
87cc1f
+	    pmsprintf(cpuname, sizeof(cpuname), "cpu%u", i); /* instance name */
87cc1f
+	    if (pmdaCacheLookupName(cpus, cpuname, &i, (void **)&cp) < 0 || !cp)
87cc1f
 		continue;
87cc1f
 	    memset(&cp->stat, 0, sizeof(cp->stat));
87cc1f
 	    sscanf(bufindex[n], PERCPU_FMT, &i,
87cc1f
@@ -290,10 +294,10 @@ refresh_proc_stat(proc_stat_t *proc_stat
87cc1f
 		    &cp->stat.idle, &cp->stat.wait, &cp->stat.irq,
87cc1f
 		    &cp->stat.sirq, &cp->stat.steal, &cp->stat.guest,
87cc1f
 		    &cp->stat.guest_nice);
87cc1f
-	    pmdaCacheStore(cpus, PMDA_CACHE_ADD, name, (void *)cp);
87cc1f
+	    pmdaCacheStore(cpus, PMDA_CACHE_ADD, cpuname, (void *)cp);
87cc1f
 
87cc1f
 	    /* update per-node aggregate CPU utilisation stats as well */
87cc1f
-	    if (pmdaCacheLookup(nodes, cp->nodeid, NULL, (void **)&np) < 0)
87cc1f
+	    if (pmdaCacheLookup(nodes, cp->node->instid, NULL, (void **)&np) < 0 || !np)
87cc1f
 		continue;
87cc1f
 	    np->stat.user += cp->stat.user;
87cc1f
 	    np->stat.nice += cp->stat.nice;