Import from AlmaLinux stable repository

This commit is contained in:
eabdullin 2024-05-15 08:49:39 +00:00
parent fca0f77d7f
commit f22a70d6e9
15 changed files with 1681 additions and 5 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/rt-tests-2.5.tar.xz
SOURCES/rt-tests-2.6.tar.xz

View File

@ -1 +1 @@
0b4143fef6905a83f68b2a53a007708a666a02ec SOURCES/rt-tests-2.5.tar.xz
60ea229d1335bab6025d1c9435e2e96856286fe4 SOURCES/rt-tests-2.6.tar.xz

View File

@ -0,0 +1,306 @@
From cf75a53807ae85cca05f08efc00c28b44beeff9a Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Fri, 27 Oct 2023 14:57:46 -0400
Subject: [PATCH 2/3] rt-tests: Add missing SPDX licenses
Add missing SPDX licenses
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 1 +
src/backfire/backfire.4 | 1 +
src/backfire/sendme.8 | 1 +
src/backfire/sendme.c | 15 +--------------
src/cyclictest/cyclictest.8 | 1 +
src/cyclictest/get_cyclictest_snapshot.8 | 1 +
src/hackbench/hackbench.8 | 1 +
src/hwlatdetect/hwlatdetect.8 | 1 +
src/oslat/oslat.8 | 1 +
src/pi_tests/pi_stress.8 | 1 +
src/pi_tests/pip_stress.8 | 1 +
src/pmqtest/pmqtest.8 | 1 +
src/ptsematest/ptsematest.8 | 1 +
src/queuelat/determine_maximum_mpps.8 | 1 +
src/queuelat/queuelat.8 | 1 +
src/queuelat/targeted-ipi/Kbuild | 1 +
src/queuelat/targeted-ipi/Makefile | 1 +
src/rt-migrate-test/rt-migrate-test.8 | 1 +
src/sched_deadline/cyclicdeadline.8 | 1 +
src/sched_deadline/deadline_test.8 | 1 +
src/signaltest/signaltest.8 | 1 +
src/sigwaittest/sigwaittest.8 | 1 +
src/ssdd/ssdd.8 | 1 +
src/svsematest/svsematest.8 | 1 +
25 files changed, 25 insertions(+), 14 deletions(-)
+# SPDX-License-Identifier: GPL-2.0-or-later
*~
.*
*.o
diff --git a/Makefile b/Makefile
index 8d3268d19901..2808c212058a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
VERSION = 2.6
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
diff --git a/src/backfire/backfire.4 b/src/backfire/backfire.4
index 66dccd1dd1f0..1057a432eefb 100644
--- a/src/backfire/backfire.4
+++ b/src/backfire/backfire.4
@@ -1,4 +1,5 @@
.TH "backfire" "4" "0.1" "" "Driver"
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH "NAME"
.LP
backfire \- send a signal from driver to user
diff --git a/src/backfire/sendme.8 b/src/backfire/sendme.8
index 05f3a1c14d8b..9c973607f859 100644
--- a/src/backfire/sendme.8
+++ b/src/backfire/sendme.8
@@ -1,4 +1,5 @@
.TH "sendme" "8" "0.2" "" ""
+# SPDX-License-Identifier: GPL-2.0-only
.SH "NAME"
.LP
\fBsendme\fR \- Send a signal from driver to user and measure time intervals
diff --git a/src/backfire/sendme.c b/src/backfire/sendme.c
index d963723b1c93..da10397846f7 100644
--- a/src/backfire/sendme.c
+++ b/src/backfire/sendme.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
/*
* sendme.c
*
* Copyright (C) 2009 Carsten Emde <C.Emde@osadl.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
- * USA.
*/
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index 1cc72e64effc..2ccdfc1ff5fa 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH CYCLICTEST 8 "April 22, 2016"
+# SPDX-License-Identifier: GPL-2.0-only
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/cyclictest/get_cyclictest_snapshot.8 b/src/cyclictest/get_cyclictest_snapshot.8
index e9251a8e821f..45eb90da070c 100644
--- a/src/cyclictest/get_cyclictest_snapshot.8
+++ b/src/cyclictest/get_cyclictest_snapshot.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH GET_CYCLICTEST_SNAPSHOT 8 "July 6, 2020"
+# SPDX-License-Identifier: GPL-2.0-or-later
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/hackbench/hackbench.8 b/src/hackbench/hackbench.8
index 4c2c8ad9cb1a..1f3ecd51cc07 100644
--- a/src/hackbench/hackbench.8
+++ b/src/hackbench/hackbench.8
@@ -1,4 +1,5 @@
.TH "hackbench" "8" "September 19, 2020" "" ""
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH "NAME"
hackbench \- scheduler benchmark/stress test
.SH "SYNOPSIS"
diff --git a/src/hwlatdetect/hwlatdetect.8 b/src/hwlatdetect/hwlatdetect.8
index 21d0fe4aaca2..560ff7cc0cc9 100644
--- a/src/hwlatdetect/hwlatdetect.8
+++ b/src/hwlatdetect/hwlatdetect.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH HWLATDETECT 8 "May 12, 2009"
+# SPDX-License-Identifier: GPL-2.0-only
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/oslat/oslat.8 b/src/oslat/oslat.8
index eb96448bfff1..fba10ab4944d 100644
--- a/src/oslat/oslat.8
+++ b/src/oslat/oslat.8
@@ -1,4 +1,5 @@
.TH OSLAT 8 "August 17, 2020"
+# SPDX-License-Identifier: GPL-3.0-only
.\" for manpage-specific macros, see man(7)
.SH NAME
oslat \- OS Latency Detector
diff --git a/src/pi_tests/pi_stress.8 b/src/pi_tests/pi_stress.8
index 8c43a1ccf676..6ae28c178d75 100644
--- a/src/pi_tests/pi_stress.8
+++ b/src/pi_tests/pi_stress.8
@@ -4,6 +4,7 @@
.\"{{{}}}
.\"{{{ Title
.TH pi_stress 8 "Nov 27, 2006" "" "Linux System Administrator's Manual"
+# SPDX-License-Identifier: GPL-2.0-or-later
.\"}}}
.\"{{{ Name
.SH NAME
diff --git a/src/pi_tests/pip_stress.8 b/src/pi_tests/pip_stress.8
index 1808330b2e17..0d06dd2215f8 100644
--- a/src/pi_tests/pip_stress.8
+++ b/src/pi_tests/pip_stress.8
@@ -1,5 +1,6 @@
.\"
.TH PIP\ STRESS 8 "September 17, 2018"
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH NAME
.B pip_stress \- Priority Inheritance with processes
.SH SYNOPSIS
diff --git a/src/pmqtest/pmqtest.8 b/src/pmqtest/pmqtest.8
index 4fbcc5c27ce2..cce43d9b5ee5 100644
--- a/src/pmqtest/pmqtest.8
+++ b/src/pmqtest/pmqtest.8
@@ -1,4 +1,5 @@
.TH "pmqtest" "8" "0.1" "" ""
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH "NAME"
.LP
\fBpmqtest\fR \- Start pairs of threads and measure the latency of interprocess communication with POSIX messages queues
diff --git a/src/ptsematest/ptsematest.8 b/src/ptsematest/ptsematest.8
index 57e1658612c0..5e944d353ec0 100644
--- a/src/ptsematest/ptsematest.8
+++ b/src/ptsematest/ptsematest.8
@@ -1,4 +1,5 @@
.TH "ptsematest" "8" "0.1" "" ""
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH "NAME"
.LP
\fBptsematest\fR \- Start two threads and measure the latency of interprocess communication with POSIX mutex.
diff --git a/src/queuelat/determine_maximum_mpps.8 b/src/queuelat/determine_maximum_mpps.8
index c48a651160d3..ba2cc2ad9c2a 100644
--- a/src/queuelat/determine_maximum_mpps.8
+++ b/src/queuelat/determine_maximum_mpps.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH DETERMINE_MAXIMUM_MPPS 8 "Dec 4, 2020"
+# SPDX-License-Identifier: GPL-2.0-or-later
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/queuelat/queuelat.8 b/src/queuelat/queuelat.8
index 2f99e703c990..aa497e93f738 100644
--- a/src/queuelat/queuelat.8
+++ b/src/queuelat/queuelat.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH QUEUELAT 8 "Sept 3, 2018"
+# SPDX-License-Identifier: GPL-2.0-or-later
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/queuelat/targeted-ipi/Kbuild b/src/queuelat/targeted-ipi/Kbuild
index 9bdd5c63a00a..6d569c38aab8 100644
--- a/src/queuelat/targeted-ipi/Kbuild
+++ b/src/queuelat/targeted-ipi/Kbuild
@@ -1,2 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
obj-m := targeted-ipi.o
diff --git a/src/queuelat/targeted-ipi/Makefile b/src/queuelat/targeted-ipi/Makefile
index ee5591fe45c0..9dabd7c22fe0 100644
--- a/src/queuelat/targeted-ipi/Makefile
+++ b/src/queuelat/targeted-ipi/Makefile
@@ -1 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
obj-$(CONFIG_TARGETED_IPI) += targeted-ipi.o
diff --git a/src/rt-migrate-test/rt-migrate-test.8 b/src/rt-migrate-test/rt-migrate-test.8
index 53670e3757fa..88daec50138c 100644
--- a/src/rt-migrate-test/rt-migrate-test.8
+++ b/src/rt-migrate-test/rt-migrate-test.8
@@ -1,5 +1,6 @@
.\"
.TH RT-MIGRATE-TEST 8 "September 18, 2020"
+# SPDX-License-Identifier: GPL-2.0-only
.\" Please adjust this date whenever editing this manpage
.SH NAME
rt-migrate-test \- real-time task migration program
diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
index fab301edc86a..bfc6327c51da 100644
--- a/src/sched_deadline/cyclicdeadline.8
+++ b/src/sched_deadline/cyclicdeadline.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH CYCLICDEADLINE 8 "January 16, 2020"
+# SPDX-License-Identifier: GPL-2.0-only
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/sched_deadline/deadline_test.8 b/src/sched_deadline/deadline_test.8
index 8f32c5b6feb6..0d7932250e23 100644
--- a/src/sched_deadline/deadline_test.8
+++ b/src/sched_deadline/deadline_test.8
@@ -1,5 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.TH DEADLINE_TEST 8 "November 1, 2018"
+# SPDX-License-Identifier: GPL-2.0-only
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
diff --git a/src/signaltest/signaltest.8 b/src/signaltest/signaltest.8
index da818ecdef67..a8c9a6e91c68 100644
--- a/src/signaltest/signaltest.8
+++ b/src/signaltest/signaltest.8
@@ -1,5 +1,6 @@
.\"
.TH SIGNALTEST 8 "November 15, 2020"
+# SPDX-License-Identifier: GPL-2.0-only
.\" Please adjust this date whenever updating this manpage
.SH NAME
signaltest \- signal roundtrip test software
diff --git a/src/sigwaittest/sigwaittest.8 b/src/sigwaittest/sigwaittest.8
index 26ad333e2841..f0ecbb6448b1 100644
--- a/src/sigwaittest/sigwaittest.8
+++ b/src/sigwaittest/sigwaittest.8
@@ -1,4 +1,5 @@
.TH "sigwaittest" "8" "0.1" "" ""
+# SPDX-License-Identifier: GPL-2.0-only
.SH "NAME"
.LP
\fBsigwaittest\fR \- Start two threads or fork two processes and measure the latency between sending and receiving a signal
diff --git a/src/ssdd/ssdd.8 b/src/ssdd/ssdd.8
index a3b9d790dec4..e6be5ef6a27d 100644
--- a/src/ssdd/ssdd.8
+++ b/src/ssdd/ssdd.8
@@ -1,4 +1,5 @@
.TH SSDD 8 "September 19, 2020"
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH NAME
ssdd \- have a tracer do a bunch of PTRACE_SINGLESTEPs
.SH SYNOPSIS
diff --git a/src/svsematest/svsematest.8 b/src/svsematest/svsematest.8
index 93abf55f3d4d..7865ed0550e9 100644
--- a/src/svsematest/svsematest.8
+++ b/src/svsematest/svsematest.8
@@ -1,4 +1,5 @@
.TH "svsematest" "8" "0.1" "" ""
+# SPDX-License-Identifier: GPL-2.0-or-later
.SH "NAME"
.LP
\fBsvsematest\fR \- Start two threads or fork two processes and measure the latency of SYSV semaphores
--
2.41.0

