6aa7c32eae
- 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>
218 lines
4.2 KiB
Diff
218 lines
4.2 KiB
Diff
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
|
|
|