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