diff mbox series

[2/2] sched_deadline: Use HRTICK_DL for sched_deadline tests

Message ID 20210723191609.14072-3-jkacur@redhat.com
State New
Headers show
Series sched_deadline: HRTICK for newer kernels | expand

Commit Message

John Kacur July 23, 2021, 7:16 p.m. UTC
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 mbox series

Patch

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;
 }