]> granicus.if.org Git - sysstat/commit
RFE #140: mpstat: Provide CPU statistics based on NUMA node placement
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 8 Mar 2017 14:06:25 +0000 (15:06 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 8 Mar 2017 14:06:25 +0000 (15:06 +0100)
commit060e888cfaaccf96c44d65366eec69d238cbdd57
tree230544860e271eb272b92779158bf5205f15bb0b
parent82f1288ebf579fb0b58481ffb1be8409afd53b21
RFE #140: mpstat: Provide CPU statistics based on NUMA node placement

This patch for mpstat provides CPU load statistics for NUMA nodes.

It uses CPU statistics read from /proc/stat file then split them among
all nodes based on node placement.
Node placement is determined using /sys/devices/system/cpu/cpu#/node#
file indicating which node the CPU is bound to. The node the CPU belongs
to is saved in an array of integers named cpu2node (e.g. cpu2node[3]
gives the node number for CPU#3).
The number of CPU per node is saved in another array of integers named
cpu_per_node (e.g. cpu_per_node[0] gives the number of CPU bound to
node#0).
The statistics for node N is calculated as the sum of statistics for
each CPU bound to node N divided by the number of CPU bound to that
node.
The patch assumes that statistics for node "all" are the same as
statistics for CPU "all".

Node statistics can be displayed using the new mpstat's option "-n"
(e.g. "mpstat -n 2 5"). Nodes to be displayed can be selected using
option "-N" the same way processors can be selected using option "-P"
(e.g. "mpstat -n -N 0,3 2 5").

PLEASE TEST THIS PATCH as my own machine offers limited possibilities.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
mpstat.c
mpstat.h