Skip to contentSkip to conversation

sched, output warning when isolcpus kernel parameter is invalid

PATCH New Prarit Bhargava 2 participants 2 messages Feb 4, 2016 – Feb 5, 2016 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched, output warning when isolcpus kernel parameter is invalid

The isolcpus kernel parameter restricts userspace from scheduling on the specified cpus. If a cpu is specified that is outside the range of 0 to nr_cpu_ids, cpulist_parse() will return -ERANGE, return an empty cpulist, and fail silently.

This patch adds an error message to isolated_cpu_setup() to indicate to the user that something has gone awry, and returns 0 on error.

Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/sched/core.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/sched/core.c +8 -1
index 9503d59..bce37ca 100644
@@ -6173,8 +6173,15 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)
 /* Setup the mask of cpus configured for isolated domains */
 static int __init isolated_cpu_setup(char *str)
 {
+	int ret;
+
 	alloc_bootmem_cpumask_var(&cpu_isolated_map);
-	cpulist_parse(str, cpu_isolated_map);
+	ret = cpulist_parse(str, cpu_isolated_map);
+	if (ret) {
+		pr_err("Error: kernel parameter isolcpus values must be between 0 and %d\n",
+		       nr_cpu_ids);
+		return 0;
+	}
 	return 1;
 }
 
Signature · 1 line
1.7.9.3
#1 lore raw

[tip:sched/core] sched/isolcpus: Output warning when the ' isolcpus=' kernel parameter is invalid

sched/isolcpus: Output warning when the 'isolcpus=' kernel parameter is invalid
Commit-ID:  a6e4491c682a7b28574a62e6f311a0acec50b318
Gitweb:     http://git.kernel.org/tip/a6e4491c682a7b28574a62e6f311a0acec50b318
Author:     Prarit Bhargava <[email protected]>
AuthorDate: Thu, 4 Feb 2016 09:38:00 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 5 Feb 2016 08:46:38 +0100

sched/isolcpus: Output warning when the 'isolcpus=' kernel parameter is invalid

The isolcpus= kernel boot parameter restricts userspace from scheduling on the specified CPUs.

If a CPU is specified that is outside the range of 0 to nr_cpu_ids, cpulist_parse() will return -ERANGE, return an empty cpulist, and fail silently.

This patch adds an error message to isolated_cpu_setup() to indicate to the user that something has gone awry, and returns 0 on error.

Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
[ Twiddled some details. ]
---
 kernel/sched/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/sched/core.c +7 -2
index 9503d59..24fcdbf 100644
@@ -6173,11 +6173,16 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)
 /* Setup the mask of cpus configured for isolated domains */
 static int __init isolated_cpu_setup(char *str)
 {
+	int ret;
+
 	alloc_bootmem_cpumask_var(&cpu_isolated_map);
-	cpulist_parse(str, cpu_isolated_map);
+	ret = cpulist_parse(str, cpu_isolated_map);
+	if (ret) {
+		pr_err("sched: Error, all isolcpus= values must be between 0 and %d\n", nr_cpu_ids);
+		return 0;
+	}
 	return 1;
 }
-
 __setup("isolcpus=", isolated_cpu_setup);
 
 struct s_data {