diff --git a/0001-cyclictest-Fix-threads-being-affined-even-when-a-isn.patch b/0001-cyclictest-Fix-threads-being-affined-even-when-a-isn.patch new file mode 100644 index 0000000..913fa21 --- /dev/null +++ b/0001-cyclictest-Fix-threads-being-affined-even-when-a-isn.patch @@ -0,0 +1,121 @@ +From 67ceae02e2cae95a2de5f371544dc551e7b86ca6 Mon Sep 17 00:00:00 2001 +From: John Stultz +Date: Thu, 28 Jul 2022 20:22:36 +0000 +Subject: [PATCH 1/4] cyclictest: Fix threads being affined even when -a isn't + set + +Using cyclictest without specifying affinity via -a, I was +noticing a strange issue where the rt threads where not +migrating when being blocked. + +After lots of debugging in the kernel, I found its actually an +issue with cyclictest. + +When using -t there is no behavioral difference between specifying +-a or not specifying -a. + +This can be confirmed by adding printf messages around the +pthread_setaffinity_np() call in the threadtest function. + +Currently: + +root@localhost:~/rt-tests# ./cyclictest -t -a -q -D1 +Affining thread 0 to cpu: 0 +Affining thread 1 to cpu: 1 +Affining thread 2 to cpu: 2 +Affining thread 3 to cpu: 3 +Affining thread 4 to cpu: 4 +Affining thread 5 to cpu: 5 +Affining thread 7 to cpu: 7 +Affining thread 6 to cpu: 6 +T: 0 (15034) P: 0 I:1000 C: 1000 Min: 82 Act: 184 Avg: 180 Max: 705 +... + +root@localhost:~/rt-tests# ./cyclictest -t -q -D1 +Affining thread 0 to cpu: 0 +Affining thread 1 to cpu: 1 +Affining thread 2 to cpu: 2 +Affining thread 3 to cpu: 3 +Affining thread 4 to cpu: 4 +Affining thread 5 to cpu: 5 +Affining thread 6 to cpu: 6 +Affining thread 7 to cpu: 7 +T: 0 (15044) P: 0 I:1000 C: 1000 Min: 74 Act: 144 Avg: 162 Max: 860 +.. + +This issue seems to come from the logic in process_options(): + /* if smp wasn't requested, test for numa automatically */ + if (!smp) { + numa = numa_initialize(); + if (setaffinity == AFFINITY_UNSPECIFIED) + setaffinity = AFFINITY_USEALL; + } + +Here, by setting setaffinity = AFFINITY_USEALL, we effectively +pin each thread to its respective cpu, same as the "-a" option. + +This was most recently introduced in commit bdb8350f1b0b +("Revert "cyclictest: Use affinity_mask for steering +thread placement""). + +This seems erronious to me, so I wanted to share this patch +which removes the overriding AFFINITY_UNSPECIFIED with +AFFINITY_USEALL by default. Also, some additional tweaks to +preserve the existing numa allocation affinity. + +With this patch, we no longer call pthread_setaffinity_np() in the +"./cyclictest -t -q -D1" case. + +Cc: John Kacur +Cc: Connor O'Brien +Cc: Qais Yousef +Signed-off-by: John Stultz +Signed-off-by: John Kacur + +[ upstream status: 2d910eecf10cd806e22abeb1d96189f87ef74d91 ] + +Signed-off-by: Petr Vorel +--- + src/cyclictest/cyclictest.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c +index decea78..82759d1 100644 +--- a/src/cyclictest/cyclictest.c ++++ b/src/cyclictest/cyclictest.c +@@ -1270,8 +1270,6 @@ static void process_options(int argc, char *argv[], int max_cpus) + /* if smp wasn't requested, test for numa automatically */ + if (!smp) { + numa = numa_initialize(); +- if (setaffinity == AFFINITY_UNSPECIFIED) +- setaffinity = AFFINITY_USEALL; + } + + if (option_affinity) { +@@ -2043,9 +2041,13 @@ int main(int argc, char **argv) + void *stack; + void *currstk; + size_t stksize; ++ int node_cpu = cpu; ++ ++ if (node_cpu == -1) ++ node_cpu = cpu_for_thread_ua(i, max_cpus); + + /* find the memory node associated with the cpu i */ +- node = rt_numa_numa_node_of_cpu(cpu); ++ node = rt_numa_numa_node_of_cpu(node_cpu); + + /* get the stack size set for this thread */ + if (pthread_attr_getstack(&attr, &currstk, &stksize)) +@@ -2056,7 +2058,7 @@ int main(int argc, char **argv) + stksize = PTHREAD_STACK_MIN * 2; + + /* allocate memory for a stack on appropriate node */ +- stack = rt_numa_numa_alloc_onnode(stksize, node, cpu); ++ stack = rt_numa_numa_alloc_onnode(stksize, node, node_cpu); + + /* touch the stack pages to pre-fault them in */ + memset(stack, 0, stksize); +-- +2.38.1 + diff --git a/0002-rt-tests-Remove-arbitrary-num-of-threads-limits.patch b/0002-rt-tests-Remove-arbitrary-num-of-threads-limits.patch new file mode 100644 index 0000000..46c36df --- /dev/null +++ b/0002-rt-tests-Remove-arbitrary-num-of-threads-limits.patch @@ -0,0 +1,75 @@ +From ce8792449b1284971f1f90b7b2de8fea7153676f Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Thu, 6 Oct 2022 16:00:44 -0400 +Subject: [PATCH 2/4] rt-tests: Remove arbitrary num of threads limits + +Remove the arbitrary limit to the number of threads in pmqtest, +ptsematest, sigwaittest and svsematest. + +Signed-off-by: John Kacur + +[ upstream status: d356a6ae3cbf3cf4ec7fe130bfa4a8e392b910e6 ] + +Signed-off-by: Petr Vorel +--- + src/pmqtest/pmqtest.c | 2 +- + src/ptsematest/ptsematest.c | 2 +- + src/sigwaittest/sigwaittest.c | 2 +- + src/svsematest/svsematest.c | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c +index 6ad0a92..9e14278 100644 +--- a/src/pmqtest/pmqtest.c ++++ b/src/pmqtest/pmqtest.c +@@ -393,7 +393,7 @@ static void process_options(int argc, char *argv[]) + } + } + +- if (num_threads < 0 || num_threads > 255) ++ if (num_threads < 0) + error = 1; + + if (priority < 0 || priority > 99) +diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c +index e000c30..a9d6c69 100644 +--- a/src/ptsematest/ptsematest.c ++++ b/src/ptsematest/ptsematest.c +@@ -299,7 +299,7 @@ static void process_options(int argc, char *argv[]) + } + } + +- if (num_threads < 0 || num_threads > 255) ++ if (num_threads < 0) + error = 1; + + if (priority < 0 || priority > 99) +diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c +index d0d79df..728176a 100644 +--- a/src/sigwaittest/sigwaittest.c ++++ b/src/sigwaittest/sigwaittest.c +@@ -369,7 +369,7 @@ static void process_options(int argc, char *argv[]) + if (duration < 0) + error = 1; + +- if (num_threads < 1 || num_threads > 255) ++ if (num_threads < 1) + error = 1; + + if (priority < 0 || priority > 99) +diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c +index 22ea7bc..243b137 100644 +--- a/src/svsematest/svsematest.c ++++ b/src/svsematest/svsematest.c +@@ -398,7 +398,7 @@ static void process_options(int argc, char *argv[]) + if (duration < 0) + error = 0; + +- if (num_threads < 1 || num_threads > 255) ++ if (num_threads < 1) + error = 1; + + if (priority < 0 || priority > 99) +-- +2.38.1 + diff --git a/0003-rt-tests-hackbench-Add-error-checking-to-connect-and.patch b/0003-rt-tests-hackbench-Add-error-checking-to-connect-and.patch new file mode 100644 index 0000000..6a826ae --- /dev/null +++ b/0003-rt-tests-hackbench-Add-error-checking-to-connect-and.patch @@ -0,0 +1,43 @@ +From 7cd6289fbebfc436e0f157f1fd2731a684b3af95 Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Tue, 1 Nov 2022 09:30:40 -0400 +Subject: [PATCH 3/4] rt-tests: hackbench: Add error checking to connect and + getsockname + +Add error checking around the calls connect and getsockname + +Signed-off-by: John Kacur + +[ upstream status: c7768aae2e6d9e5440a3f4dc62d6e03f05df80f4 ] + +Signed-off-by: Petr Vorel +--- + src/hackbench/hackbench.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c +index 18c9284..8c6d835 100644 +--- a/src/hackbench/hackbench.c ++++ b/src/hackbench/hackbench.c +@@ -130,14 +130,16 @@ static int inet_socketpair(int fds[2]) + + if (bind(s1, &sin, len) < 0) + barf("bind"); +- getsockname(s1, &sin, &len); ++ if (getsockname(s1, &sin, &len) < 0) ++ barf("getsockname"); + if (listen(s1, 10) < 0) + barf("listen"); + if (ioctl(s2, FIONBIO, &ul) < 0) + barf("ioctl"); + if (ioctl(s1, FIONBIO, &ul) < 0) + barf("ioctl"); +- connect(s2, &sin, len); ++ if (connect(s2, &sin, len) < 0) ++ barf("connect"); + if ((fds[0] = accept(s1, &sin, &len)) < 0) + barf("accept"); + ul = 0; +-- +2.38.1 + diff --git a/0004-rt-tests-hwlatdetect-Update-to-integer-division.patch b/0004-rt-tests-hwlatdetect-Update-to-integer-division.patch new file mode 100644 index 0000000..43bb2e7 --- /dev/null +++ b/0004-rt-tests-hwlatdetect-Update-to-integer-division.patch @@ -0,0 +1,41 @@ +From 4d5e69dc656f063e8832a4e3bf6f4734f6e1fbc6 Mon Sep 17 00:00:00 2001 +From: Leah Leshchinsky +Date: Thu, 10 Nov 2022 10:35:27 -0500 +Subject: [PATCH 4/4] rt-tests: hwlatdetect: Update to integer division + +In Python 3, "/" is a float division operator, as opposed to Python 2, +which defaults to integer division. This results in an error when +calculating width, which assumes an integer. + +Update width division to integer division with the "//" operator. + +Signed-off-by: Leah Leshchinsky +Signed-off-by: John Kacur + +[ upstream status: 1eaa7feae3225ae82d00d2e1f02986e34c31a38d ] + +Signed-off-by: Petr Vorel +--- + src/hwlatdetect/hwlatdetect.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py +index 9ef50f8..bef1af2 100755 +--- a/src/hwlatdetect/hwlatdetect.py ++++ b/src/hwlatdetect/hwlatdetect.py +@@ -454,9 +454,10 @@ if __name__ == '__main__': + + if args.window: + w = microseconds(args.window) ++ width = w//2 + if w < int(detect.get("width")): +- debug("shrinking width to %d for new window of %d" % (w/2, w)) +- detect.set("width", w/2) ++ debug("shrinking width to %d for new window of %d" % (width, w)) ++ detect.set("width", width) + debug("window parameter = %d" % w) + detect.set("window", w) + debug("window for sampling set to %dus" % w) +-- +2.38.1 + diff --git a/rt-tests-1.10-Makefile.patch b/rt-tests-1.10-Makefile.patch deleted file mode 100644 index c0ee72c..0000000 --- a/rt-tests-1.10-Makefile.patch +++ /dev/null @@ -1,12 +0,0 @@ -Index: rt-tests-1.10/Makefile -=================================================================== ---- rt-tests-1.10/Makefile -+++ rt-tests-1.10/Makefile -@@ -56,6 +56,7 @@ - src/sched_deadline/deadline_test.8 \ - src/ssdd/ssdd.8 \ - src/sched_deadline/cyclicdeadline.8 \ -+ src/cyclictest/get_cyclictest_snapshot.8 \ - src/oslat/oslat.8 - - ifdef PYLIB diff --git a/rt-tests-2.2.tar.gz b/rt-tests-2.2.tar.gz deleted file mode 100644 index f295c87..0000000 --- a/rt-tests-2.2.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b91d33a2d3a738fb68e928c00653804a172df5b5f76253b997581f45be6c228b -size 164348 diff --git a/rt-tests-2.4.tar.xz b/rt-tests-2.4.tar.xz new file mode 100644 index 0000000..854cb4f --- /dev/null +++ b/rt-tests-2.4.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:393457f0c91cce57e82b876ecb9b672871f898e6cecafc751548079512bcc808 +size 104172 diff --git a/rt-tests.changes b/rt-tests.changes index ce4ca48..0eda281 100644 --- a/rt-tests.changes +++ b/rt-tests.changes @@ -1,3 +1,27 @@ +------------------------------------------------------------------- +Thu Nov 24 09:39:36 UTC 2022 - Petr Vorel + +- Update to upstream version v2.4 + https://lore.kernel.org/linux-rt-users/20220708150017.13462-1-jkacur@redhat.com/ + +- Update to upstream version v2.3 + https://lore.kernel.org/linux-rt-users/20211210184649.11084-1-jkacur@redhat.com/ + +- Remove old patch rt-tests-1.10-Makefile.patch, which installed + src/cyclictest/get_cyclictest_snapshot.8. Upstream guarded it with PYLIB in + 3d1976b ("Makefile: manpages: only add get_cyclictest_snapshot if PYLIB") + but PYLIB should be defined due BuildRequires: python3-base + +- Backport runtime fixes from upcomming release: + * 0001-cyclictest-Fix-threads-being-affined-even-when-a-isn.patch + * 0002-rt-tests-Remove-arbitrary-num-of-threads-limits.patch + * 0003-rt-tests-hackbench-Add-error-checking-to-connect-and.patch + * 0004-rt-tests-hwlatdetect-Update-to-integer-division.patch + +- Use tarball with xz compression instead of gz + +- Use %autosetup (not having to add -p1 for patches) + ------------------------------------------------------------------- Tue Aug 31 08:27:01 UTC 2021 - Daniel Wagner diff --git a/rt-tests.spec b/rt-tests.spec index d145dff..c8ee337 100644 --- a/rt-tests.spec +++ b/rt-tests.spec @@ -1,7 +1,7 @@ # # spec file for package rt-tests # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,14 +17,17 @@ Name: rt-tests -Version: 2.2 +Version: 2.4 Release: 0 Summary: Realtime Kernel Testsuite License: GPL-2.0-only Group: System/Benchmark URL: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git -Source0: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git/snapshot/rt-tests-%{version}.tar.gz -Patch1: rt-tests-1.10-Makefile.patch +Source0: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git/snapshot/rt-tests-%{version}.tar.xz +Patch1: 0001-cyclictest-Fix-threads-being-affined-even-when-a-isn.patch +Patch2: 0002-rt-tests-Remove-arbitrary-num-of-threads-limits.patch +Patch3: 0003-rt-tests-hackbench-Add-error-checking-to-connect-and.patch +Patch4: 0004-rt-tests-hwlatdetect-Update-to-integer-division.patch BuildRequires: libnuma-devel BuildRequires: python-rpm-macros BuildRequires: python3-base @@ -36,8 +39,7 @@ specifically timer and signal latency and the functionality of Priority Inheritance Mutexes. %prep -%setup -q -%patch1 -p1 +%autosetup -p1 %build export CFLAGS="%{optflags}"