diff --git a/SOURCES/oslat-Use-cpuset-size-as-upper-bound.patch b/SOURCES/oslat-Use-cpuset-size-as-upper-bound.patch new file mode 100644 index 0000000..415b023 --- /dev/null +++ b/SOURCES/oslat-Use-cpuset-size-as-upper-bound.patch @@ -0,0 +1,38 @@ +From 6d5aa2b00d41ecdb6eb1355309737647e177e5e6 Mon Sep 17 00:00:00 2001 +From: Daniel Wagner +Date: Wed, 10 Feb 2021 17:54:07 +0100 +Subject: [PATCH 2/3] oslat: Use cpuset size as upper bound + +To assign the threads to the correct CPU we need to use the cpuset +size as upper bound for the loop and not the number of threads. + +Fixes: 85b0763dacd9 ("oslat: Use parse_cpumask() from rt-numa.h") +Reported-by: Peter Xu +Signed-off-by: Daniel Wagner +Signed-off-by: John Kacur +--- + src/oslat/oslat.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c +index 7826c277f26d..2fe550b3ee12 100644 +--- a/src/oslat/oslat.c ++++ b/src/oslat/oslat.c +@@ -747,9 +747,12 @@ int main(int argc, char *argv[]) + n_cores = numa_bitmask_weight(cpu_set); + + TEST(threads = calloc(1, n_cores * sizeof(threads[0]))); +- for (i = 0; i < n_cores; ++i) +- if (numa_bitmask_isbitset(cpu_set, i) && move_to_core(i) == 0) ++ for (i = 0; n_cores && i < cpu_set->size; i++) { ++ if (numa_bitmask_isbitset(cpu_set, i) && move_to_core(i) == 0) { + threads[g.n_threads_total++].core_i = i; ++ n_cores--; ++ } ++ } + + if (numa_bitmask_isbitset(cpu_set, 0) && g.rtprio) + printf("WARNING: Running SCHED_FIFO workload on CPU 0 may hang the thread\n"); +-- +2.26.2 + diff --git a/SOURCES/oslat-allow-scheduling-on-all-possible-cores.patch b/SOURCES/oslat-allow-scheduling-on-all-possible-cores.patch new file mode 100644 index 0000000..a80e336 --- /dev/null +++ b/SOURCES/oslat-allow-scheduling-on-all-possible-cores.patch @@ -0,0 +1,73 @@ +From 29884cff6352856fee9fffecb4a715efd70e08f5 Mon Sep 17 00:00:00 2001 +From: Peter Xu +Date: Thu, 18 Feb 2021 14:27:29 -0500 +Subject: [PATCH] oslat: Fix --cpu-list won't allow to schedule on all possible + cores + +parse_cpumask() is too strict for oslat, in that use_current_cpuset() will +filter out all the cores that are not allowed for current process to run. This +seems to be unnecessary at least for oslat. For example, the bash process that +runs the oslat program may have a sched affinity of 0-2, however it's still +legal to have it start a oslat thread running on the cores outside 0-2 as long +as the follow up sched_setaffinity() will succeed. + +numa_parse_cpustring_all() suites exactly for this case, which should already +have considered sysconf(_SC_NPROCESSORS_ONLN) limit. Use that instead. + +Since at it, also remove initialization of cpu_set variable otherwise it's +leaked in previous parse_cpumask too: numa_parse_cpustring_all() will return a +newly allocated buffer already. Quotting from manual: + + numa_parse_nodestring() parses a character string list of nodes into a bit + mask. The bit mask is allocated by numa_allocate_nodemask(). + + numa_parse_nodestring_all() is similar to numa_parse_nodestring, but can + parse all possible nodes, not only current nodeset. + +Cc: John Kacur +Cc: Daniel Wagner +Cc: Clark Williams +Reported-by: Pradipta Kumar Sahoo +Reported-by: Mike Stowell +Signed-off-by: Peter Xu +Signed-off-by: John Kacur +--- + src/oslat/oslat.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c +index b2c5373388fb..465a694cdd1d 100644 +--- a/src/oslat/oslat.c ++++ b/src/oslat/oslat.c +@@ -785,7 +785,6 @@ int main(int argc, char *argv[]) + struct thread *threads; + int i, n_cores; + struct bitmask *cpu_set = NULL; +- int max_cpus = sysconf(_SC_NPROCESSORS_ONLN); + + #ifdef FRC_MISSING + printf("This architecture is not yet supported. " +@@ -797,10 +796,6 @@ int main(int argc, char *argv[]) + exit(1); + } + +- cpu_set = numa_allocate_cpumask(); +- if (!cpu_set) +- fatal("oslat: Could not allocate cpumask\n"); +- + g.app_name = argv[0]; + g.rtprio = 0; + g.bucket_size = BUCKET_SIZE; +@@ -817,7 +812,8 @@ int main(int argc, char *argv[]) + if (!g.cpu_list) + g.cpu_list = strdup("all"); + +- if (parse_cpumask(g.cpu_list, max_cpus, &cpu_set) != 0) ++ cpu_set = numa_parse_cpustring_all(g.cpu_list); ++ if (!cpu_set) + fatal("oslat: parse_cpumask failed.\n"); + n_cores = numa_bitmask_weight(cpu_set); + +-- +2.26.2 + diff --git a/SOURCES/rt-tests-oslat-Allocate-memory-for-cpu_set.patch b/SOURCES/rt-tests-oslat-Allocate-memory-for-cpu_set.patch new file mode 100644 index 0000000..708e927 --- /dev/null +++ b/SOURCES/rt-tests-oslat-Allocate-memory-for-cpu_set.patch @@ -0,0 +1,47 @@ +From 5821269dde6a778b0af06c172bc2f19bbe324bda Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Fri, 12 Feb 2021 12:22:23 -0500 +Subject: [PATCH 3/3] rt-tests: oslat: Allocate memory for cpu_set + +- cpu_set is a pointer to a bitmask struct +Memory needs to be allocated for the struct, so call +numa_allocate_cpumask() + +- use rt-tests fatal to exit on error conditions + +Reviewed-by: Daniel Wagner +Signed-off-by: John Kacur +--- + src/oslat/oslat.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c +index 2fe550b3ee12..2a3be393a268 100644 +--- a/src/oslat/oslat.c ++++ b/src/oslat/oslat.c +@@ -727,6 +727,10 @@ int main(int argc, char *argv[]) + exit(1); + } + ++ cpu_set = numa_allocate_cpumask(); ++ if (!cpu_set) ++ fatal("oslat: Could not allocate cpumask\n"); ++ + g.app_name = argv[0]; + g.rtprio = 0; + g.bucket_size = BUCKET_SIZE; +@@ -742,8 +746,9 @@ int main(int argc, char *argv[]) + + if (!g.cpu_list) + g.cpu_list = strdup("all"); +- if (parse_cpumask(g.cpu_list, max_cpus, &cpu_set)) +- exit(1); ++ ++ if (parse_cpumask(g.cpu_list, max_cpus, &cpu_set) != 0) ++ fatal("oslat: parse_cpumask failed.\n"); + n_cores = numa_bitmask_weight(cpu_set); + + TEST(threads = calloc(1, n_cores * sizeof(threads[0]))); +-- +2.26.2 + diff --git a/SOURCES/rt-tests-oslat-print-version-string.patch b/SOURCES/rt-tests-oslat-print-version-string.patch new file mode 100644 index 0000000..ee1fd6b --- /dev/null +++ b/SOURCES/rt-tests-oslat-print-version-string.patch @@ -0,0 +1,54 @@ +From 2f4d564fb5557f7a420c183ddd3938647c231a8c Mon Sep 17 00:00:00 2001 +From: John Kacur +Date: Wed, 10 Feb 2021 22:18:41 -0500 +Subject: [PATCH 1/3] rt-tests: oslat: print version string + +During the streamlining of the command line options something went awry +with the version. The author of oslat wishes to always print the version +string. This allows us to just exit in the case of -v + +Fixes e411219d27b1 + +Reported-by: Pradipta Kumar Sahoo +Reported-by: Reported-by: Peter Xu + +Signed-off-by: John Kacur +--- + src/oslat/oslat.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c +index 5b7e0d5b5d5c..7826c277f26d 100644 +--- a/src/oslat/oslat.c ++++ b/src/oslat/oslat.c +@@ -512,7 +512,6 @@ static void handle_alarm(int code) + + static void usage(int error) + { +- printf("oslat V %1.2f\n", VERSION); + printf("Usage:\n" + "oslat \n\n" + "This is an OS latency detector by running busy loops on specified cores.\n" +@@ -657,8 +656,8 @@ static void parse_options(int argc, char *argv[]) + break; + case 'v': + /* +- * Because we always dump the version even before parsing options, +- * what we need to do is to quit.. ++ * We always print the version before parsing options ++ * so just exit + */ + exit(0); + break; +@@ -736,7 +735,7 @@ int main(int argc, char *argv[]) + g.workload_mem_size = WORKLOAD_MEM_SIZE; + /* Run the main thread on cpu0 by default */ + g.cpu_main_thread = 0; +- ++ printf("oslat V %1.2f\n", VERSION); + parse_options(argc, argv); + + TEST(mlockall(MCL_CURRENT | MCL_FUTURE) == 0); +-- +2.26.2 + diff --git a/SPECS/rt-tests.spec b/SPECS/rt-tests.spec index 140ff55..c798bc2 100644 --- a/SPECS/rt-tests.spec +++ b/SPECS/rt-tests.spec @@ -6,7 +6,7 @@ Name: rt-tests # Numa argument to make: NUMA=1 # Version: 1.10 -Release: 1%{?dist} +Release: 3%{?dist} License: GPLv2 Group: Development/Tools URL: git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git @@ -21,6 +21,10 @@ BuildRequires: python3-devel Requires: bash bc #Patches +Patch1: rt-tests-oslat-print-version-string.patch +Patch2: oslat-Use-cpuset-size-as-upper-bound.patch +Patch3: rt-tests-oslat-Allocate-memory-for-cpu_set.patch +Patch4: oslat-allow-scheduling-on-all-possible-cores.patch %description rt-tests is a set of programs that test and measure various components of @@ -29,6 +33,10 @@ latency. It also tests the functioning of priority-inheritance mutexes. %prep %setup -q -n %{name}-%{version} +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build %set_build_flags @@ -83,6 +91,16 @@ rm -rf ${build_root} %{_mandir}/man8/determine_maximum_mpps.8.* %changelog +* Fri Feb 19 2021 John Kacur - 1.10-3 +- parse_cpumask() is too strict for oslat, allow all possible cores +Resolves: rhbz#1926578 + +* Thu Feb 18 2021 John Kacur - 1.10-2 +- print the version number in oslat everytime. +- use cpuset size as upper bound in loop in oslat +- allocate memory for cpu_set in oslat +Resolves: rhbz#1926578 + * Mon Jan 11 2021 John Kacur - 1.10-1 - Upgrade to upstream rt-tests-1.10 Resolves: rhbz#1890556