View File

@ -0,0 +1,170 @@
From d13b57f72f0c8b8e058f9aa4322641d5c15a2618 Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Wed, 6 Dec 2023 14:55:05 -0600
Subject: [PATCH] rt-tests: Fix warnings
Numerous places threw sign comparison warnings; we could fix them but
it's kind of an obnoxious warning that requires casts to deal with things
such as ARRAY_SIZE() while still being able to check for the user
entering a negative number.
-Wunused-parameter is another obnoxious warning as it flags perfectly
reasonable code that takes unneeded parameters in order to comply with
a function pointer interface or similar; however, all of the instances
that were flagged here were actual dead parameters, so just fix them.
Add volatile to timer_started in hackbench so that it doesn't get
clobbered by longjmp().
Signed-off-by: Crystal Wood <crwood@redhat.com>
--
Let me know if you'd rather I fix the sign warnings.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 2 +-
src/hackbench/hackbench.c | 2 +-
src/sched_deadline/cyclicdeadline.c | 6 +++---
src/sched_deadline/deadline_test.c | 10 +++++-----
src/sigwaittest/sigwaittest.c | 6 +++---
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index 2808c212058a..ad481a73cf93 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ prefix ?= /usr/local
bindir ?= $(prefix)/bin
mandir ?= $(prefix)/share/man
-CFLAGS ?= -Wall -Wno-nonnull -Wextra
+CFLAGS ?= -Wall -Wno-nonnull -Wextra -Wno-sign-compare
CPPFLAGS += -D_GNU_SOURCE -Isrc/include
LDFLAGS ?=
diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c
index 69dd5f087fb6..4430db0e4ed6 100644
--- a/src/hackbench/hackbench.c
+++ b/src/hackbench/hackbench.c
@@ -494,7 +494,7 @@ int main(int argc, char *argv[])
struct timeval start, stop, diff;
int readyfds[2], wakefds[2];
char dummy;
- int timer_started = 0;
+ volatile int timer_started = 0;
struct sched_param sp;
process_options (argc, argv);
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 9bdc4b5deaf1..097e2e5d4580 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -750,7 +750,7 @@ static void print_stat(FILE *fp, struct sched_data *sd, int index, int verbose,
}
}
-static u64 do_runtime(long tid, struct sched_data *sd, u64 period)
+static u64 do_runtime(struct sched_data *sd, u64 period)
{
struct thread_stat *stat = &sd->stat;
u64 next_period = period + sd->deadline_us;
@@ -833,7 +833,7 @@ void *run_deadline(void *data)
period = get_time_us();
while (!shutdown) {
- period = do_runtime(tid, sd, period);
+ period = do_runtime(sd, period);
if (tracelimit && (stat->max > tracelimit)) {
shutdown++;
pthread_mutex_lock(&break_thread_id_lock);
@@ -1266,7 +1266,7 @@ int main(int argc, char **argv)
/* Make sure that we can make our deadlines */
start_period = get_time_us();
- do_runtime(gettid(), sd, start_period);
+ do_runtime(sd, start_period);
end_period = get_time_us();
if (end_period - start_period > sd->runtime_us)
fatal("Failed to perform task within runtime: Missed by %lld us\n",
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
index cd8ef01f7d68..ca2da476ec95 100644
--- a/src/sched_deadline/deadline_test.c
+++ b/src/sched_deadline/deadline_test.c
@@ -1181,7 +1181,7 @@ static int read_ctx_switches(int *vol, int *nonvol, int *migrate)
* @data->total_time - Total time it took to complete all loops
* @data->nr_periods - Number of periods that were executed.
*/
-static u64 do_runtime(long tid, struct sched_data *data, u64 period)
+static u64 do_runtime(struct sched_data *data, u64 period)
{
u64 next_period = period + data->deadline_us;
u64 now = get_time_us();
@@ -1354,7 +1354,7 @@ void *run_deadline(void *data)
period = get_time_us();
while (!done) {
- period = do_runtime(tid, sched_data, period);
+ period = do_runtime(sched_data, period);
sched_yield();
}
ret = sched_getattr(0, &attr, sizeof(attr), 0);
@@ -1714,7 +1714,7 @@ static u64 calculate_loops_per_ms(u64 *overhead)
do_sleep(1000);
start = get_time_us();
- do_runtime(0, &sd, start + sd.deadline_us);
+ do_runtime(&sd, start + sd.deadline_us);
end = get_time_us();
diff = end - start;
@@ -1743,7 +1743,7 @@ static u64 calculate_loops_per_ms(u64 *overhead)
do_sleep(1000);
start = get_time_us();
- do_runtime(0, &sd, start + sd.deadline_us);
+ do_runtime(&sd, start + sd.deadline_us);
end = get_time_us();
odiff = end - start;
@@ -1962,7 +1962,7 @@ int main(int argc, char **argv)
/* Make sure that we can make our deadlines */
start_period = get_time_us();
- do_runtime(gettid(), sd, start_period);
+ do_runtime(sd, start_period);
end_period = get_time_us();
if (end_period - start_period > sd->runtime_us) {
printf("Failed to perform task within runtime: Missed by %lld us\n",
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index 55855769c63b..8c1c16fb3081 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -375,7 +375,7 @@ static void sighand(int sig __attribute__ ((unused)))
mustshutdown = 1;
}
-static void print_stat(FILE *fp, struct params *receiver, struct params *sender,
+static void print_stat(struct params *receiver, struct params *sender,
int verbose __attribute__ ((unused)), int quiet)
{
int i;
@@ -644,7 +644,7 @@ int main(int argc, char *argv[])
sender[i].shutdown;
if (receiver[0].samples > oldsamples || mustshutdown) {
- print_stat(stdout, receiver, sender, 0, quiet);
+ print_stat(receiver, sender, 0, quiet);
if (!quiet)
printf("\033[%dA", num_threads*2);
}
@@ -664,7 +664,7 @@ int main(int argc, char *argv[])
if (!quiet)
printf("\033[%dB", num_threads*2 + 2);
else
- print_stat(stdout, receiver, sender, 0, 0);
+ print_stat(receiver, sender, 0, 0);
for (i = 0; i < num_threads; i++) {
receiver[i].shutdown = 1;
--
2.43.0

View File

@ -0,0 +1,37 @@
From 57f8f11fbab520b5cb239451c841f951a994328a Mon Sep 17 00:00:00 2001
From: Mathias Krause <minipli@grsecurity.net>
Date: Thu, 19 Oct 2023 08:53:28 +0200
Subject: [PATCH 1/3] rt-tests: Makefile: Restore support for Exuberant Ctags
Commit 974241c78a6f ("rt-tests: Makefile: ctags: Change obsolete extra
to extras") is Universal Ctags specific and broke Exuberant Ctags.
Restore support for Exuberant Ctags by automatically detecting which
variant to use.
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 223a839151ec..8d3268d19901 100644
--- a/Makefile
+++ b/Makefile
@@ -251,6 +251,11 @@ help:
@echo " tarball : make a rt-tests tarball suitable for release"
@echo " help : print this message"
+# Universal Ctags warns about the backward compatible option '--extra' and
+# wants it to be called '--extras'.
+CTAGS_BIN = ctags
+CTAGS_EXTRA := $(shell $(CTAGS_BIN) --version 2>&1 | grep -iq universal && echo extras || echo extra)
+
.PHONY: tags
tags:
- ctags -R --extras=+f --c-kinds=+p --exclude=tmp --exclude=BUILD *
+ $(CTAGS_BIN) -R --$(CTAGS_EXTRA)=+f --c-kinds=+p --exclude=tmp --exclude=BUILD *
--
2.41.0

View File

@ -0,0 +1,57 @@
From 3cbd2fc69160f5c21b66445279fcb31c22e29915 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Fri, 27 Oct 2023 15:22:30 -0400
Subject: [PATCH 3/3] rt-tests: Remove remaining unnecessary texts after adding
SPDX licenses
Remove remaining unnecessary texts after adding SPDX licenses
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/signaltest/signaltest.c | 4 ----
src/sigwaittest/sigwaittest.c | 14 --------------
2 files changed, 18 deletions(-)
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 4737c253b1af..5412c50f7e17 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -5,10 +5,6 @@
*
* (C) 2007 Thomas Gleixner <tglx@linutronix.de>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License Version
- * 2 as published by the Free Software Foundation;
- *
*/
#include <fcntl.h>
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index 818e3a8e680a..55855769c63b 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -5,20 +5,6 @@
*
* Copyright (C) 2009 Carsten Emde <C.Emde@osadl.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
- * USA.
*/
#include <stdio.h>
--
2.41.0

View File

@ -0,0 +1,254 @@
From dba4231b17f3515c0278938d571a53a5dfa925d7 Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Mon, 18 Dec 2023 21:37:50 -0600
Subject: [PATCH 3/3] rt-tests: cyclicdeadline: Add histogram support
Add support for the --histogram and --histfile options as in cyclictest.
The short -h option is not supported, as cyclicdeadline already uses that
for help. -H/--histofall is not supported but could be easily added.
Signed-off-by: Crystal Wood <crwood@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/sched_deadline/cyclicdeadline.c | 114 +++++++++++++++++++++++++---
1 file changed, 104 insertions(+), 10 deletions(-)
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 9bdc4b5deaf1..d84da732a991 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -33,6 +33,7 @@
#include "rt-utils.h"
#include "rt-sched.h"
#include "rt-error.h"
+#include "histogram.h"
#define _STR(x) #x
#define STR(x) _STR(x)
@@ -40,6 +41,8 @@
#define MAXPATH 1024
#endif
+#define HIST_MAX 1000000
+
#define CPUSET_ALL "my_cpuset_all"
#define CPUSET_LOCAL "my_cpuset"
@@ -56,16 +59,13 @@ struct thread_stat {
long act;
double avg;
long *values;
- long *hist_array;
- long *outliers;
+ struct histogram *hist;
pthread_t thread;
int threadstarted;
int tid;
long reduce;
long redmax;
long cycleofmax;
- long hist_overflow;
- long num_outliers;
};
struct sched_data {
@@ -84,6 +84,8 @@ static int info_enable;
static int debug_enable;
static int tracelimit;
static int trace_marker;
+static int histogram;
+static FILE *histfile;
static pthread_mutex_t break_thread_id_lock = PTHREAD_MUTEX_INITIALIZER;
static pid_t break_thread_id;
static uint64_t break_thread_value;
@@ -97,6 +99,8 @@ static int mark_fd;
static int quiet;
static char jsonfile[MAX_PATH];
+static struct histoset hset;
+
static int find_mount(const char *mount, char *debugfs)
{
char type[100];
@@ -691,6 +695,10 @@ static void usage(int error)
" Append 'm', 'h', or 'd' to specify minutes, hours or\n"
" days\n"
"-h --help Show this help menu.\n"
+ " --histogram=US dump a latency histogram to stdout after the run\n"
+ " US is the max latency time to be tracked in microseconds\n"
+ " This option runs all threads at the same priority.\n"
+ " --histfile=<path> dump the latency histogram to <path> instead of stdout\n"
"-i INTV --interval The shortest deadline for the tasks in us\n"
" (default 1000us).\n"
" --json=FILENAME write final results into FILENAME, JSON formatted\n"
@@ -718,6 +726,55 @@ static u64 get_time_us(void)
return time;
}
+static void print_hist(FILE *fp, struct sched_data *sd, int nthreads)
+{
+ int i;
+ unsigned long maxmax, alloverflows;
+
+ fprintf(fp, "# Histogram\n");
+ for (i = 0; i < histogram; i++) {
+ unsigned long flags = 0;
+
+ fprintf(fp, "%06d ", i);
+
+ hset_print_bucket(&hset, fp, i, flags);
+ fprintf(fp, "\n");
+ }
+ fprintf(fp, "# Min Latencies:");
+ for (i = 0; i < nthreads; i++)
+ fprintf(fp, " %05lu", sd[i].stat.min);
+ fprintf(fp, "\n");
+ fprintf(fp, "# Avg Latencies:");
+ for (i = 0; i < nthreads; i++)
+ fprintf(fp, " %05lu", sd[i].stat.cycles ?
+ (long)(sd[i].stat.avg/sd[i].stat.cycles) : 0);
+ fprintf(fp, "\n");
+ fprintf(fp, "# Max Latencies:");
+ maxmax = 0;
+ for (i = 0; i < nthreads; i++) {
+ fprintf(fp, " %05lu", sd[i].stat.max);
+ if (sd[i].stat.max > maxmax)
+ maxmax = sd[i].stat.max;
+ }
+ fprintf(fp, "\n");
+ fprintf(fp, "# Histogram Overflows:");
+ alloverflows = 0;
+ for (i = 0; i < nthreads; i++) {
+ fprintf(fp, " %05lu", sd[i].stat.hist->oflow_count);
+ alloverflows += sd[i].stat.hist->oflow_count;
+ }
+ fprintf(fp, "\n");
+
+ fprintf(fp, "# Histogram Overflow at cycle number:\n");
+ for (i = 0; i < nthreads; i++) {
+ fprintf(fp, "# Thread %d: ", i);
+ hist_print_oflows(sd[i].stat.hist, fp);
+ fprintf(fp, "\n");
+ }
+
+ fprintf(fp, "\n");
+}
+
static void print_stat(FILE *fp, struct sched_data *sd, int index, int verbose, int quiet)
{
struct thread_stat *stat = &sd->stat;
@@ -784,6 +841,9 @@ static u64 do_runtime(long tid, struct sched_data *sd, u64 period)
stat->act = diff;
stat->avg += (double) diff;
+ if (histogram)
+ hist_sample(stat->hist, diff);
+
stat->cycles++;
return next_period;
@@ -1058,8 +1118,14 @@ static void loop(struct sched_data *sched_data, int nr_threads)
if (!quiet) {
printf("\033[%dB", nr_threads + 2);
} else {
- for (i = 0; i < nr_threads; ++i)
- print_stat(stdout, &sched_data[i], i, 0, 0);
+ if (histogram) {
+ FILE *out = histfile ? histfile : stdout;
+
+ print_hist(out, sched_data, nr_threads);
+ } else {
+ for (i = 0; i < nr_threads; ++i)
+ print_stat(stdout, &sched_data[i], i, 0, 0);
+ }
}
}
@@ -1075,10 +1141,14 @@ static void write_stats(FILE *f, void *data)
for (i = 0; i < nr_threads; i++) {
s = &sd[i].stat;
fprintf(f, " \"%u\": {\n", i);
- fprintf(f, " \"cycles\": %ld,\n", s->cycles);
- fprintf(f, " \"min\": %ld,\n", s->min);
- fprintf(f, " \"max\": %ld,\n", s->max);
- fprintf(f, " \"avg\": %.2f\n", s->avg/s->cycles);
+
+ fprintf(f, " \"histogram\": {");
+ hist_print_json(s->hist, f);
+ fprintf(f, " },\n");
+ fprintf(f, " \"cycles\": %ld,\n", s->cycles);
+ fprintf(f, " \"min\": %ld,\n", s->min);
+ fprintf(f, " \"max\": %ld,\n", s->max);
+ fprintf(f, " \"avg\": %.2f\n", s->avg/s->cycles);
fprintf(f, " }%s\n", i == nr_threads - 1 ? "" : ",");
}
fprintf(f, " }\n");
@@ -1088,6 +1158,7 @@ enum options_values {
OPT_AFFINITY=1, OPT_DURATION, OPT_HELP, OPT_INTERVAL,
OPT_JSON, OPT_STEP, OPT_THREADS, OPT_QUIET,
OPT_BREAKTRACE, OPT_TRACEMARK, OPT_INFO, OPT_DEBUG,
+ OPT_HISTOGRAM, OPT_HISTFILE
};
int main(int argc, char **argv)
@@ -1130,6 +1201,8 @@ int main(int argc, char **argv)
{ "tracemark", no_argument, NULL, OPT_TRACEMARK },
{ "verbose", no_argument, NULL, OPT_INFO},
{ "debug", no_argument, NULL, OPT_DEBUG},
+ { "histogram", required_argument, NULL, OPT_HISTOGRAM },
+ { "histfile", required_argument, NULL, OPT_HISTFILE },
{ NULL, 0, NULL, 0 },
};
c = getopt_long(argc, argv, "a::c:D:hi:s:t:b:q", options, NULL);
@@ -1188,6 +1261,17 @@ int main(int argc, char **argv)
case OPT_DEBUG:
debug_enable = 1;
break;
+ case OPT_HISTOGRAM:
+ histogram = atoi(optarg);
+ if (histogram <= 0 || histogram > HIST_MAX)
+ usage(1);
+ break;
+ case OPT_HISTFILE:
+ histfile = fopen(optarg, "w");
+ if (!histfile)
+ fatal("Couldn\'t open histfile %s: %s\n",
+ optarg, strerror(errno));
+ break;
default:
usage(1);
}
@@ -1233,6 +1317,10 @@ int main(int argc, char **argv)
if (!thread || !sched_data)
fatal("allocating threads");
+ if (histogram && hset_init(&hset, nr_threads, 1, histogram, histogram))
+ fatal("failed to allocate histogram of size %d for %d threads\n",
+ histogram, nr_threads);
+
if (nr_threads > nr_cpus) {
/*
* More threads than CPUs, then have the total be
@@ -1262,6 +1350,9 @@ int main(int argc, char **argv)
sd->runtime_us = runtime;
sd->deadline_us = interval;
+ if (histogram)
+ sd->stat.hist = &hset.histos[i];
+
info(info_enable, "interval: %lld:%lld\n", sd->runtime_us, sd->deadline_us);
/* Make sure that we can make our deadlines */
@@ -1356,6 +1447,9 @@ int main(int argc, char **argv)
free(setcpu_buf);
free(thread);
free(sched_data);
+ if (histfile)
+ fclose(histfile);
+ hset_destroy(&hset);
return 0;
}
--
2.43.0

View File

@ -0,0 +1,49 @@
From 8f05671597898ffc9f2f310bbf71e0b9c7b4dec3 Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Mon, 22 Jan 2024 16:13:20 -0600
Subject: [PATCH 2/3] rt-tests: cyclicdeadline: Print the histogram regardless
of quiet
The histogram printing code should not have been gated by !quiet,
even though other summary printing code is.
The non-histogram output also should not have been gated based on
the presence of the histogram.
Signed-off-by: Crystal Wood <crwood@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/sched_deadline/cyclicdeadline.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index b3155547b9bb..3cb8f714b788 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -1117,15 +1117,15 @@ static void loop(struct sched_data *sched_data, int nr_threads)
usleep(10000);
if (!quiet) {
printf("\033[%dB", nr_threads + 2);
- } else {
- if (histogram) {
- FILE *out = histfile ? histfile : stdout;
+ } else if (!histogram) {
+ for (i = 0; i < nr_threads; ++i)
+ print_stat(stdout, &sched_data[i], i, 0, 0);
+ }
- print_hist(out, sched_data, nr_threads);
- } else {
- for (i = 0; i < nr_threads; ++i)
- print_stat(stdout, &sched_data[i], i, 0, 0);
- }
+ if (histogram) {
+ FILE *out = histfile ? histfile : stdout;
+
+ print_hist(out, sched_data, nr_threads);
}
}
--
2.43.0

View File

@ -0,0 +1,107 @@
From 326e7c65f07a6caee814eb1e385704aa1b5b129e Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Mon, 22 Jan 2024 16:13:21 -0600
Subject: [PATCH 3/3] rt-tests: cyclicdeadline: Remove dead "verbose" code in
print_stat()
print_stat() isn't and has never been called with verbose set, and
that codepath doesn't even print anything. Remove it.
Signed-off-by: Crystal Wood <crwood@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/sched_deadline/cyclicdeadline.c | 46 ++++++++++-------------------
1 file changed, 15 insertions(+), 31 deletions(-)
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 3cb8f714b788..7525ad136d2c 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -53,7 +53,6 @@ typedef int s32;
/* Struct for statistics */
struct thread_stat {
unsigned long cycles;
- unsigned long cyclesread;
long min;
long max;
long act;
@@ -64,8 +63,6 @@ struct thread_stat {
int threadstarted;
int tid;
long reduce;
- long redmax;
- long cycleofmax;
};
struct sched_data {
@@ -775,36 +772,23 @@ static void print_hist(FILE *fp, struct sched_data *sd, int nthreads)
fprintf(fp, "\n");
}
-static void print_stat(FILE *fp, struct sched_data *sd, int index, int verbose, int quiet)
+static void print_stat(FILE *fp, struct sched_data *sd, int index, int quiet)
{
struct thread_stat *stat = &sd->stat;
+ char *fmt;
- if (!verbose) {
- if (quiet != 1) {
- char *fmt;
- if (use_nsecs)
- fmt = "T:%2d (%5d) I:%ld C:%7lu "
- "Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n";
- else
- fmt = "T:%2d (%5d) I:%ld C:%7lu "
- "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n";
- fprintf(fp, fmt, index, stat->tid,
- sd->deadline_us, stat->cycles, stat->min, stat->act,
- stat->cycles ?
- (long)(stat->avg/stat->cycles) : 0, stat->max);
- }
- } else {
- while (stat->cycles != stat->cyclesread) {
- long diff = stat->values
- [stat->cyclesread & sd->bufmsk];
+ if (quiet)
+ return;
- if (diff > stat->redmax) {
- stat->redmax = diff;
- stat->cycleofmax = stat->cyclesread;
- }
- stat->cyclesread++;
- }
- }
+ if (use_nsecs)
+ fmt = "T:%2d (%5d) I:%ld C:%7lu Min:%7ld Act:%8ld Avg:%8ld Max:%8ld\n";
+ else
+ fmt = "T:%2d (%5d) I:%ld C:%7lu Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n";
+
+ fprintf(fp, fmt, index, stat->tid,
+ sd->deadline_us, stat->cycles, stat->min, stat->act,
+ stat->cycles ?
+ (long)(stat->avg/stat->cycles) : 0, stat->max);
}
static u64 do_runtime(struct sched_data *sd, u64 period)
@@ -1109,7 +1093,7 @@ static void loop(struct sched_data *sched_data, int nr_threads)
while (!shutdown) {
for (i = 0; i < nr_threads; i++)
- print_stat(stdout, &sched_data[i], i, 0, quiet);
+ print_stat(stdout, &sched_data[i], i, quiet);
usleep(10000);
if (!quiet)
printf("\033[%dA", nr_threads);
@@ -1119,7 +1103,7 @@ static void loop(struct sched_data *sched_data, int nr_threads)
printf("\033[%dB", nr_threads + 2);
} else if (!histogram) {
for (i = 0; i < nr_threads; ++i)
- print_stat(stdout, &sched_data[i], i, 0, 0);
+ print_stat(stdout, &sched_data[i], i, 0);
}
if (histogram) {
--
2.43.0

View File

@ -0,0 +1,62 @@
From 36f634cf8853e00558512b5b48ce600b629402bb Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Mon, 22 Jan 2024 16:13:19 -0600
Subject: [PATCH 1/3] rt-tests: cyclics: Fix json segfault when not using
histogram
If we're not generating a histogram, don't call the histogram code with
a NULL pointer. Also don't print the rest of the histogram json node.
Signed-off-by: Crystal Wood <crwood@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/cyclictest.c | 11 ++++++-----
src/sched_deadline/cyclicdeadline.c | 9 +++++----
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 6169170fc66d..33fac3b95f5d 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1778,12 +1778,13 @@ static void write_stats(FILE *f, void *data __attribute__ ((unused)))
fprintf(f, " \"resolution_in_ns\": %u,\n", use_nsecs);
fprintf(f, " \"thread\": {\n");
for (i = 0; i < num_threads; i++) {
- fprintf(f, " \"%u\": {\n", i);
-
- fprintf(f, " \"histogram\": {");
s = par[i]->stats;
- hist_print_json(par[i]->stats->hist, f);
- fprintf(f, " },\n");
+ fprintf(f, " \"%u\": {\n", i);
+ if (s->hist) {
+ fprintf(f, " \"histogram\": {");
+ hist_print_json(s->hist, f);
+ fprintf(f, " },\n");
+ }
fprintf(f, " \"cycles\": %ld,\n", s->cycles);
fprintf(f, " \"min\": %ld,\n", s->min);
fprintf(f, " \"max\": %ld,\n", s->max);
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index e449be57870e..b3155547b9bb 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -1141,10 +1141,11 @@ static void write_stats(FILE *f, void *data)
for (i = 0; i < nr_threads; i++) {
s = &sd[i].stat;
fprintf(f, " \"%u\": {\n", i);
-
- fprintf(f, " \"histogram\": {");
- hist_print_json(s->hist, f);
- fprintf(f, " },\n");
+ if (s->hist) {
+ fprintf(f, " \"histogram\": {");
+ hist_print_json(s->hist, f);
+ fprintf(f, " },\n");
+ }
fprintf(f, " \"cycles\": %ld,\n", s->cycles);
fprintf(f, " \"min\": %ld,\n", s->min);
fprintf(f, " \"max\": %ld,\n", s->max);
--
2.43.0

View File

@ -0,0 +1,60 @@
From 0c5bc44d844807691da69abf8a2aad5acd8f0de5 Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Wed, 6 Dec 2023 14:55:06 -0600
Subject: [PATCH 1/3] rt-tests: cyclictest: Remove histogram totals
The Total: line does not seem to contribute much value, as it should just
be the number of cycles minus the number of overflows. Unless someone
complains, remove it to simplify moving to common histogram code.
Signed-off-by: Crystal Wood <crwood@redhat.com>
- Tested in rteval
- Edited commit message to say "cycles" instead of buckets
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/cyclictest.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index a8039b49feb6..93ce201e9fca 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1407,12 +1407,9 @@ static void print_tids(struct thread_param *par[], int nthreads)
static void print_hist(struct thread_param *par[], int nthreads)
{
int i, j;
- unsigned long long int log_entries[nthreads+1];
unsigned long maxmax, alloverflows;
FILE *fd;
- bzero(log_entries, sizeof(log_entries));
-
if (use_histfile) {
fd = fopen(histfile, "w");
if (!fd) {
@@ -1434,21 +1431,12 @@ static void print_hist(struct thread_param *par[], int nthreads)
fprintf(fd, "%06lu", curr_latency);
if (j < nthreads - 1)
fprintf(fd, "\t");
- log_entries[j] += curr_latency;
allthreads += curr_latency;
}
- if (histofall && nthreads > 1) {
+ if (histofall && nthreads > 1)
fprintf(fd, "\t%06llu", allthreads);
- log_entries[nthreads] += allthreads;
- }
fprintf(fd, "\n");
}
- fprintf(fd, "# Total:");
- for (j = 0; j < nthreads; j++)
- fprintf(fd, " %09llu", log_entries[j]);
- if (histofall && nthreads > 1)
- fprintf(fd, " %09llu", log_entries[nthreads]);
- fprintf(fd, "\n");
fprintf(fd, "# Min Latencies:");
for (j = 0; j < nthreads; j++)
fprintf(fd, " %05lu", par[j]->stats->min);
--
2.43.0

View File

@ -0,0 +1,448 @@
From 8adfb00d4694e2d4440eba44f8d275d585fd725d Mon Sep 17 00:00:00 2001
From: Crystal Wood <crwood@redhat.com>
Date: Mon, 18 Dec 2023 21:37:49 -0600
Subject: [PATCH 2/3] rt-tests: cyclictest: Replace histogram code with library
The new code is also intended to be used by cyclicdeadline, and possibly
oslat and other tests.
Signed-off-by: Crystal Wood <crwood@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
Makefile | 3 +-
src/cyclictest/cyclictest.c | 82 +++++------------
src/include/histogram.h | 42 +++++++++
src/lib/histogram.c | 172 ++++++++++++++++++++++++++++++++++++
4 files changed, 239 insertions(+), 60 deletions(-)
create mode 100644 src/include/histogram.h
create mode 100644 src/lib/histogram.c
diff --git a/Makefile b/Makefile
index 223a839151ec..a278ca0dfbc0 100644
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,8 @@ oslat: $(OBJDIR)/oslat.o $(OBJDIR)/librttest.a $(OBJDIR)/librttestnuma.a
%.8.bz2: %.8
bzip2 -c $< > $@
-LIBOBJS =$(addprefix $(OBJDIR)/,rt-error.o rt-get_cpu.o rt-sched.o rt-utils.o)
+LIBOBJS =$(addprefix $(OBJDIR)/,rt-error.o rt-get_cpu.o rt-sched.o rt-utils.o \
+ histogram.o)
$(OBJDIR)/librttest.a: $(LIBOBJS)
$(AR) rcs $@ $^
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 93ce201e9fca..6169170fc66d 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -35,6 +35,7 @@
#include "rt-utils.h"
#include "rt-numa.h"
#include "rt-error.h"
+#include "histogram.h"
#include <bionic.h>
@@ -133,16 +134,13 @@ struct thread_stat {
double avg;
long *values;
long *smis;
- long *hist_array;
- long *outliers;
+ struct histogram *hist;
pthread_t thread;
int threadstarted;
int tid;
long reduce;
long redmax;
long cycleofmax;
- long hist_overflow;
- long num_outliers;
unsigned long smi_count;
};
@@ -216,6 +214,7 @@ static char jsonfile[MAX_PATH];
static struct thread_param **parameters;
static struct thread_stat **statistics;
+static struct histoset hset;
static void print_stat(FILE *fp, struct thread_param *par, int index, int verbose, int quiet);
static void rstat_print_stat(struct thread_param *par, int index, int verbose, int quiet);
@@ -777,15 +776,8 @@ static void *timerthread(void *param)
}
/* Update the histogram */
- if (histogram) {
- if (diff >= histogram) {
- stat->hist_overflow++;
- if (stat->num_outliers < histogram)
- stat->outliers[stat->num_outliers++] = stat->cycles;
- } else {
- stat->hist_array[diff]++;
- }
- }
+ if (histogram)
+ hist_sample(stat->hist, diff);
stat->cycles++;
@@ -1422,19 +1414,13 @@ static void print_hist(struct thread_param *par[], int nthreads)
fprintf(fd, "# Histogram\n");
for (i = 0; i < histogram; i++) {
- unsigned long long int allthreads = 0;
+ unsigned long flags = 0;
fprintf(fd, "%06d ", i);
- for (j = 0; j < nthreads; j++) {
- unsigned long curr_latency=par[j]->stats->hist_array[i];
- fprintf(fd, "%06lu", curr_latency);
- if (j < nthreads - 1)
- fprintf(fd, "\t");
- allthreads += curr_latency;
- }
- if (histofall && nthreads > 1)
- fprintf(fd, "\t%06llu", allthreads);
+ if (histofall)
+ flags |= HSET_PRINT_SUM;
+ hset_print_bucket(&hset, fd, i, flags);
fprintf(fd, "\n");
}
fprintf(fd, "# Min Latencies:");
@@ -1459,8 +1445,8 @@ static void print_hist(struct thread_param *par[], int nthreads)
fprintf(fd, "# Histogram Overflows:");
alloverflows = 0;
for (j = 0; j < nthreads; j++) {
- fprintf(fd, " %05lu", par[j]->stats->hist_overflow);
- alloverflows += par[j]->stats->hist_overflow;
+ fprintf(fd, " %05lu", par[j]->stats->hist->oflow_count);
+ alloverflows += par[j]->stats->hist->oflow_count;
}
if (histofall && nthreads > 1)
fprintf(fd, " %05lu", alloverflows);
@@ -1468,11 +1454,8 @@ static void print_hist(struct thread_param *par[], int nthreads)
fprintf(fd, "# Histogram Overflow at cycle number:\n");
for (i = 0; i < nthreads; i++) {
- fprintf(fd, "# Thread %d:", i);
- for (j = 0; j < par[i]->stats->num_outliers; j++)
- fprintf(fd, " %05lu", par[i]->stats->outliers[j]);
- if (par[i]->stats->num_outliers < par[i]->stats->hist_overflow)
- fprintf(fd, " # %05lu others", par[i]->stats->hist_overflow - par[i]->stats->num_outliers);
+ fprintf(fd, "# Thread %d: ", i);
+ hist_print_oflows(par[i]->stats->hist, fd);
fprintf(fd, "\n");
}
if (smi) {
@@ -1788,8 +1771,7 @@ rstat_err:
static void write_stats(FILE *f, void *data __attribute__ ((unused)))
{
struct thread_param **par = parameters;
- int i, j;
- unsigned comma;
+ int i;
struct thread_stat *s;
fprintf(f, " \"num_threads\": %d,\n", num_threads);
@@ -1800,15 +1782,7 @@ static void write_stats(FILE *f, void *data __attribute__ ((unused)))
fprintf(f, " \"histogram\": {");
s = par[i]->stats;
- for (j = 0, comma = 0; j < histogram; j++) {
- if (s->hist_array[j] == 0)
- continue;
- fprintf(f, "%s", comma ? ",\n" : "\n");
- fprintf(f, " \"%u\": %ld", j, s->hist_array[j]);
- comma = 1;
- }
- if (comma)
- fprintf(f, "\n");
+ hist_print_json(par[i]->stats->hist, f);
fprintf(f, " },\n");
fprintf(f, " \"cycles\": %ld,\n", s->cycles);
fprintf(f, " \"min\": %ld,\n", s->min);
@@ -1991,6 +1965,10 @@ int main(int argc, char **argv)
/* Set-up shm */
rstat_setup();
+ if (histogram && hset_init(&hset, num_threads, 1, histogram, histogram))
+ fatal("failed to allocate histogram of size %d for %d threads\n",
+ histogram, num_threads);
+
parameters = calloc(num_threads, sizeof(struct thread_param *));
if (!parameters)
goto out;
@@ -2066,18 +2044,8 @@ int main(int argc, char **argv)
fatal("error allocating thread status struct for thread %d\n", i);
memset(stat, 0, sizeof(struct thread_stat));
- /* allocate the histogram if requested */
- if (histogram) {
- int bufsize = histogram * sizeof(long);
-
- stat->hist_array = threadalloc(bufsize, node);
- stat->outliers = threadalloc(bufsize, node);
- if (stat->hist_array == NULL || stat->outliers == NULL)
- fatal("failed to allocate histogram of size %d on node %d\n",
- histogram, i);
- memset(stat->hist_array, 0, bufsize);
- memset(stat->outliers, 0, bufsize);
- }
+ if (histogram)
+ stat->hist = &hset.histos[i];
if (verbose) {
int bufsize = VALBUF_SIZE * sizeof(long);
@@ -2215,13 +2183,8 @@ int main(int argc, char **argv)
if (trigger)
trigger_print();
- if (histogram) {
+ if (histogram)
print_hist(parameters, num_threads);
- for (i = 0; i < num_threads; i++) {
- threadfree(statistics[i]->hist_array, histogram*sizeof(long), parameters[i]->node);
- threadfree(statistics[i]->outliers, histogram*sizeof(long), parameters[i]->node);
- }
- }
if (tracelimit) {
print_tids(parameters, num_threads);
@@ -2263,5 +2226,6 @@ int main(int argc, char **argv)
if (rstat_fd >= 0)
shm_unlink(shm_name);
+ hset_destroy(&hset);
exit(ret);
}
diff --git a/src/include/histogram.h b/src/include/histogram.h
new file mode 100644
index 000000000000..c7aba68ffb99
--- /dev/null
+++ b/src/include/histogram.h
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdint.h>
+#include <stdio.h>
+
+struct histogram {
+ unsigned long *buckets;
+ unsigned long width; // interval covered by one bucket
+ unsigned long num; // number of buckets
+ unsigned long events; // number of events logged
+
+ unsigned long *oflows; // events when overflow happened
+ unsigned long oflow_bufsize; // number of overflows that can be logged
+ unsigned long oflow_count; // number of events that overflowed
+ uint64_t oflow_magnitude; // sum of how many buckets overflowed by
+};
+
+struct histoset {
+ struct histogram *histos; // Group of related histograms (e.g. per cpu)
+ struct histogram *sum; // Accumulates events from all histos
+ unsigned long num_histos; // Not including sum
+ unsigned long num_buckets;
+};
+
+#define HIST_OVERFLOW 1
+#define HIST_OVERFLOW_MAG 2
+#define HIST_OVERFLOW_LOG 4
+
+int hist_init(struct histogram *h, unsigned long width, unsigned long num);
+int hist_init_oflow(struct histogram *h, unsigned long num);
+void hist_destroy(struct histogram *h);
+int hist_sample(struct histogram *h, uint64_t sample);
+
+#define HSET_PRINT_SUM 1
+#define HSET_PRINT_JSON 2
+
+int hset_init(struct histoset *hs, unsigned long histos, unsigned long bucket_width,
+ unsigned long num_buckets, unsigned long overflow);
+void hset_destroy(struct histoset *hs);
+void hset_print_bucket(struct histoset *hs, FILE *f, unsigned long bucket,
+ unsigned long flags);
+void hist_print_json(struct histogram *h, FILE *f);
+void hist_print_oflows(struct histogram *h, FILE *f);
diff --git a/src/lib/histogram.c b/src/lib/histogram.c
new file mode 100644
index 000000000000..35a9d604da86
--- /dev/null
+++ b/src/lib/histogram.c
@@ -0,0 +1,172 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Latency histograms
+ *
+ * Copyright 2023 Red Hat Inc.
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include "histogram.h"
+
+int hist_init(struct histogram *h, unsigned long width, unsigned long num)
+{
+ memset(h, 0, sizeof(*h));
+ h->width = width;
+ h->num = num;
+
+ h->buckets = calloc(num, sizeof(unsigned long));
+ if (!h->buckets)
+ return -ENOMEM;
+
+ return 0;
+}
+
+int hist_init_oflow(struct histogram *h, unsigned long num)
+{
+ h->oflow_bufsize = num;
+ h->oflows = calloc(num, sizeof(unsigned long));
+ if (!h->oflows)
+ return -ENOMEM;
+
+ return 0;
+}
+
+void hist_destroy(struct histogram *h)
+{
+ free(h->oflows);
+ h->oflows = NULL;
+ free(h->buckets);
+ h->buckets = NULL;
+}
+
+int hist_sample(struct histogram *h, uint64_t sample)
+{
+ unsigned long bucket = sample / h->width;
+ unsigned long extra;
+ unsigned long event = h->events++;
+ int ret;
+
+ if (bucket < h->num) {
+ h->buckets[bucket]++;
+ return 0;
+ }
+
+ ret = HIST_OVERFLOW;
+ extra = bucket - h->num;
+ if (h->oflow_magnitude + extra > h->oflow_magnitude)
+ h->oflow_magnitude += extra;
+ else
+ ret |= HIST_OVERFLOW_MAG;
+
+ if (h->oflows) {
+ if (h->oflow_count < h->oflow_bufsize)
+ h->oflows[h->oflow_count] = event;
+ else
+ ret |= HIST_OVERFLOW_LOG;
+ }
+
+ h->oflow_count++;
+ return ret;
+}
+
+int hset_init(struct histoset *hs, unsigned long num_histos,
+ unsigned long bucket_width, unsigned long num_buckets,
+ unsigned long overflow)
+{
+ unsigned long i;
+
+ if (num_histos == 0)
+ return -EINVAL;
+
+ hs->num_histos = num_histos;
+ hs->num_buckets = num_buckets;
+ hs->histos = calloc(num_histos, sizeof(struct histogram));
+ if (!hs->histos)
+ return -ENOMEM;
+
+ for (i = 0; i < num_histos; i++) {
+ if (hist_init(&hs->histos[i], bucket_width, num_buckets))
+ goto fail;
+ if (overflow && hist_init_oflow(&hs->histos[i], overflow))
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ hset_destroy(hs);
+ return -ENOMEM;
+}
+
+void hset_destroy(struct histoset *hs)
+{
+ unsigned long i;
+
+ if (hs->histos) {
+ for (i = 0; i < hs->num_histos; i++)
+ hist_destroy(&hs->histos[i]);
+ }
+
+ free(hs->histos);
+ hs->histos = NULL;
+}
+
+void hset_print_bucket(struct histoset *hs, FILE *f, unsigned long bucket,
+ unsigned long flags)
+{
+ unsigned long long sum = 0;
+ unsigned long i;
+
+ if (bucket >= hs->num_buckets)
+ return;
+
+ for (i = 0; i < hs->num_histos; i++) {
+ unsigned long val = hs->histos[i].buckets[bucket];
+
+ sum += val;
+ if (i != 0)
+ fprintf(f, "\t");
+ fprintf(f, "%06lu", val);
+ }
+
+ if (flags & HSET_PRINT_SUM)
+ fprintf(f, "\t%06llu", sum);
+}
+
+void hist_print_json(struct histogram *h, FILE *f)
+{
+ unsigned long i;
+ bool comma = false;
+
+ for (i = 0; i < h->num; i++) {
+ unsigned long val = h->buckets[i];
+
+ if (val != 0) {
+ if (comma)
+ fprintf(f, ",");
+ fprintf(f, "\n \"%lu\": %lu", i, val);
+ comma = true;
+ }
+ }
+
+ fprintf(f, "\n");
+}
+
+void hist_print_oflows(struct histogram *h, FILE *f)
+{
+ unsigned long i;
+
+ for (i = 0; i < h->oflow_count; i++) {
+ if (i >= h->oflow_bufsize)
+ break;
+ if (i != 0)
+ fprintf(f, " ");
+ fprintf(f, "%05lu", h->oflows[i]);
+ }
+
+ if (i >= h->oflow_bufsize)
+ fprintf(f, " # %05lu others", h->oflow_count - h->oflow_bufsize);
+}
--
2.43.0

View File

@ -0,0 +1,42 @@
From 4aeacf722cee26a3f88ab7f631c9ab9ba6ecdb49 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Thu, 1 Feb 2024 14:50:54 -0300
Subject: [PATCH 2/2] rt-tests: oslat: convert to nanoseconds correctly
With buckets of size 1us, accounting for measurements in the
[1ns, 999ns] range are done to the 2us bucket (while they
should be accounted in the 1us bucket):
001 (us): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
002 (us): 41916187 41937649 41938461 42029055 ...
003 (us): 969 985 958 972 964 986 970 961 973 ...
Fix this by doing a plain cycles -> nanoseconds convertion:
001 (us): 43287555 43086678 43087427 43109974 ...
002 (us): 983 987 985 975 982 960 993 961 992 ...
003 (us): 9 6 7 13 9 22 3 21 3 3 8 8 10 11 3 55
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reported-by: Chuck Newman <chuck.newman@hpe.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/oslat/oslat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index e398f205b40a..0863297f2cf1 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -334,7 +334,7 @@ static void insert_bucket(struct thread *t, stamp_t value)
uint64_t extra;
double us;
- lat = (value * g.unit_per_us + t->counter_mhz - 1) / t->counter_mhz;
+ lat = (value * g.unit_per_us) / t->counter_mhz;
us = (double)lat / g.unit_per_us;
if (!g.preheat && g.trace_threshold && us >= g.trace_threshold) {
char *line = "%s: Trace threshold (%d us) triggered on cpu %d with %.*f us!\n";
--
2.43.0

View File

@ -0,0 +1,34 @@
From 251d082403b371098c8420c01d1b058b12a9cc78 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Thu, 1 Feb 2024 13:05:38 -0300
Subject: [PATCH 1/2] rt-tests: oslat should use MHz, not Mhz
Usage of Mhz, in oslat, is incorrect:
From https://www.nist.gov/pml/owm/writing-si-metric-system-units#:~:text=NOT%20250%20mms.-,Capitalization,the%20beginning%20of%20the%20sentence:
"When the unit is derived from the name of a person, the symbol or the first letter of the symbol is an uppercase letter (W for the unit "watt" or Pa for the unit "pascal")."
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reported-by: Chuck Newman <chuck.newman@hpe.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/oslat/oslat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index 4bdca643da72..e398f205b40a 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -501,7 +501,7 @@ static void write_summary(struct thread *t)
calculate(t);
putfield("Core", t[i].core_i, "d", "");
- putfield("Counter Freq", t[i].counter_mhz, "u", " (Mhz)");
+ putfield("Counter Freq", t[i].counter_mhz, "u", " (MHz)");
for (j = 0; j < g.bucket_size; j++) {
if (j < g.bucket_size-1 && g.output_omit_zero_buckets) {
--
2.43.0

View File

@ -5,13 +5,13 @@ Name: realtime-tests
# BuildRequires: numactl-devel
# Numa argument to make: NUMA=1
#
Version: 2.5
Release: 1%{?dist}
Version: 2.6
Release: 5%{?dist}
License: GPLv2
URL: https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
Source0: https://www.kernel.org/pub/linux/utils/rt-tests/rt-tests-%{version}.tar.xz
ExcludeArch: s390 s390x armv7hl ppc64 ppc64le aarch64 i686
ExcludeArch: s390 s390x armv7hl ppc64 ppc64le i686
BuildRequires: make
BuildRequires: gcc
BuildRequires: numactl-devel
@ -20,6 +20,18 @@ Requires: bash
Requires: bc
#Patches
Patch1: rt-tests-Add-missing-SPDX-licenses.patch
Patch2: rt-tests-Makefile-Restore-support-for-Exuberant-Ctag.patch
Patch3: rt-tests-Remove-remaining-unnecessary-texts.patch
Patch4: rt-tests-Fix-warnings.patch
Patch5: rt-tests-cyclictest-Remove-histogram-totals.patch
Patch6: rt-tests-cyclictest-Replace-histogram-code-with-libr.patch
Patch7: rt-tests-cyclicdeadline-Add-histogram-support.patch
Patch8: rt-tests-cyclics-Fix-json-segfault-when-not-using-hi.patch
Patch9: rt-tests-cyclicdeadline-Print-the-histogram-regardle.patch
Patch10: rt-tests-cyclicdeadline-Remove-dead-verbose-code-in-.patch
Patch11: rt-tests-oslat-should-use-MHz-not-Mhz.patch
Patch12: rt-tests-oslat-convert-to-nanoseconds-correctly.patch
%description
realtime-tests is a set of programs that test and measure various components of
@ -28,6 +40,18 @@ latency. It also tests the functioning of priority-inheritance mutexes.
%prep
%setup -q -n rt-tests-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%build
%set_build_flags
@ -78,6 +102,32 @@ latency. It also tests the functioning of priority-inheritance mutexes.
%{_mandir}/man8/determine_maximum_mpps.8.*
%changelog
* Mon Feb 05 2024 John Kacur <jkacur@redhat.com> - 2.6-4
- Fix specfile to apply all patches
Resolves: RHEL-23909
* Mon Feb 05 2024 John Kacur <jkacur@redhat.com> - 2.6-4
- oslat: correct spelling of Mhz to MHz
- oslat: Fix conversion to nanoseconds for 1us bucket
Resolves: RHEL-23909
* Fri Jan 26 2024 Crystal Wood <crwood@redhat.com> - 2.6-3
- Fix issues with with using --json without --histogram (both cyclictest and
cyclicdeadline), and using --histogram without --quiet in cyclicdeadline.
Resolves: RHEL-9910
* Thu Jan 11 2024 Crystal Wood <crwood@redhat.com> - 2.6-2
- cyclicdeadline histogram support
Resolves: RHEL-9910
* Fri Oct 27 2023 John Kacur <jkacur@redhat.com> - 2.6-1
- Update to latest rt-tests upstream v2.6
Resolves: RHEL-7860
* Wed Jul 12 2023 John Kacur <jkacur@redhat.com> - 2.5-2
- Remove aarch64 from ExcludeArch to allow internal arm builds
Resolves: rhbz#2222437
* Tue Jan 24 2023 John Kacur <jkacur@redhat.com> - 2.5-1
- Update to latest rt-tests upstream v2.5
Resolves: rhbz#2162779