FAILED: patch "[PATCH] s390/cpum_cf: Check session mask before cpu offline" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 99a95985dfc85eecad97f0991a2401d2fcef294c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110414-reliable-bonded-7e4b@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 99a95985dfc85eecad97f0991a2401d2fcef294c Mon Sep 17 00:00:00 2001
From: Sumanth Korikkar <[email protected]>
Date: Tue, 6 Oct 2026 13:13:03 +0200
Subject: [PATCH] s390/cpum_cf: Check session mask before cpu offline
cfset_offline_cpu() stops counter sets for every active session without checking whether the outgoing cpu belongs to the session mask.
For example, run an hwctr session on cpu0 and a cpu bound perf event on cpu1:
lshwc -l 9999 -i 5 0:b
perf stat -C 1 -e cpum_cf/CPU_CYCLES/ sleep 120
chcpu -d 1
chcpu -e 1
Although the hwctr session does not include cpu1, cfset_offline_cpu() decrements its counter set reference count. The subsequent perf teardown decrements it again, causing it to underflow.
The perf event keeps the percpu state alive across hotplug. When cpu1 comes online, the hwctr session is started there and the reference count moves from -1 to 0. Stopping the hwctr session then decrements it to -1 again, so the zero triggered counter set disable path is skipped.
Check the session mask before stopping counter sets on the outgoing cpu. This prevents the unmatched decrement and the resulting reference count underflow.
arch/s390/kernel/perf_cpum_cf.c +3 -0
@@ -1797,6 +1797,9 @@ static int cfset_offline_cpu(unsigned int cpu)if (!list_empty (&cfset_session.head)) {list_for_each_entry (rp, &cfset_session.head, node) { +if (!cpumask_test_cpu (cpu, &rp->mask)) +continue ; + p.sets = rp->ctrset;cfset_ioctl_off (&p);cpumask_clear_cpu (cpu, &rp->mask);
Sasha Levin
maintainerPATCH 1/1 s390/cpum_cf: Check session mask before cpu offline
From: Sumanth Korikkar <[email protected]>
[ Upstream commit 99a95985dfc85eecad97f0991a2401d2fcef294c ]
cfset_offline_cpu() stops counter sets for every active session without checking whether the outgoing cpu belongs to the session mask.
For example, run an hwctr session on cpu0 and a cpu bound perf event on cpu1:
lshwc -l 9999 -i 5 0:b
perf stat -C 1 -e cpum_cf/CPU_CYCLES/ sleep 120
chcpu -d 1
chcpu -e 1
Although the hwctr session does not include cpu1, cfset_offline_cpu() decrements its counter set reference count. The subsequent perf teardown decrements it again, causing it to underflow.
The perf event keeps the percpu state alive across hotplug. When cpu1 comes online, the hwctr session is started there and the reference count moves from -1 to 0. Stopping the hwctr session then decrements it to -1 again, so the zero triggered counter set disable path is skipped.
Check the session mask before stopping counter sets on the outgoing cpu. This prevents the unmatched decrement and the resulting reference count underflow.
--- arch/s390/kernel/perf_cpum_cf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kernel/perf_cpum_cf.c +2 -1
@@ -1223,7 +1223,8 @@ int cfset_offline_cpu(unsigned int cpu)struct cfset_call_on_cpu_parm p;mutex_lock (&cfset_ctrset_mutex); -if (cfset_request.ctrset) { +if (cfset_request.ctrset && +cpumask_test_cpu (cpu, &cfset_request.mask)) { p.sets = cfset_request.ctrset;cfset_ioctl_off (&p);cpumask_clear_cpu (cpu, &cfset_request.mask);
Signature · 1 line
2.53.0