All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] sched_deadline: HRTICK for newer kernels
@ 2021-07-23 19:16 John Kacur
  2021-07-23 19:16 ` [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file in kernel John Kacur
  2021-07-23 19:16 ` [PATCH 2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests John Kacur
  0 siblings, 2 replies; 3+ messages in thread
From: John Kacur @ 2021-07-23 19:16 UTC (permalink / raw)
  To: RT
  Cc: Clark Williams, Daniel Wagner, Daniel Bristot de Oliveria,
	Juri Lelli, Steven Rostedt, John Kacur

Newer kernels have HRTICK_DL which is a HRTICK for the deadline
scheduler only.

In addion newer kernels rename
/sys/kernel/debug/sched_features
to
/sys/kernel/debug/sched/features

These changes use HRTICK_DL if available and make use of the
new file name in a backwards compatible manner.

These changes are based on changes in util.c in the stalld program.
The stalld program itself was based on code in the sched_deadline
programs in this suite.

John Kacur (2):
  sched_deadline: Accommodate new location of HRTICK file in kernel
  sched_deadline: Use HRTICK_DL for sched_deadline tests

 src/sched_deadline/cyclicdeadline.c | 92 +++++++++++++++++++++++------
 src/sched_deadline/deadline_test.c  | 89 ++++++++++++++++++++++------
 2 files changed, 145 insertions(+), 36 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file in kernel
  2021-07-23 19:16 [PATCH 0/2] sched_deadline: HRTICK for newer kernels John Kacur
@ 2021-07-23 19:16 ` John Kacur
  2021-07-23 19:16 ` [PATCH 2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests John Kacur
  1 sibling, 0 replies; 3+ messages in thread
From: John Kacur @ 2021-07-23 19:16 UTC (permalink / raw)
  To: RT
  Cc: Clark Williams, Daniel Wagner, Daniel Bristot de Oliveria,
	Juri Lelli, Steven Rostedt, John Kacur

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests
  2021-07-23 19:16 [PATCH 0/2] sched_deadline: HRTICK for newer kernels John Kacur
  2021-07-23 19:16 ` [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file in kernel John Kacur
@ 2021-07-23 19:16 ` John Kacur
  1 sibling, 0 replies; 3+ messages in thread
From: John Kacur @ 2021-07-23 19:16 UTC (permalink / raw)
  To: RT
  Cc: Clark Williams, Daniel Wagner, Daniel Bristot de Oliveria,
	Juri Lelli, Steven Rostedt, John Kacur

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-23 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 19:16 [PATCH 0/2] sched_deadline: HRTICK for newer kernels John Kacur
2021-07-23 19:16 ` [PATCH 1/2] sched_deadline: Accommodate new location of HRTICK file in kernel John Kacur
2021-07-23 19:16 ` [PATCH 2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests John Kacur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.