* [PATCH v3] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters
@ 2020-04-03 22:35 Peter Xu
2020-04-14 21:57 ` Peter Xu
2020-04-15 8:44 ` [tip: sched/core] " tip-bot2 for Peter Xu
0 siblings, 2 replies; 3+ messages in thread
From: Peter Xu @ 2020-04-03 22:35 UTC (permalink / raw)
To: linux-kernel
Cc: peterx, Ming Lei, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Luiz Capitulino, Thomas Gleixner
The "isolcpus=" parameter allows sub-parameters to exist before the
cpulist is specified, and if it sees unknown sub-parameters the whole
parameter will be ignored. This design is incompatible with itself
when we add more sub-parameters to "isolcpus=", because the old
kernels will not recognize the new "isolcpus=" sub-parameters, then it
will invalidate the whole parameter so the CPU isolation will not
really take effect if we start to use the new sub-parameters while
later we reboot into an old kernel. Instead we will see this when
booting the old kernel:
isolcpus: Error, unknown flag
The better and compatible way is to allow "isolcpus=" to skip unknown
sub-parameters, so that even if we add new sub-parameters to it the
old kernel will still be able to behave as usual even if with the new
sub-parameter is specified.
Ideally this patch should be there when we introduce the first
sub-parameter for "isolcpus=", so it's already a bit late. However
late is better than nothing.
CC: Ming Lei <ming.lei@redhat.com>
CC: Ingo Molnar <mingo@redhat.com>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Juri Lelli <juri.lelli@redhat.com>
CC: Luiz Capitulino <lcapitulino@redhat.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
v3:
- add brackets for for loop
- move "illegal" a bit higher, which may look tiny bit nicer
- also allow '_'
v2:
- only allow isalpha() for sub-parameters [tglx]
---
kernel/sched/isolation.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 008d6ac2342b..808244f3ddd9 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -149,6 +149,9 @@ __setup("nohz_full=", housekeeping_nohz_full_setup);
static int __init housekeeping_isolcpus_setup(char *str)
{
unsigned int flags = 0;
+ bool illegal = false;
+ char *par;
+ int len;
while (isalpha(*str)) {
if (!strncmp(str, "nohz,", 5)) {
@@ -169,8 +172,22 @@ static int __init housekeeping_isolcpus_setup(char *str)
continue;
}
- pr_warn("isolcpus: Error, unknown flag\n");
- return 0;
+ /*
+ * Skip unknown sub-parameter and validate that it is not
+ * containing an invalid character.
+ */
+ for (par = str, len = 0; *str && *str != ','; str++, len++) {
+ if (!isalpha(*str) && *str != '_')
+ illegal = true;
+ }
+
+ if (illegal) {
+ pr_warn("isolcpus: Invalid flag %.*s\n", len, par);
+ return 0;
+ }
+
+ pr_info("isolcpus: Skipped unknown flag %.*s\n", len, par);
+ str++;
}
/* Default behaviour for isolcpus without flags */
--
2.24.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters
2020-04-03 22:35 [PATCH v3] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters Peter Xu
@ 2020-04-14 21:57 ` Peter Xu
2020-04-15 8:44 ` [tip: sched/core] " tip-bot2 for Peter Xu
1 sibling, 0 replies; 3+ messages in thread
From: Peter Xu @ 2020-04-14 21:57 UTC (permalink / raw)
To: linux-kernel
Cc: Ming Lei, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Luiz Capitulino, Thomas Gleixner
Ping - Thomas, do you think this version is ok to you?
This has missed 5.7 already, am I right?
Thanks,
On Fri, Apr 03, 2020 at 06:35:17PM -0400, Peter Xu wrote:
> The "isolcpus=" parameter allows sub-parameters to exist before the
> cpulist is specified, and if it sees unknown sub-parameters the whole
> parameter will be ignored. This design is incompatible with itself
> when we add more sub-parameters to "isolcpus=", because the old
> kernels will not recognize the new "isolcpus=" sub-parameters, then it
> will invalidate the whole parameter so the CPU isolation will not
> really take effect if we start to use the new sub-parameters while
> later we reboot into an old kernel. Instead we will see this when
> booting the old kernel:
>
> isolcpus: Error, unknown flag
>
> The better and compatible way is to allow "isolcpus=" to skip unknown
> sub-parameters, so that even if we add new sub-parameters to it the
> old kernel will still be able to behave as usual even if with the new
> sub-parameter is specified.
>
> Ideally this patch should be there when we introduce the first
> sub-parameter for "isolcpus=", so it's already a bit late. However
> late is better than nothing.
>
> CC: Ming Lei <ming.lei@redhat.com>
> CC: Ingo Molnar <mingo@redhat.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Juri Lelli <juri.lelli@redhat.com>
> CC: Luiz Capitulino <lcapitulino@redhat.com>
> Suggested-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> v3:
> - add brackets for for loop
> - move "illegal" a bit higher, which may look tiny bit nicer
> - also allow '_'
> v2:
> - only allow isalpha() for sub-parameters [tglx]
> ---
> kernel/sched/isolation.c | 21 +++++++++++++++++++--
> 1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
> index 008d6ac2342b..808244f3ddd9 100644
> --- a/kernel/sched/isolation.c
> +++ b/kernel/sched/isolation.c
> @@ -149,6 +149,9 @@ __setup("nohz_full=", housekeeping_nohz_full_setup);
> static int __init housekeeping_isolcpus_setup(char *str)
> {
> unsigned int flags = 0;
> + bool illegal = false;
> + char *par;
> + int len;
>
> while (isalpha(*str)) {
> if (!strncmp(str, "nohz,", 5)) {
> @@ -169,8 +172,22 @@ static int __init housekeeping_isolcpus_setup(char *str)
> continue;
> }
>
> - pr_warn("isolcpus: Error, unknown flag\n");
> - return 0;
> + /*
> + * Skip unknown sub-parameter and validate that it is not
> + * containing an invalid character.
> + */
> + for (par = str, len = 0; *str && *str != ','; str++, len++) {
> + if (!isalpha(*str) && *str != '_')
> + illegal = true;
> + }
> +
> + if (illegal) {
> + pr_warn("isolcpus: Invalid flag %.*s\n", len, par);
> + return 0;
> + }
> +
> + pr_info("isolcpus: Skipped unknown flag %.*s\n", len, par);
> + str++;
> }
>
> /* Default behaviour for isolcpus without flags */
> --
> 2.24.1
>
--
Peter Xu
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: sched/core] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters
2020-04-03 22:35 [PATCH v3] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters Peter Xu
2020-04-14 21:57 ` Peter Xu
@ 2020-04-15 8:44 ` tip-bot2 for Peter Xu
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Peter Xu @ 2020-04-15 8:44 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thomas Gleixner, Peter Xu, x86, LKML
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 3662daf023500dc084fa3b96f68a6f46179ddc73
Gitweb: https://git.kernel.org/tip/3662daf023500dc084fa3b96f68a6f46179ddc73
Author: Peter Xu <peterx@redhat.com>
AuthorDate: Fri, 03 Apr 2020 18:35:17 -04:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 15 Apr 2020 10:38:26 +02:00
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 <tglx@linutronix.de>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200403223517.406353-1-peterx@redhat.com
---
kernel/sched/isolation.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 008d6ac..808244f 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -149,6 +149,9 @@ __setup("nohz_full=", housekeeping_nohz_full_setup);
static int __init housekeeping_isolcpus_setup(char *str)
{
unsigned int flags = 0;
+ bool illegal = false;
+ char *par;
+ int len;
while (isalpha(*str)) {
if (!strncmp(str, "nohz,", 5)) {
@@ -169,8 +172,22 @@ static int __init housekeeping_isolcpus_setup(char *str)
continue;
}
- pr_warn("isolcpus: Error, unknown flag\n");
- return 0;
+ /*
+ * Skip unknown sub-parameter and validate that it is not
+ * containing an invalid character.
+ */
+ for (par = str, len = 0; *str && *str != ','; str++, len++) {
+ if (!isalpha(*str) && *str != '_')
+ illegal = true;
+ }
+
+ if (illegal) {
+ pr_warn("isolcpus: Invalid flag %.*s\n", len, par);
+ return 0;
+ }
+
+ pr_info("isolcpus: Skipped unknown flag %.*s\n", len, par);
+ str++;
}
/* Default behaviour for isolcpus without flags */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-15 8:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 22:35 [PATCH v3] sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters Peter Xu
2020-04-14 21:57 ` Peter Xu
2020-04-15 8:44 ` [tip: sched/core] " tip-bot2 for Peter Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®