Gentoo Archives: gentoo-commits

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