Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/rt-tests/, dev-util/rt-tests/files/
Date: Wed, 14 Jul 2021 14:32:56
Message-Id: 1626273161.622b2e8e3fd229118206cec008136d114deb0939.juippis@gentoo
1 commit: 622b2e8e3fd229118206cec008136d114deb0939
2 Author: Kurt Kanzenbach <kurt <AT> kmk-computers <DOT> de>
3 AuthorDate: Sun Jul 4 06:51:37 2021 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 14 14:32:41 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=622b2e8e
7
8 dev-util/rt-tests: Bump to v2.1
9
10 Package-Manager: Portage-3.0.20, Repoman-3.0.2
11 Signed-off-by: Kurt Kanzenbach <kurt <AT> kmk-computers.de>
12 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
13
14 dev-util/rt-tests/Manifest | 1 +
15 dev-util/rt-tests/files/rt-tests-2.1-musl.patch | 352 ++++++++++++++++++++++++
16 dev-util/rt-tests/rt-tests-2.1.ebuild | 38 +++
17 3 files changed, 391 insertions(+)
18
19 diff --git a/dev-util/rt-tests/Manifest b/dev-util/rt-tests/Manifest
20 index c246fed4f7c..aa57879e254 100644
21 --- a/dev-util/rt-tests/Manifest
22 +++ b/dev-util/rt-tests/Manifest
23 @@ -1,2 +1,3 @@
24 DIST rt-tests-1.10.tar.xz 112300 BLAKE2B b38a7357b1402de94661014e71ed9fc48d9dde6cabbe72ed4031841b57f7fb76a01dda03c7888f11d8e5e9c11cda8281dae1b437f0d1ff971d2941547f659103 SHA512 9512419b364746ad490894c7184a391f0e8d571477ad636abff8ed473151c6f2c263475ca4aa7d498e81c18e17e42ae82260693b90bce4ef9889e0eaf0b77b58
25 DIST rt-tests-2.0.tar.xz 114944 BLAKE2B 809224e6d480b098ed398c0646070f18aa25e8947485709ff309c4a2ee289797924e6df39ac2af68b91b2df064642d56bd8f7aa7332764d95d53e7d9a34d4ca7 SHA512 6c582734eb41f7addaac7d0f3dbb313e3af30eb2b662781f6c62dbaf13da2e84f36a6f918f11608406ca2a08636df93375272444a2cdf205e782ec9f4bc45dca
26 +DIST rt-tests-2.1.tar.xz 114892 BLAKE2B 25a382c898ffdbbe7b6c3f69f440b87ca6b88cc634aae06a3e02154954b8b50da46e2f2b3291d7473bb0ae533f5a90a7769433650bab3f7c229a5d3022e32b50 SHA512 7abab6c1191247ac44f4e5193752474756d82fdf1d8a3b69c92c8d37bd4fe8458444d2165894fc8483590809ff5b4f1c755d66afb296e72041f9efbedd048d0d
27
28 diff --git a/dev-util/rt-tests/files/rt-tests-2.1-musl.patch b/dev-util/rt-tests/files/rt-tests-2.1-musl.patch
29 new file mode 100644
30 index 00000000000..caa8d415aad
31 --- /dev/null
32 +++ b/dev-util/rt-tests/files/rt-tests-2.1-musl.patch
33 @@ -0,0 +1,352 @@
34 +From 0b7a1e0d3463aa8aa4b7dcad0ec154e658d68036 Mon Sep 17 00:00:00 2001
35 +From: Kurt Kanzenbach <kurt@×××××××××××××.de>
36 +Date: Wed, 1 Apr 2020 20:15:24 +0200
37 +Subject: [PATCH] all: Fix musl build
38 +
39 +There are a few problems:
40 +
41 + * pi stress: pthread_attr_setaffinity_np() is not supported
42 + * cyclictest: SIGEV_THREAD_ID is not supported
43 + * hackbench: Fix include
44 + * all: Fix sched_* calls
45 +
46 +With these changes applied, the rt-tests seem to run fine.
47 +
48 +Signed-off-by: Kurt Kanzenbach <kurt@×××××××××××××.de>
49 +---
50 + Makefile | 5 --
51 + src/backfire/sendme.c | 1
52 + src/cyclictest/cyclictest.c | 70 ++++------------------------------
53 + src/hackbench/hackbench.c | 4 +
54 + src/include/musl.h | 28 +++++++++++++
55 + src/lib/rt-utils.c | 1
56 + src/pi_tests/classic_pi.c | 2
57 + src/pi_tests/tst-mutexpi10.c | 2
58 + src/pmqtest/pmqtest.c | 1
59 + src/ptsematest/ptsematest.c | 1
60 + src/rt-migrate-test/rt-migrate-test.c | 1
61 + src/sched_deadline/cyclicdeadline.c | 1
62 + 12 files changed, 50 insertions(+), 67 deletions(-)
63 + create mode 100644 src/include/musl.h
64 +
65 +--- a/Makefile
66 ++++ b/Makefile
67 +@@ -7,7 +7,6 @@ OBJDIR = bld
68 + sources = cyclictest.c \
69 + hackbench.c \
70 + pip_stress.c \
71 +- pi_stress.c \
72 + pmqtest.c \
73 + ptsematest.c \
74 + rt-migrate-test.c \
75 +@@ -42,7 +41,6 @@ ifeq (${PYLIB},)
76 + endif
77 +
78 + MANPAGES = src/cyclictest/cyclictest.8 \
79 +- src/pi_tests/pi_stress.8 \
80 + src/ptsematest/ptsematest.8 \
81 + src/rt-migrate-test/rt-migrate-test.8 \
82 + src/sigwaittest/sigwaittest.8 \
83 +@@ -130,9 +128,6 @@ deadline_test: $(OBJDIR)/deadline_test.o
84 + signaltest: $(OBJDIR)/signaltest.o $(OBJDIR)/librttest.a $(OBJDIR)/librttestnuma.a
85 + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB) $(RTTESTNUMA)
86 +
87 +-pi_stress: $(OBJDIR)/pi_stress.o $(OBJDIR)/librttest.a
88 +- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(RTTESTLIB)
89 +-
90 + hwlatdetect: src/hwlatdetect/hwlatdetect.py
91 + chmod +x src/hwlatdetect/hwlatdetect.py
92 + ln -s src/hwlatdetect/hwlatdetect.py hwlatdetect
93 +--- a/src/backfire/sendme.c
94 ++++ b/src/backfire/sendme.c
95 +@@ -29,6 +29,7 @@
96 + #include <string.h>
97 + #include <time.h>
98 + #include <errno.h>
99 ++#include "musl.h"
100 + #include "rt-utils.h"
101 + #include "rt-get_cpu.h"
102 +
103 +--- a/src/cyclictest/cyclictest.c
104 ++++ b/src/cyclictest/cyclictest.c
105 +@@ -33,6 +33,7 @@
106 + #include <sys/utsname.h>
107 + #include <sys/mman.h>
108 + #include <sys/syscall.h>
109 ++#include "musl.h"
110 + #include "rt_numa.h"
111 +
112 + #include "rt-utils.h"
113 +@@ -502,12 +503,8 @@ static void *timerthread(void *param)
114 + {
115 + struct thread_param *par = param;
116 + struct sched_param schedp;
117 +- struct sigevent sigev;
118 + sigset_t sigset;
119 +- timer_t timer;
120 + struct timespec now, next, interval, stop;
121 +- struct itimerval itimer;
122 +- struct itimerspec tspec;
123 + struct thread_stat *stat = par->stats;
124 + int stopped = 0;
125 + cpu_set_t mask;
126 +@@ -538,14 +535,6 @@ static void *timerthread(void *param)
127 + sigaddset(&sigset, par->signal);
128 + sigprocmask(SIG_BLOCK, &sigset, NULL);
129 +
130 +- if (par->mode == MODE_CYCLIC) {
131 +- sigev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL;
132 +- sigev.sigev_signo = par->signal;
133 +- sigev.sigev_notify_thread_id = stat->tid;
134 +- timer_create(par->clock, &sigev, &timer);
135 +- tspec.it_interval = interval;
136 +- }
137 +-
138 + memset(&schedp, 0, sizeof(schedp));
139 + schedp.sched_priority = par->prio;
140 + if (setscheduler(0, par->policy, &schedp))
141 +@@ -600,20 +589,6 @@ static void *timerthread(void *param)
142 + stop = now;
143 + stop.tv_sec += duration;
144 + }
145 +- if (par->mode == MODE_CYCLIC) {
146 +- if (par->timermode == TIMER_ABSTIME)
147 +- tspec.it_value = next;
148 +- else
149 +- tspec.it_value = interval;
150 +- timer_settime(timer, par->timermode, &tspec, NULL);
151 +- }
152 +-
153 +- if (par->mode == MODE_SYS_ITIMER) {
154 +- itimer.it_interval.tv_sec = interval.tv_sec;
155 +- itimer.it_interval.tv_usec = interval.tv_nsec / 1000;
156 +- itimer.it_value = itimer.it_interval;
157 +- setitimer(ITIMER_REAL, &itimer, NULL);
158 +- }
159 +
160 + stat->threadstarted++;
161 +
162 +@@ -621,16 +596,10 @@ static void *timerthread(void *param)
163 +
164 + uint64_t diff;
165 + unsigned long diff_smi = 0;
166 +- int sigs, ret;
167 ++ int ret;
168 +
169 + /* Wait for next period */
170 + switch (par->mode) {
171 +- case MODE_CYCLIC:
172 +- case MODE_SYS_ITIMER:
173 +- if (sigwait(&sigset, &sigs) < 0)
174 +- goto out;
175 +- break;
176 +-
177 + case MODE_CLOCK_NANOSLEEP:
178 + if (par->timermode == TIMER_ABSTIME) {
179 + ret = clock_nanosleep(par->clock, TIMER_ABSTIME,
180 +@@ -751,11 +720,6 @@ static void *timerthread(void *param)
181 +
182 + next.tv_sec += interval.tv_sec;
183 + next.tv_nsec += interval.tv_nsec;
184 +- if (par->mode == MODE_CYCLIC) {
185 +- int overrun_count = timer_getoverrun(timer);
186 +- next.tv_sec += overrun_count * interval.tv_sec;
187 +- next.tv_nsec += overrun_count * interval.tv_nsec;
188 +- }
189 + tsnorm(&next);
190 +
191 + while (tsgreater(&now, &next)) {
192 +@@ -780,17 +744,6 @@ out:
193 + pthread_mutex_unlock(&refresh_on_max_lock);
194 + }
195 +
196 +- if (par->mode == MODE_CYCLIC)
197 +- timer_delete(timer);
198 +-
199 +- if (par->mode == MODE_SYS_ITIMER) {
200 +- itimer.it_value.tv_sec = 0;
201 +- itimer.it_value.tv_usec = 0;
202 +- itimer.it_interval.tv_sec = 0;
203 +- itimer.it_interval.tv_usec = 0;
204 +- setitimer(ITIMER_REAL, &itimer, NULL);
205 +- }
206 +-
207 + /* close msr file */
208 + if (smi)
209 + close(par->msr_fd);
210 +@@ -1174,7 +1127,8 @@ static void process_options(int argc, ch
211 + case OPT_VERBOSE: verbose = 1; break;
212 + case 'x':
213 + case OPT_POSIX_TIMERS:
214 +- use_nanosleep = MODE_CYCLIC; break;
215 ++ fatal("--posix_timers is not available on your libc\n");
216 ++ break;
217 + case '?':
218 + case OPT_HELP:
219 + display_help(0); break;
220 +@@ -1207,13 +1161,6 @@ static void process_options(int argc, ch
221 + }
222 + }
223 +
224 +- if ((use_system == MODE_SYS_OFFSET) && (use_nanosleep == MODE_CYCLIC)) {
225 +- warn("The system option requires clock_nanosleep\n");
226 +- warn("and is not compatible with posix_timers\n");
227 +- warn("Using clock_nanosleep\n");
228 +- use_nanosleep = MODE_CLOCK_NANOSLEEP;
229 +- }
230 +-
231 + /* if smp wasn't requested, test for numa automatically */
232 + if (!smp) {
233 + numa = numa_initialize();
234 +@@ -1943,7 +1890,6 @@ int main(int argc, char **argv)
235 +
236 + }
237 +
238 +-
239 + mode = use_nanosleep + use_system;
240 +
241 + sigemptyset(&sigset);
242 +@@ -1993,16 +1939,18 @@ int main(int argc, char **argv)
243 + void *stack;
244 + void *currstk;
245 + size_t stksize;
246 ++ int err;
247 +
248 + /* find the memory node associated with the cpu i */
249 + node = rt_numa_numa_node_of_cpu(cpu);
250 +
251 +- /* get the stack size set for this thread */
252 +- if (pthread_attr_getstack(&attr, &currstk, &stksize))
253 ++ /* get the stack size set for for this thread */
254 ++ err = pthread_attr_getstack(&attr, &currstk, &stksize);
255 ++ if (err != EINVAL)
256 + fatal("failed to get stack size for thread %d\n", i);
257 +
258 + /* if the stack size is zero, set a default */
259 +- if (stksize == 0)
260 ++ if (err == EINVAL || stksize == 0)
261 + stksize = PTHREAD_STACK_MIN * 2;
262 +
263 + /* allocate memory for a stack on appropriate node */
264 +--- a/src/hackbench/hackbench.c
265 ++++ b/src/hackbench/hackbench.c
266 +@@ -24,13 +24,15 @@
267 + #include <sys/socket.h>
268 + #include <sys/wait.h>
269 + #include <sys/time.h>
270 +-#include <sys/poll.h>
271 ++#include <poll.h>
272 + #include <limits.h>
273 + #include <getopt.h>
274 + #include <signal.h>
275 + #include <setjmp.h>
276 + #include <sched.h>
277 +
278 ++#include "musl.h"
279 ++
280 + static unsigned int datasize = 100;
281 + static unsigned int loops = 100;
282 + static unsigned int num_groups = 10;
283 +--- /dev/null
284 ++++ b/src/include/musl.h
285 +@@ -0,0 +1,28 @@
286 ++/*
287 ++ * Copyright (C) 2020 Kurt Kanzenbach <kurt@×××××××××××××.de>
288 ++ * Time-stamp: <2020-04-04 10:54:01 kurt>
289 ++ */
290 ++
291 ++#ifndef _MUSL_H_
292 ++#define _MUSL_H_
293 ++
294 ++#include <unistd.h>
295 ++#include <sys/syscall.h>
296 ++
297 ++/*
298 ++ * Musl someshow defines sched_* to ENOSYS which is not correct ...
299 ++ * See commit 1e21e78bf7a5 ("add support for thread scheduling (POSIX TPS option)")
300 ++ *
301 ++ * Workaround: define them to syscall(...)
302 ++ */
303 ++
304 ++#define sched_getparam(pid, param) \
305 ++ syscall(SYS_sched_getparam, pid, param)
306 ++#define sched_setparam(pid, param) \
307 ++ syscall(SYS_sched_setparam, pid, param)
308 ++#define sched_getscheduler(pid) \
309 ++ syscall(SYS_sched_getscheduler, pid)
310 ++#define sched_setscheduler(pid, policy, param) \
311 ++ syscall(SYS_sched_setscheduler, pid, policy, param)
312 ++
313 ++#endif /* _MUSL_H_ */
314 +--- a/src/lib/rt-utils.c
315 ++++ b/src/lib/rt-utils.c
316 +@@ -24,6 +24,7 @@
317 + #include <time.h>
318 + #include <sys/time.h>
319 +
320 ++#include "musl.h"
321 + #include "rt-utils.h"
322 + #include "rt-sched.h"
323 + #include "rt-error.h"
324 +--- a/src/pi_tests/classic_pi.c
325 ++++ b/src/pi_tests/classic_pi.c
326 +@@ -34,6 +34,8 @@
327 + #include <signal.h>
328 + #include <getopt.h>
329 +
330 ++#include "musl.h"
331 ++
332 + /* test timeout */
333 + #define TIMEOUT 2
334 +
335 +--- a/src/pi_tests/tst-mutexpi10.c
336 ++++ b/src/pi_tests/tst-mutexpi10.c
337 +@@ -35,6 +35,8 @@
338 + #include <string.h>
339 + #include <signal.h>
340 +
341 ++#include "musl.h"
342 ++
343 + /* test timeout */
344 + #define TIMEOUT 2
345 +
346 +--- a/src/pmqtest/pmqtest.c
347 ++++ b/src/pmqtest/pmqtest.c
348 +@@ -24,6 +24,7 @@
349 + #include <pthread.h>
350 + #include <inttypes.h>
351 +
352 ++#include "musl.h"
353 + #include "rt-utils.h"
354 + #include "rt-get_cpu.h"
355 + #include "rt-error.h"
356 +--- a/src/ptsematest/ptsematest.c
357 ++++ b/src/ptsematest/ptsematest.c
358 +@@ -22,6 +22,7 @@
359 + #include <pthread.h>
360 + #include <inttypes.h>
361 +
362 ++#include "musl.h"
363 + #include "rt-utils.h"
364 + #include "rt-get_cpu.h"
365 + #include "rt-error.h"
366 +--- a/src/rt-migrate-test/rt-migrate-test.c
367 ++++ b/src/rt-migrate-test/rt-migrate-test.c
368 +@@ -27,6 +27,7 @@
369 +
370 + #include <linux/unistd.h>
371 +
372 ++#include "musl.h"
373 + #include "rt-utils.h"
374 +
375 + int nr_tasks;
376 +--- a/src/sched_deadline/cyclicdeadline.c
377 ++++ b/src/sched_deadline/cyclicdeadline.c
378 +@@ -30,6 +30,7 @@
379 + #include <linux/unistd.h>
380 + #include <linux/magic.h>
381 +
382 ++#include "musl.h"
383 + #include "rt-utils.h"
384 + #include "rt-sched.h"
385 + #include "rt-error.h"
386
387 diff --git a/dev-util/rt-tests/rt-tests-2.1.ebuild b/dev-util/rt-tests/rt-tests-2.1.ebuild
388 new file mode 100644
389 index 00000000000..8f2df0599b2
390 --- /dev/null
391 +++ b/dev-util/rt-tests/rt-tests-2.1.ebuild
392 @@ -0,0 +1,38 @@
393 +# Copyright 1999-2021 Gentoo Authors
394 +# Distributed under the terms of the GNU General Public License v2
395 +
396 +EAPI=7
397 +
398 +PYTHON_COMPAT=( python3_{7..10} )
399 +
400 +inherit python-single-r1 toolchain-funcs
401 +
402 +DESCRIPTION="A collection of latency testing tools for the linux(-rt) kernel"
403 +HOMEPAGE="https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git/about/"
404 +SRC_URI="
405 + https://kernel.org/pub/linux/utils/rt-tests/${P}.tar.xz
406 + https://kernel.org/pub/linux/utils/rt-tests/older/${P}.tar.xz"
407 +
408 +LICENSE="GPL-2 GPL-2+ LGPL-2.1+"
409 +SLOT="0"
410 +KEYWORDS="~amd64 ~arm64 ~x86"
411 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
412 +
413 +DEPEND="${PYTHON_DEPS}
414 + sys-process/numactl"
415 +RDEPEND="${DEPEND}"
416 +
417 +src_prepare() {
418 + default
419 + use elibc_musl && eapply "${FILESDIR}/${P}-musl.patch"
420 +}
421 +
422 +src_compile() {
423 + emake CC="$(tc-getCC)" AR="$(tc-getAR)"
424 +}
425 +
426 +src_install() {
427 + emake prefix=/usr DESTDIR="${ED}" install
428 + python_fix_shebang "${ED}"
429 + python_optimize
430 +}