Skip to content

Commit 3662daf

Browse files
xzpeterKAGA-KOKO
authored andcommitted
sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters
The "isolcpus=" parameter allows sub-parameters before the cpulist is specified, and if the parser detects an unknown sub-parameters the whole parameter will be ignored. This design is incompatible with itself when new sub-parameters are added. An older kernel will not recognize the new sub-parameter and will invalidate the whole parameter so the CPU isolation will not take effect. It emits a warning: isolcpus: Error, unknown flag The better and compatible way is to allow "isolcpus=" to skip unknown sub-parameters, so that even if new sub-parameters are added an older kernel will still be able to behave as usual even if with the new sub-parameter specified on the command line. Ideally this should have been there when the first sub-parameter for "isolcpus=" was introduced. Suggested-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Xu <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 8f3d9f3 commit 3662daf

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

kernel/sched/isolation.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ __setup("nohz_full=", housekeeping_nohz_full_setup);
149149
static int __init housekeeping_isolcpus_setup(char *str)
150150
{
151151
unsigned int flags = 0;
152+
bool illegal = false;
153+
char *par;
154+
int len;
152155

153156
while (isalpha(*str)) {
154157
if (!strncmp(str, "nohz,", 5)) {
@@ -169,8 +172,22 @@ static int __init housekeeping_isolcpus_setup(char *str)
169172
continue;
170173
}
171174

172-
pr_warn("isolcpus: Error, unknown flag\n");
173-
return 0;
175+
/*
176+
* Skip unknown sub-parameter and validate that it is not
177+
* containing an invalid character.
178+
*/
179+
for (par = str, len = 0; *str && *str != ','; str++, len++) {
180+
if (!isalpha(*str) && *str != '_')
181+
illegal = true;
182+
}
183+
184+
if (illegal) {
185+
pr_warn("isolcpus: Invalid flag %.*s\n", len, par);
186+
return 0;
187+
}
188+
189+
pr_info("isolcpus: Skipped unknown flag %.*s\n", len, par);
190+
str++;
174191
}
175192

176193
/* Default behaviour for isolcpus without flags */

0 commit comments

Comments
 (0)