sched_deadline: Changes for HRTICK
- Take into account the rename of the sched_features file for HRTICK - Use HRTICK_DL if available Resolves: rhbz#1973083 Signed-off-by: John Kacur <jkacur@redhat.com>
This commit is contained in:
parent
f9afb08aae
commit
6aa7c32eae
@ -6,7 +6,7 @@ Name: realtime-tests
|
||||
# Numa argument to make: NUMA=1
|
||||
#
|
||||
Version: 2.1
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?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
|
||||
@ -20,6 +20,8 @@ Requires: bash
|
||||
Requires: bc
|
||||
|
||||
#Patches
|
||||
Patch1: sched_deadline-Accommodate-new-location-of-HRTICK-file.patch
|
||||
Patch2: sched_deadline-Use-HRTICK_DL-for-sched_deadline-tests.patch
|
||||
|
||||
%description
|
||||
realtime-tests is a set of programs that test and measure various components of
|
||||
@ -28,6 +30,8 @@ latency. It also tests the functioning of priority-inheritance mutexes.
|
||||
|
||||
%prep
|
||||
%setup -q -n rt-tests-%{version}
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
|
||||
%build
|
||||
%set_build_flags
|
||||
@ -78,6 +82,11 @@ latency. It also tests the functioning of priority-inheritance mutexes.
|
||||
%{_mandir}/man8/determine_maximum_mpps.8.*
|
||||
|
||||
%changelog
|
||||
* Fri Jul 23 2021 John Kacur <jkacur@redhat.com> - 2.1-2
|
||||
- Take into account the rename of the sched_features file for HRTICK
|
||||
- Use HRTICK_DL if available
|
||||
Resolves: rhbz#1973083
|
||||
|
||||
* Wed Jun 30 2021 john Kacur <jkacur@redhat.com> - 2.1-1
|
||||
- Update to latest upstream rt-tests-2.1
|
||||
Resolves: rhbz#1890563
|
||||
|
217
sched_deadline-Accommodate-new-location-of-HRTICK-file.patch
Normal file
217
sched_deadline-Accommodate-new-location-of-HRTICK-file.patch
Normal file
@ -0,0 +1,217 @@
|
||||
From 84c45a66bf077be31c9e0cf85b72896798966826 Mon Sep 17 00:00:00 2001
|
||||
From: John Kacur <jkacur@redhat.com>
|
||||
Date: Thu, 22 Jul 2021 16:30:13 -0400
|
||||
Subject: [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file
|
||||
in kernel
|
||||
|
||||
Newer kernels rename /sys/kernel/debug/sched_features to
|
||||
/sys/kernel/debug/sched/features
|
||||
|
||||
Modify sched_deadline tests to look for the new file and if that fails
|
||||
look for the old file name
|
||||
|
||||
These functions are based on ones in stalld, and stalld itself has
|
||||
functions based on the sched_deadline programs in rt-tests
|
||||
|
||||
Signed-off-by: John Kacur <jkacur@redhat.com>
|
||||
---
|
||||
src/sched_deadline/cyclicdeadline.c | 65 ++++++++++++++++++++++-------
|
||||
src/sched_deadline/deadline_test.c | 61 +++++++++++++++++++++------
|
||||
2 files changed, 100 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
|
||||
index 8447424273ee..4a38ec2274c9 100644
|
||||
--- a/src/sched_deadline/cyclicdeadline.c
|
||||
+++ b/src/sched_deadline/cyclicdeadline.c
|
||||
@@ -230,12 +230,53 @@ found:
|
||||
mark_fd = open(files, O_WRONLY);
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Return true if file exists
|
||||
+ */
|
||||
+static int check_file_exists(char *path)
|
||||
+{
|
||||
+ int ret;
|
||||
+ struct stat st;
|
||||
+
|
||||
+ ret = !stat(path, &st);
|
||||
+
|
||||
+ return ret;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Return 0 on success
|
||||
+ */
|
||||
+
|
||||
+static int fill_sched_features(char *path)
|
||||
+{
|
||||
+ int ret;
|
||||
+ const char *debugfs;
|
||||
+
|
||||
+ debugfs = find_debugfs();
|
||||
+ if (strlen(debugfs) == 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ snprintf(path, MAX_PATH, "%s/sched/features", debugfs);
|
||||
+ ret = check_file_exists(path);
|
||||
+ if (ret)
|
||||
+ return 0;
|
||||
+
|
||||
+ snprintf(path, MAX_PATH, "%s/sched_features", debugfs);
|
||||
+ ret = check_file_exists(path);
|
||||
+ if (ret)
|
||||
+ return 0;
|
||||
+
|
||||
+ memset(path, 0, MAX_PATH);
|
||||
+
|
||||
+ return ret;
|
||||
+
|
||||
+}
|
||||
+
|
||||
static int setup_hr_tick(void)
|
||||
{
|
||||
- const char *debugfs = find_debugfs();
|
||||
- char files[strlen(debugfs) + strlen("/sched_features") + 1];
|
||||
+ char path[MAX_PATH];
|
||||
char buf[500];
|
||||
- struct stat st;
|
||||
static int set = 0;
|
||||
char *p;
|
||||
int ret;
|
||||
@@ -244,27 +285,23 @@ static int setup_hr_tick(void)
|
||||
|
||||
if (set)
|
||||
return 1;
|
||||
-
|
||||
set = 1;
|
||||
|
||||
- if (strlen(debugfs) == 0)
|
||||
- return 0;
|
||||
-
|
||||
- sprintf(files, "%s/sched_features", debugfs);
|
||||
- ret = stat(files, &st);
|
||||
- if (ret < 0)
|
||||
+ ret = fill_sched_features(path);
|
||||
+ if (ret)
|
||||
return 0;
|
||||
|
||||
- fd = open(files, O_RDWR);
|
||||
- perror(files);
|
||||
- if (fd < 0)
|
||||
+ fd = open(path, O_RDWR);
|
||||
+ if (fd < 0) {
|
||||
+ perror(path);
|
||||
return 0;
|
||||
+ }
|
||||
|
||||
len = sizeof(buf);
|
||||
|
||||
ret = read(fd, buf, len);
|
||||
if (ret < 0) {
|
||||
- perror(files);
|
||||
+ perror(path);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
|
||||
index 395c2370f69a..c1e890319895 100644
|
||||
--- a/src/sched_deadline/deadline_test.c
|
||||
+++ b/src/sched_deadline/deadline_test.c
|
||||
@@ -368,6 +368,49 @@ found:
|
||||
mark_fd = open(files, O_WRONLY);
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * Return true if file exists
|
||||
+ */
|
||||
+static int check_file_exists(char *path)
|
||||
+{
|
||||
+ int ret;
|
||||
+ struct stat st;
|
||||
+
|
||||
+ ret = !stat(path, &st);
|
||||
+
|
||||
+ return ret;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Return 0 on success
|
||||
+ */
|
||||
+
|
||||
+static int fill_sched_features(char *path)
|
||||
+{
|
||||
+ int ret;
|
||||
+ const char *debugfs;
|
||||
+
|
||||
+ debugfs = find_debugfs();
|
||||
+ if (strlen(debugfs) == 0)
|
||||
+ return -1;
|
||||
+
|
||||
+ snprintf(path, MAX_PATH, "%s/sched/features", debugfs);
|
||||
+ ret = check_file_exists(path);
|
||||
+ if (ret)
|
||||
+ return 0;
|
||||
+
|
||||
+ snprintf(path, MAX_PATH, "%s/sched_features", debugfs);
|
||||
+ ret = check_file_exists(path);
|
||||
+ if (ret)
|
||||
+ return 0;
|
||||
+
|
||||
+ memset(path, 0, MAX_PATH);
|
||||
+
|
||||
+ return ret;
|
||||
+
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* setup_hr_tick - Enable the HRTICK in sched_features (if available)
|
||||
*
|
||||
@@ -381,10 +424,8 @@ found:
|
||||
*/
|
||||
static int setup_hr_tick(void)
|
||||
{
|
||||
- const char *debugfs = find_debugfs();
|
||||
- char files[strlen(debugfs) + strlen("/sched_features") + 1];
|
||||
+ char path[MAX_PATH];
|
||||
char buf[500];
|
||||
- struct stat st;
|
||||
static int set = 0;
|
||||
char *p;
|
||||
int ret;
|
||||
@@ -396,17 +437,13 @@ static int setup_hr_tick(void)
|
||||
|
||||
set = 1;
|
||||
|
||||
- if (strlen(debugfs) == 0)
|
||||
- return 0;
|
||||
-
|
||||
- sprintf(files, "%s/sched_features", debugfs);
|
||||
- ret = stat(files, &st);
|
||||
- if (ret < 0)
|
||||
+ ret = fill_sched_features(path);
|
||||
+ if (ret)
|
||||
return 0;
|
||||
|
||||
- fd = open(files, O_RDWR);
|
||||
+ fd = open(path, O_RDWR);
|
||||
if (fd < 0) {
|
||||
- perror(files);
|
||||
+ perror(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -414,7 +451,7 @@ static int setup_hr_tick(void)
|
||||
|
||||
ret = read(fd, buf, len);
|
||||
if (ret < 0) {
|
||||
- perror(files);
|
||||
+ perror(path);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.31.1
|
||||
|
125
sched_deadline-Use-HRTICK_DL-for-sched_deadline-tests.patch
Normal file
125
sched_deadline-Use-HRTICK_DL-for-sched_deadline-tests.patch
Normal file
@ -0,0 +1,125 @@
|
||||
From de3cdf92834bc600d5806f959e8d78d48f7f9775 Mon Sep 17 00:00:00 2001
|
||||
From: John Kacur <jkacur@redhat.com>
|
||||
Date: Fri, 23 Jul 2021 14:52:43 -0400
|
||||
Subject: [PATCH 2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests
|
||||
|
||||
If the HRTICK_DL feature is available, use it for the sched_deadline
|
||||
tests, otherwise fall back to HRTICK
|
||||
|
||||
This code is based on changes in stalld - which in turn was based on
|
||||
these sched_deadline tests
|
||||
|
||||
Signed-off-by: John Kacur <jkacur@redhat.com>
|
||||
---
|
||||
src/sched_deadline/cyclicdeadline.c | 27 ++++++++++++++++++++++-----
|
||||
src/sched_deadline/deadline_test.c | 28 +++++++++++++++++++++++-----
|
||||
2 files changed, 45 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
|
||||
index 4a38ec2274c9..4860a40f5e6b 100644
|
||||
--- a/src/sched_deadline/cyclicdeadline.c
|
||||
+++ b/src/sched_deadline/cyclicdeadline.c
|
||||
@@ -278,6 +278,7 @@ static int setup_hr_tick(void)
|
||||
char path[MAX_PATH];
|
||||
char buf[500];
|
||||
static int set = 0;
|
||||
+ int hrtick_dl = 0;
|
||||
char *p;
|
||||
int ret;
|
||||
int len;
|
||||
@@ -311,18 +312,34 @@ static int setup_hr_tick(void)
|
||||
|
||||
ret = 1;
|
||||
|
||||
- p = strstr(buf, "HRTICK");
|
||||
- if (p + 3 >= buf) {
|
||||
+ p = strstr(buf, "HRTICK_DL");
|
||||
+ if (p && p - 3 >= buf) {
|
||||
+ hrtick_dl = 1;
|
||||
p -= 3;
|
||||
- if (strncmp(p, "NO_HRTICK", 9) == 0) {
|
||||
- ret = write(fd, "HRTICK", 6);
|
||||
- if (ret != 6)
|
||||
+ if (strncmp(p, "NO_HRTICK_DL", 12) == 0) {
|
||||
+ ret = write(fd, "HRTICK_DL", 9);
|
||||
+ if (ret != 9)
|
||||
ret = 0;
|
||||
else
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+ /* Backwards compatibility for kernel that only have HRTICK */
|
||||
+ if (!hrtick_dl) {
|
||||
+ p = strstr(buf, "HRTICK");
|
||||
+ if (p && p - 3 >= buf) {
|
||||
+ p -=3;
|
||||
+ if (strncmp(p, "NO_HRTICK", 9) == 0) {
|
||||
+ ret = write(fd, "HRTICK", 6);
|
||||
+ if (ret != 6)
|
||||
+ ret = 0;
|
||||
+ else
|
||||
+ ret = 1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
|
||||
index c1e890319895..a48c231c1281 100644
|
||||
--- a/src/sched_deadline/deadline_test.c
|
||||
+++ b/src/sched_deadline/deadline_test.c
|
||||
@@ -427,6 +427,7 @@ static int setup_hr_tick(void)
|
||||
char path[MAX_PATH];
|
||||
char buf[500];
|
||||
static int set = 0;
|
||||
+ int hrtick_dl = 0;
|
||||
char *p;
|
||||
int ret;
|
||||
int len;
|
||||
@@ -461,18 +462,35 @@ static int setup_hr_tick(void)
|
||||
|
||||
ret = 1;
|
||||
|
||||
- p = strstr(buf, "HRTICK");
|
||||
- if (p + 3 >= buf) {
|
||||
+ p = strstr(buf, "HRTICK_DL");
|
||||
+ if (p && p - 3 >= buf) {
|
||||
+ hrtick_dl = 1;
|
||||
p -= 3;
|
||||
- if (strncmp(p, "NO_HRTICK", 9) == 0) {
|
||||
- ret = write(fd, "HRTICK", 6);
|
||||
- if (ret != 6)
|
||||
+ if (strncmp(p, "NO_HRTICK_DL", 12) == 0) {
|
||||
+ ret = write(fd, "HRTICK_DL", 9);
|
||||
+ if (ret != 9)
|
||||
ret = 0;
|
||||
else
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+ /* Backwards compatibility for kernel that only have HRTICK */
|
||||
+ if (!hrtick_dl) {
|
||||
+ p = strstr(buf, "HRTICK");
|
||||
+ if (p && p - 3 >= buf) {
|
||||
+ p -=3;
|
||||
+ if (strncmp(p, "NO_HRTICK", 9) == 0) {
|
||||
+ ret = write(fd, "HRTICK", 6);
|
||||
+ if (ret != 6)
|
||||
+ ret = 0;
|
||||
+ else
|
||||
+ ret = 1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
--
|
||||
2.31.1
|
||||
|
Loading…
Reference in New Issue
Block a user