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