[PATCH v3 0/6] Track and expose idle PURR and SPURR ticks
From: Gautham R. Shenoy
Date: Wed Mar 11 2020 - 05:38:16 EST
From: "Gautham R. Shenoy" <ego@xxxxxxxxxxxxxxxxxx>
Hi,
This is the third version of the patches to track and expose idle PURR
and SPURR ticks. These patches are required by tools such as lparstat
to compute system utilization for capacity planning purposes.
The previous versions can be found here:
v2: https://lkml.org/lkml/2020/2/21/21
v1: https://lore.kernel.org/patchwork/cover/1159341/
They key changes from v2 are:
- The prolog and epilog functions have been named
pseries_idle_prolog() and pseries_idle_epilog() respectively to
indicate their pseries specific nature.
- Fixed the Documentation for
/sys/devices/system/cpu/cpuX/idle_spurr as pointed out by
Nathan Lynch.
- Introduces a patch (Patch 6/6) to send an IPI in order to read
and cache the values of purr, spurr, idle_purr and idle_spurr of
the target CPU when any one of them is read via sysfs. These
cached values will be presented if any of these sysfs are read
within the next 10ms. If these sysfs files are read after 10ms
from the earlier IPI, a fresh IPI is issued to read and cache
the values again. This minimizes the number of IPIs required to
be sent when these values are read back-to-back via the sysfs
interface.
Test-results: While reading the four sysfs files back-to-back for a
given CPU every second for 100 seconds.
Without patch 6/6 (Without caching):
16 [XICS 2 Edge IPI] = 422 times
DBL [Doorbell interrupts] = 13 times
Total : 435 IPIs.
With patch 6/6 (With caching):
16 [XICS 2 Edge IPI] = 111 times
DBL [Doorbell interrupts] = 17 times
Total : 128 IPIs.
Motivation:
===========
On PSeries LPARs, the data centers planners desire a more accurate
view of system utilization per resource such as CPU to plan the system
capacity requirements better. Such accuracy can be obtained by reading
PURR/SPURR registers for CPU resource utilization.
Tools such as lparstat which are used to compute the utilization need
to know [S]PURR ticks when the cpu was busy or idle. The [S]PURR
counters are already exposed through sysfs. We already account for
PURR ticks when we go to idle so that we can update the VPA area. This
patchset extends support to account for SPURR ticks when idle, and
expose both via per-cpu sysfs files.
These patches are required for enhancement to the lparstat utility
that compute the CPU utilization based on PURR and SPURR which can be
found here :
https://groups.google.com/forum/#!topic/powerpc-utils-devel/fYRo69xO9r4
With the patches, when lparstat is run on a LPAR running CPU-Hogs,
=========================================================================
sudo ./src/lparstat -E 1 3
System Configuration
type=Dedicated mode=Capped smt=8 lcpu=2 mem=4834176 kB cpus=0 ent=2.00
---Actual--- -Normalized-
%busy %idle Frequency %busy %idle
------ ------ ------------- ------ ------
1 99.99 0.00 3.35GHz[111%] 110.99 0.00
2 100.00 0.00 3.35GHz[111%] 111.00 0.00
3 100.00 0.00 3.35GHz[111%] 111.00 0.00
=========================================================================
When lparstat is run on an LPAR that is idle,
=========================================================================
$ sudo ./src/lparstat -E 1 3
System Configuration
type=Dedicated mode=Capped smt=8 lcpu=2 mem=4834176 kB cpus=0 ent=2.00
---Actual--- -Normalized-
%busy %idle Frequency %busy %idle
------ ------ ------------- ------ ------
1 0.71 99.30 2.18GHz[ 72%] 0.53 71.48
2 0.56 99.44 2.11GHz[ 70%] 0.43 69.57
3 0.54 99.46 2.11GHz[ 70%] 0.43 69.57
=========================================================================
Gautham R. Shenoy (6):
powerpc: Move idle_loop_prolog()/epilog() functions to header file
powerpc/idle: Add accessor function to always read latest idle PURR
powerpc/pseries: Account for SPURR ticks on idle CPUs
powerpc/sysfs: Show idle_purr and idle_spurr for every CPU
Documentation: Document sysfs interfaces purr, spurr, idle_purr, idle_spurr
pseries/sysfs: Minimise IPI noise while reading [idle_][s]purr
Documentation/ABI/testing/sysfs-devices-system-cpu | 39 ++++++
arch/powerpc/include/asm/idle.h | 89 ++++++++++++++
arch/powerpc/kernel/sysfs.c | 133 +++++++++++++++++++--
arch/powerpc/platforms/pseries/setup.c | 8 +-
drivers/cpuidle/cpuidle-pseries.c | 39 ++----
5 files changed, 267 insertions(+), 41 deletions(-)
create mode 100644 arch/powerpc/include/asm/idle.h
--
1.9.4