From: Costa Shulyupin <costa.shul@redhat.com>
To: longman@redhat.com, ming.lei@redhat.com, pauld@redhat.com,
juri.lelli@redhat.com, vschneid@redhat.com,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Costa Shulyupin" <costa.shul@redhat.com>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: [RFC PATCH v4 4/4] DO NOT MERGE: Test CPU isolation from managed interrupts
Date: Sun, 1 Dec 2024 14:42:44 +0200 [thread overview]
Message-ID: <20241201124244.997754-5-costa.shul@redhat.com> (raw)
In-Reply-To: <20241201124244.997754-1-costa.shul@redhat.com>
Test CPU isolation to ensure it is unaffected by managed interrupts.
Target: irq_restore_affinity_of_irq()
Managed interrupts can be created in various ways. One of them:
qemu-img create -f qcow2 test.qcow2 100M
virtme-ng -v --cpus 4 --rw --user root \
--qemu-opts '\-drive id=d1,if=none,file=test.qcow2 \
\-device nvme,id=i1,drive=d1,serial=1,bootindex=2'
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
v4:
- Remove /sys/devices/system/cpu/cpu$isolate/online
v3:
- No changes
v2:
- use shell script only
---
MAINTAINERS | 2 +
tests/managed_irq.sh | 135 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 137 insertions(+)
create mode 100755 tests/managed_irq.sh
diff --git a/MAINTAINERS b/MAINTAINERS
index 1240e75ecf4b..4a753c2b34c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26046,3 +26046,5 @@ S: Buried alive in reporters
T: git git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
F: *
F: */
+
+# disable warning
diff --git a/tests/managed_irq.sh b/tests/managed_irq.sh
new file mode 100755
index 000000000000..3763183fc987
--- /dev/null
+++ b/tests/managed_irq.sh
@@ -0,0 +1,135 @@
+#!/bin/zsh
+# SPDX-License-Identifier: GPL-2.0
+
+# shell script for testing dynamic isolation of managed interrupts.
+# Target: irq_restore_affinity_of_irq()
+
+# cpu# to isolate
+
+isolate=1
+
+managed_affined=$(
+ cd /sys/kernel/debug/irq/irqs/;
+ grep -l -e "affinity: $isolate$" /dev/null $(grep -l IRQD_AFFINITY_MANAGED *) |
+ head -n1
+)
+grep -l -e "affinity: $isolate$" /dev/null \
+ $(grep -l IRQD_AFFINITY_MANAGED /sys/kernel/debug/irq/irqs/*)
+test_irq=${managed_affined%% *}
+echo test_irq=$test_irq
+
+[ -z $test_irq ] && { echo No managed IRQs found;exit 1}
+
+cp -R /sys/kernel/debug/irq/irqs 0.irqs
+
+# Restart CPUs without changing the isolated cpuset.
+# Setup a baseline (the "control group")
+# to compare against the test of isolated mask.
+
+echo 0 > /sys/devices/system/cpu/cpu$isolate/online
+echo 0 > /sys/devices/system/cpu/cpu3/online
+echo 1 > /sys/devices/system/cpu/cpu$isolate/online
+echo 1 > /sys/devices/system/cpu/cpu3/online
+
+rm -rf baseline.irqs
+cp -R /sys/kernel/debug/irq/irqs baseline.irqs
+
+cd /sys/fs/cgroup/
+echo +cpuset > cgroup.subtree_control
+mkdir -p test
+echo isolated > test/cpuset.cpus.partition
+
+effective_affinity=/proc/irq/$test_irq/effective_affinity
+test_irq_debug=/sys/kernel/debug/irq/irqs/$test_irq
+
+errors=0
+
+check()
+{
+ local _status=$?
+ if [[ $_status == 0 ]]
+ then
+ echo PASS
+ else
+ let errors+=1
+ echo "FAIL #$errors:"
+ cat $test_irq_debug
+ fi
+ return $_status
+}
+
+check_activated()
+{
+ echo "Check normal irq affinity"
+ test 0 -ne $((0x$(cat $effective_affinity) & 1 << $isolate))
+ check
+ grep -q IRQD_ACTIVATED $test_irq_debug
+ check
+ grep -q IRQD_IRQ_STARTED $test_irq_debug
+ check
+ ! grep -q IRQD_IRQ_DISABLED $test_irq_debug
+ check
+ ! grep -q IRQD_IRQ_MASKED $test_irq_debug
+ check
+ ! grep -q IRQD_MANAGED_SHUTDOWN $test_irq_debug
+ check
+}
+
+check_shutdown()
+{
+ echo "Check that irq affinity doesn't contain isolated cpu."
+ test 0 -eq $((0x$(cat $effective_affinity) & 1 << $isolate))
+ check
+ ! grep -q IRQD_ACTIVATED $test_irq_debug
+ check
+ ! grep -q IRQD_IRQ_STARTED $test_irq_debug
+ check
+ grep -q IRQD_IRQ_DISABLED $test_irq_debug
+ check
+ grep -q IRQD_IRQ_MASKED $test_irq_debug
+ check
+ grep -q IRQD_MANAGED_SHUTDOWN $test_irq_debug
+ check
+}
+
+echo "Isolating CPU #$isolate"
+echo $isolate > test/cpuset.cpus
+
+check_shutdown
+
+echo Reset cpuset
+echo "" > test/cpuset.cpus
+
+check_activated
+
+echo "Isolating CPU #$isolate again"
+echo $isolate > test/cpuset.cpus
+
+check_shutdown
+
+echo "Isolating CPU #3 and restore CPU #$isolate"
+echo 3 > test/cpuset.cpus
+
+check_activated
+
+echo Reset cpuset
+echo "" > test/cpuset.cpus
+
+rmdir test
+cd -
+
+rm -rf final.irqs
+cp -R /sys/kernel/debug/irq/irqs final.irqs
+
+sleep 1 # wait till IRQD_IRQ_INPROGRESS, IRQD_IRQ_MASKED
+
+if ! diff -r --ignore-matching-lines=Vector:: baseline.irqs final.irqs; then
+ echo diff failed;
+ let errors+=1
+fi
+
+#
+# return zero on success or number of errors
+#
+echo errors=$errors
+(return $errors)
--
2.47.0
prev parent reply other threads:[~2024-12-01 12:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-01 12:42 [RFC PATCH v4 0/4] genirq/cpuhotplug: Adjust managed interrupts according to change of housekeeping cpumask Costa Shulyupin
2024-12-01 12:42 ` [RFC PATCH v4 1/4] cgroup/cpuset: Add HK_TYPE_MANAGED_IRQ to HOUSEKEEPING_FLAGS Costa Shulyupin
2024-12-01 12:42 ` [RFC PATCH v4 2/4] genirq/cpuhotplug: Dynamically isolate CPUs from managed interrupts Costa Shulyupin
2024-12-01 13:43 ` Thomas Gleixner
[not found] ` <CADDUTFx3bS4bQ+6s2MSpAL=aN+5CP7V9i5vu-EnrfLrSYbQ_vg@mail.gmail.com>
2024-12-04 14:12 ` Thomas Gleixner
2024-12-01 12:42 ` [RFC PATCH v4 3/4] cgroup/cpuset: Restart CPUs whose isolated_cpus bits have changed Costa Shulyupin
2024-12-01 12:42 ` Costa Shulyupin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241201124244.997754-5-costa.shul@redhat.com \
--to=costa.shul@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=ming.lei@redhat.com \
--cc=mkoutny@suse.com \
--cc=pauld@redhat.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®