Skip to contentSkip to conversation

sched: stop using magic values in sched_dynamic_mode

PATCH Applied Rasmus Villemoes 3 participants 5 messages Mar 25, 2021 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sched: stop using magic values in sched_dynamic_mode

Use the enum names which are also what is used in the switch() in sched_dynamic_update().

---
 kernel/sched/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +3 -3
index 98191218d891..3959481261bb 100644
@@ -5370,13 +5370,13 @@ static int preempt_dynamic_mode = preempt_dynamic_full;
 static int sched_dynamic_mode(const char *str)
 {
 	if (!strcmp(str, "none"))
-		return 0;
+		return preempt_dynamic_none;
 
 	if (!strcmp(str, "voluntary"))
-		return 1;
+		return preempt_dynamic_voluntary;
 
 	if (!strcmp(str, "full"))
-		return 2;
+		return preempt_dynamic_full;
 
 	return -1;
 }
Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 sched: use -EINVAL in sched_dynamic_mode

-1 is -EPERM which is a somewhat odd error to return from sched_dynamic_write(). No other callers care about which negative value is used.

---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index 3959481261bb..5b29261668a6 100644
@@ -5378,7 +5378,7 @@ static int sched_dynamic_mode(const char *str)
 	if (!strcmp(str, "full"))
 		return preempt_dynamic_full;
 
-	return -1;
+	return -EINVAL;
 }
 
 static void sched_dynamic_update(int mode)
Signature · 1 line
2.29.2
#2 lore raw

[tip: sched/core] sched/core: Use -EINVAL in sched_dynamic_mode()

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     c4681f3f1cfcfde0c95ff72f0bdb43f9ffd7f00e
Gitweb:        https://git.kernel.org/tip/c4681f3f1cfcfde0c95ff72f0bdb43f9ffd7f00e
Author:        Rasmus Villemoes <[email protected]>
AuthorDate:    Thu, 25 Mar 2021 01:45:15 +01:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Thu, 25 Mar 2021 11:39:13 +01:00

sched/core: Use -EINVAL in sched_dynamic_mode()

-1 is -EPERM which is a somewhat odd error to return from sched_dynamic_write(). No other callers care about which negative value is used.

---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index 1fe9d3f..95bd6ab 100644
@@ -5384,7 +5384,7 @@ static int sched_dynamic_mode(const char *str)
 	if (!strcmp(str, "full"))
 		return preempt_dynamic_full;
 
-	return -1;
+	return -EINVAL;
 }
 
 static void sched_dynamic_update(int mode)
#4 lore raw

[tip: sched/core] sched/core: Stop using magic values in sched_dynamic_mode()

In reply to Rasmus Villemoes
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     7e1b2eb74928b2478fd0630ce6c664334b480d00
Gitweb:        https://git.kernel.org/tip/7e1b2eb74928b2478fd0630ce6c664334b480d00
Author:        Rasmus Villemoes <[email protected]>
AuthorDate:    Thu, 25 Mar 2021 01:45:14 +01:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Thu, 25 Mar 2021 11:39:12 +01:00

sched/core: Stop using magic values in sched_dynamic_mode()

Use the enum names which are also what is used in the switch() in sched_dynamic_update().

---
 kernel/sched/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/sched/core.c +3 -3
index 3384ea7..1fe9d3f 100644
@@ -5376,13 +5376,13 @@ static int preempt_dynamic_mode = preempt_dynamic_full;
 static int sched_dynamic_mode(const char *str)
 {
 	if (!strcmp(str, "none"))
-		return 0;
+		return preempt_dynamic_none;
 
 	if (!strcmp(str, "voluntary"))
-		return 1;
+		return preempt_dynamic_voluntary;
 
 	if (!strcmp(str, "full"))
-		return 2;
+		return preempt_dynamic_full;
 
 	return -1;
 }