mirror-linux/arch
Thomas Richter 99269799bf s390/pai: Fix missing PAI counter increments under heavy load
Machines with a larger number of CPUs and under heavy load sometimes
loose PAI counter increments during recording using events
-e CRYPTO_ÂLL or -e NNPA_ALL. Counting is not affected.
This happens when several PAI crypto counters are incremented during
the same cryptographic operation.

During schedule out the functions

paiXXX_sched_task() (with XXX either crypt or ext)
+--> pai_have_samples()
   +--> pai_have_sample()
	+--> pai_copy()
	+--> pai_push_sample()

are called to read out PAI counter values.
In pai_copy() the current values of PAI counters are read from the
PMU memory mapped page and compared to the values read during last
schedule out operation, which have been saved in a backup page
named PAI_SAVE_AREA(event). For each PAI counter a delta is calculated
and when the delta is positive, that PAI counter was incremented by
hardware. This positve delta is reported as raw data record attached
to a sample.
After all deltas have been calculated, the new PAI counter values
are saved in the backup page PAI_SAVE_AREA(event). However this is
done in pai_push_sample(), leaving a small window for missing hardware
triggered updates. Here is one scenario:

  PAI counter idx:   0   1   2   3   4   5   6   7  ....  N
                   +---+---+---+---+---+---+---+---+    +---+
  PAI counter page:|   |   | X |   |   |   |   |   |....| Y |
                   +---+---+---+---+---+---+---+---+    +---+

In pai_copy() each PAI counter value is read and compared
to its old value. This is done in a loop. When PAI counter indexed
N is read, the hardware might increment PAI counter indexed 2 again,
updating its value from X to X+1.
Later pai_push_sample() simply mem-copies the complete PAI counter
page to a backup page and the increment of X+1 is lost, because the
backup page now contains the new value.

Read each PAI counter and save this value in the backup page when
there is a positive delta. This omits any time window between read
and store. This also reduced the work load as only modified PAI
counters are saved.

Cc: stable@vger.kernel.org
Fixes: fe861b0c8d ("s390/pai: save PAI counter value page in event structure")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
2026-05-11 16:00:04 +02:00
..
alpha Delete some obsolete networking code 2026-04-24 09:41:58 -07:00
arc bpf-fixes 2026-04-17 15:58:22 -07:00
arm ARM development for 7.1-rc1 2026-04-25 07:44:26 -07:00
arm64 soc: late changes for 7.1 2026-04-23 08:57:24 -07:00
csky arch, mm: consolidate empty_zero_page 2026-04-05 13:53:01 -07:00
hexagon mm.git review status for linus..mm-stable 2026-04-15 12:59:16 -07:00
loongarch LoongArch changes for v7.1 2026-04-24 09:54:45 -07:00
m68k m68k updates for v7.1 2026-04-16 08:11:01 -07:00
microblaze mm: change to return bool for ptep_test_and_clear_young() 2026-04-05 13:53:35 -07:00
mips Delete some obsolete networking code 2026-04-24 09:41:58 -07:00
nios2 mm: convert do_brk_flags() to use vma_flags_t 2026-04-05 13:53:40 -07:00
openrisc arch, mm: consolidate empty_zero_page 2026-04-05 13:53:01 -07:00
parisc parisc architecture fixes and updates for kernel v7.1-rc1: 2026-04-18 11:37:36 -07:00
powerpc Delete some obsolete networking code 2026-04-24 09:41:58 -07:00
riscv RISC-V updates for v7.1 2026-04-24 10:00:37 -07:00
s390 s390/pai: Fix missing PAI counter increments under heavy load 2026-05-11 16:00:04 +02:00
sh sh updates for v7.1 2026-04-20 16:41:19 -07:00
sparc memblock: updates for 7.0-rc1 2026-04-18 11:29:14 -07:00
um Mostly cleanups and small things, notably: 2026-04-20 16:36:46 -07:00
x86 Miscellaneous x86 fixes: 2026-04-24 10:05:42 -07:00
xtensa Xtensa updates for v7.1 2026-04-23 16:40:03 -07:00
.gitignore
Kconfig parisc architecture fixes and updates for kernel v7.1-rc1: 2026-04-18 11:37:36 -07:00