Skip to contentSkip to conversation

sched/core: fix sched_rt_global_validate

PATCH In review Juri Lelli 2 participants 4 messages Jan 31, 2014 – Feb 3, 2014 Scheduler

lore
Share & tools
lore

Juri Lelli

author
#0 lore raw

PATCH 1/1 sched/core: fix sched_rt_global_validate

Don't compare sysctl_sched_rt_runtime against sysctl_sched_rt_period if the former is equal to RUNTIME_INF, otherwise disabling -rt bandwidth management always fails.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +2 -1
index 210a12a..5c0a304 100644
@@ -7477,7 +7477,8 @@ static int sched_rt_global_validate(void)
 	if (sysctl_sched_rt_period <= 0)
 		return -EINVAL;
 
-	if (sysctl_sched_rt_runtime > sysctl_sched_rt_period)
+	if ((sysctl_sched_rt_runtime != RUNTIME_INF) &&
+		(sysctl_sched_rt_runtime > sysctl_sched_rt_period))
 		return -EINVAL;
 
 	return 0;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 16 lines · Juri Lelli

Don't compare sysctl_sched_rt_runtime against sysctl_sched_rt_period if the former is equal to RUNTIME_INF, otherwise disabling -rt bandwidth management always fails.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +0 -0
index 210a12a..5c0a304 100644

kernel/sched/core.c static int sched_rt_global_validate(void) · line 7482

Quoted 7 lines
kernel/sched/core.c +2 -1
@@ -7477,7 +7477,8 @@ static int sched_rt_global_validate(void)
 	if (sysctl_sched_rt_period <= 0)
 		return -EINVAL;
 
-	if (sysctl_sched_rt_runtime > sysctl_sched_rt_period)
+	if ((sysctl_sched_rt_runtime != RUNTIME_INF) &&
+		(sysctl_sched_rt_runtime > sysctl_sched_rt_period))
 		return -EINVAL;

Won't this be caught by the test above?

#define RUNTIME_INF ((u64)~0ULL)

which means that if sysctl_sched_rt_runtime is set to RUNTIME_INF, it will trigger on the previous test, and the first part of this test will always be true.

Or have I suffered catastrophic monday-morning braindamage?

Signature · 1 line
Henrik Austad
author
#2 lore raw
Quoted 27 lines · Henrik Austad
Quoted 16 lines · Juri Lelli

Don't compare sysctl_sched_rt_runtime against sysctl_sched_rt_period if the former is equal to RUNTIME_INF, otherwise disabling -rt bandwidth management always fails.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +0 -0
index 210a12a..5c0a304 100644

kernel/sched/core.c static int sched_rt_global_validate(void) · line 7482

Quoted 7 lines
kernel/sched/core.c +2 -1
@@ -7477,7 +7477,8 @@ static int sched_rt_global_validate(void)
 	if (sysctl_sched_rt_period <= 0)
 		return -EINVAL;
 
-	if (sysctl_sched_rt_runtime > sysctl_sched_rt_period)
+	if ((sysctl_sched_rt_runtime != RUNTIME_INF) &&
+		(sysctl_sched_rt_runtime > sysctl_sched_rt_period))
 		return -EINVAL;

Won't this be caught by the test above?

Quoted 8 lines

#define RUNTIME_INF ((u64)~0ULL)

which means that if sysctl_sched_rt_runtime is set to RUNTIME_INF, it will trigger on the previous test, and the first part of this test will always be true.

Or have I suffered catastrophic monday-morning braindamage?

As I understand it. When you do

echo -1 > /proc/sys/kernel/sched_rt_runtime_us

sysctl_sched_rt_runtime is actually set to -1 (being an int).
But then you compare it against and unsigned int, so the cast converts it to actually be RUNTIME_INF, and thus greater than sysctl_sched_rt_period (so the function returns -EINVAL, while you'd want it to return 0, as you are disabling -rt throttling).

Makes sense?

Thanks,

- Juri

#3 lore raw
Quoted 34 lines · Juri Lelli
Quoted 33 lines · Henrik Austad
Quoted 16 lines · Juri Lelli

Don't compare sysctl_sched_rt_runtime against sysctl_sched_rt_period if the former is equal to RUNTIME_INF, otherwise disabling -rt bandwidth management always fails.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/core.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +0 -0
index 210a12a..5c0a304 100644

kernel/sched/core.c static int sched_rt_global_validate(void) · line 7482

Quoted 7 lines
kernel/sched/core.c +2 -1
@@ -7477,7 +7477,8 @@ static int sched_rt_global_validate(void)
 	if (sysctl_sched_rt_period <= 0)
 		return -EINVAL;
 
-	if (sysctl_sched_rt_runtime > sysctl_sched_rt_period)
+	if ((sysctl_sched_rt_runtime != RUNTIME_INF) &&
+		(sysctl_sched_rt_runtime > sysctl_sched_rt_period))
 		return -EINVAL;

Won't this be caught by the test above?

#define RUNTIME_INF ((u64)~0ULL)

which means that if sysctl_sched_rt_runtime is set to RUNTIME_INF, it will trigger on the previous test, and the first part of this test will always be true.

Quoted 8 lines
Quoted 2 lines

Or have I suffered catastrophic monday-morning braindamage?

As I understand it. When you do

echo -1 > /proc/sys/kernel/sched_rt_runtime_us

sysctl_sched_rt_runtime is actually set to -1 (being an int).

Yes.

Quoted 4 lines

But then you compare it against and unsigned int, so the cast converts it to actually be RUNTIME_INF, and thus greater than sysctl_sched_rt_period (so the function returns -EINVAL, while you'd want it to return 0, as you are disabling -rt throttling).

Ah, yes, it comes down to my early-monday brain hemorrhage, mixing up rt_period and rt_runtime. My apologies!

Quoted 1 line

Makes sense?

Yes it does.

Signature · 1 line
Henrik Austad