|
|
0d4f16 |
From 84c45a66bf077be31c9e0cf85b72896798966826 Mon Sep 17 00:00:00 2001
|
|
|
0d4f16 |
From: John Kacur <jkacur@redhat.com>
|
|
|
0d4f16 |
Date: Thu, 22 Jul 2021 16:30:13 -0400
|
|
|
0d4f16 |
Subject: [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file
|
|
|
0d4f16 |
in kernel
|
|
|
0d4f16 |
|
|
|
0d4f16 |
Newer kernels rename /sys/kernel/debug/sched_features to
|
|
|
0d4f16 |
/sys/kernel/debug/sched/features
|
|
|
0d4f16 |
|
|
|
0d4f16 |
Modify sched_deadline tests to look for the new file and if that fails
|
|
|
0d4f16 |
look for the old file name
|
|
|
0d4f16 |
|
|
|
0d4f16 |
These functions are based on ones in stalld, and stalld itself has
|
|
|
0d4f16 |
functions based on the sched_deadline programs in rt-tests
|
|
|
0d4f16 |
|
|
|
0d4f16 |
Signed-off-by: John Kacur <jkacur@redhat.com>
|
|
|
0d4f16 |
---
|
|
|
0d4f16 |
src/sched_deadline/cyclicdeadline.c | 65 ++++++++++++++++++++++-------
|
|
|
0d4f16 |
src/sched_deadline/deadline_test.c | 61 +++++++++++++++++++++------
|
|
|
0d4f16 |
2 files changed, 100 insertions(+), 26 deletions(-)
|
|
|
0d4f16 |
|
|
|
0d4f16 |
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
|
|
|
0d4f16 |
index 8447424273ee..4a38ec2274c9 100644
|
|
|
0d4f16 |
--- a/src/sched_deadline/cyclicdeadline.c
|
|
|
0d4f16 |
+++ b/src/sched_deadline/cyclicdeadline.c
|
|
|
0d4f16 |
@@ -230,12 +230,53 @@ found:
|
|
|
0d4f16 |
mark_fd = open(files, O_WRONLY);
|
|
|
0d4f16 |
}
|
|
|
0d4f16 |
|
|
|
0d4f16 |
+/*
|
|
|
0d4f16 |
+ * Return true if file exists
|
|
|
0d4f16 |
+ */
|
|
|
0d4f16 |
+static int check_file_exists(char *path)
|
|
|
0d4f16 |
+{
|
|
|
0d4f16 |
+ int ret;
|
|
|
0d4f16 |
+ struct stat st;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ ret = !stat(path, &st);
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ return ret;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+}
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+/*
|
|
|
0d4f16 |
+ * Return 0 on success
|
|
|
0d4f16 |
+ */
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+static int fill_sched_features(char *path)
|
|
|
0d4f16 |
+{
|
|
|
0d4f16 |
+ int ret;
|
|
|
0d4f16 |
+ const char *debugfs;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ debugfs = find_debugfs();
|
|
|
0d4f16 |
+ if (strlen(debugfs) == 0)
|
|
|
0d4f16 |
+ return -1;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ snprintf(path, MAX_PATH, "%s/sched/features", debugfs);
|
|
|
0d4f16 |
+ ret = check_file_exists(path);
|
|
|
0d4f16 |
+ if (ret)
|
|
|
0d4f16 |
+ return 0;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ snprintf(path, MAX_PATH, "%s/sched_features", debugfs);
|
|
|
0d4f16 |
+ ret = check_file_exists(path);
|
|
|
0d4f16 |
+ if (ret)
|
|
|
0d4f16 |
+ return 0;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ memset(path, 0, MAX_PATH);
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ return ret;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+}
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
static int setup_hr_tick(void)
|
|
|
0d4f16 |
{
|
|
|
0d4f16 |
- const char *debugfs = find_debugfs();
|
|
|
0d4f16 |
- char files[strlen(debugfs) + strlen("/sched_features") + 1];
|
|
|
0d4f16 |
+ char path[MAX_PATH];
|
|
|
0d4f16 |
char buf[500];
|
|
|
0d4f16 |
- struct stat st;
|
|
|
0d4f16 |
static int set = 0;
|
|
|
0d4f16 |
char *p;
|
|
|
0d4f16 |
int ret;
|
|
|
0d4f16 |
@@ -244,27 +285,23 @@ static int setup_hr_tick(void)
|
|
|
0d4f16 |
|
|
|
0d4f16 |
if (set)
|
|
|
0d4f16 |
return 1;
|
|
|
0d4f16 |
-
|
|
|
0d4f16 |
set = 1;
|
|
|
0d4f16 |
|
|
|
0d4f16 |
- if (strlen(debugfs) == 0)
|
|
|
0d4f16 |
- return 0;
|
|
|
0d4f16 |
-
|
|
|
0d4f16 |
- sprintf(files, "%s/sched_features", debugfs);
|
|
|
0d4f16 |
- ret = stat(files, &st);
|
|
|
0d4f16 |
- if (ret < 0)
|
|
|
0d4f16 |
+ ret = fill_sched_features(path);
|
|
|
0d4f16 |
+ if (ret)
|
|
|
0d4f16 |
return 0;
|
|
|
0d4f16 |
|
|
|
0d4f16 |
- fd = open(files, O_RDWR);
|
|
|
0d4f16 |
- perror(files);
|
|
|
0d4f16 |
- if (fd < 0)
|
|
|
0d4f16 |
+ fd = open(path, O_RDWR);
|
|
|
0d4f16 |
+ if (fd < 0) {
|
|
|
0d4f16 |
+ perror(path);
|
|
|
0d4f16 |
return 0;
|
|
|
0d4f16 |
+ }
|
|
|
0d4f16 |
|
|
|
0d4f16 |
len = sizeof(buf);
|
|
|
0d4f16 |
|
|
|
0d4f16 |
ret = read(fd, buf, len);
|
|
|
0d4f16 |
if (ret < 0) {
|
|
|
0d4f16 |
- perror(files);
|
|
|
0d4f16 |
+ perror(path);
|
|
|
0d4f16 |
close(fd);
|
|
|
0d4f16 |
return 0;
|
|
|
0d4f16 |
}
|
|
|
0d4f16 |
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
|
|
|
0d4f16 |
index 395c2370f69a..c1e890319895 100644
|
|
|
0d4f16 |
--- a/src/sched_deadline/deadline_test.c
|
|
|
0d4f16 |
+++ b/src/sched_deadline/deadline_test.c
|
|
|
0d4f16 |
@@ -368,6 +368,49 @@ found:
|
|
|
0d4f16 |
mark_fd = open(files, O_WRONLY);
|
|
|
0d4f16 |
}
|
|
|
0d4f16 |
|
|
|
0d4f16 |
+/*
|
|
|
0d4f16 |
+ * Return true if file exists
|
|
|
0d4f16 |
+ */
|
|
|
0d4f16 |
+static int check_file_exists(char *path)
|
|
|
0d4f16 |
+{
|
|
|
0d4f16 |
+ int ret;
|
|
|
0d4f16 |
+ struct stat st;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ ret = !stat(path, &st);
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ return ret;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+}
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+/*
|
|
|
0d4f16 |
+ * Return 0 on success
|
|
|
0d4f16 |
+ */
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+static int fill_sched_features(char *path)
|
|
|
0d4f16 |
+{
|
|
|
0d4f16 |
+ int ret;
|
|
|
0d4f16 |
+ const char *debugfs;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ debugfs = find_debugfs();
|
|
|
0d4f16 |
+ if (strlen(debugfs) == 0)
|
|
|
0d4f16 |
+ return -1;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ snprintf(path, MAX_PATH, "%s/sched/features", debugfs);
|
|
|
0d4f16 |
+ ret = check_file_exists(path);
|
|
|
0d4f16 |
+ if (ret)
|
|
|
0d4f16 |
+ return 0;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ snprintf(path, MAX_PATH, "%s/sched_features", debugfs);
|
|
|
0d4f16 |
+ ret = check_file_exists(path);
|
|
|
0d4f16 |
+ if (ret)
|
|
|
0d4f16 |
+ return 0;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ memset(path, 0, MAX_PATH);
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+ return ret;
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
+}
|
|
|
0d4f16 |
+
|
|
|
0d4f16 |
/**
|
|
|
0d4f16 |
* setup_hr_tick - Enable the HRTICK in sched_features (if available)
|
|
|
0d4f16 |
*
|
|
|
0d4f16 |
@@ -381,10 +424,8 @@ found:
|
|
|
0d4f16 |
*/
|
|
|
0d4f16 |
static int setup_hr_tick(void)
|
|
|
0d4f16 |
{
|
|
|
0d4f16 |
- const char *debugfs = find_debugfs();
|
|
|
0d4f16 |
- char files[strlen(debugfs) + strlen("/sched_features") + 1];
|
|
|
0d4f16 |
+ char path[MAX_PATH];
|
|
|
0d4f16 |
char buf[500];
|
|
|
0d4f16 |
- struct stat st;
|
|
|
0d4f16 |
static int set = 0;
|
|
|
0d4f16 |
char *p;
|
|
|
0d4f16 |
int ret;
|
|
|
0d4f16 |
@@ -396,17 +437,13 @@ static int setup_hr_tick(void)
|
|
|
0d4f16 |
|
|
|
0d4f16 |
set = 1;
|
|
|
0d4f16 |
|
|
|
0d4f16 |
- if (strlen(debugfs) == 0)
|
|
|
0d4f16 |
- return 0;
|
|
|
0d4f16 |
-
|
|
|
0d4f16 |
- sprintf(files, "%s/sched_features", debugfs);
|
|
|
0d4f16 |
- ret = stat(files, &st);
|
|
|
0d4f16 |
- if (ret < 0)
|
|
|
0d4f16 |
+ ret = fill_sched_features(path);
|
|
|
0d4f16 |
+ if (ret)
|
|
|
0d4f16 |
return 0;
|
|
|
0d4f16 |
|
|
|
0d4f16 |
- fd = open(files, O_RDWR);
|
|
|
0d4f16 |
+ fd = open(path, O_RDWR);
|
|
|
0d4f16 |
if (fd < 0) {
|
|
|
0d4f16 |
- perror(files);
|
|
|
0d4f16 |
+ perror(path);
|
|
|
0d4f16 |
return 0;
|
|
|
0d4f16 |
}
|
|
|
0d4f16 |
|
|
|
0d4f16 |
@@ -414,7 +451,7 @@ static int setup_hr_tick(void)
|
|
|
0d4f16 |
|
|
|
0d4f16 |
ret = read(fd, buf, len);
|
|
|
0d4f16 |
if (ret < 0) {
|
|
|
0d4f16 |
- perror(files);
|
|
|
0d4f16 |
+ perror(path);
|
|
|
0d4f16 |
close(fd);
|
|
|
0d4f16 |
return 0;
|
|
|
0d4f16 |
}
|
|
|
0d4f16 |
--
|
|
|
0d4f16 |
2.31.1
|
|
|
0d4f16 |
|