[PATCH] sched: Fix preemption string of preempt_dynamic_none

Thomas Weißschuh posted 1 patch 6 months, 2 weeks ago
There is a newer version of this series
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] sched: Fix preemption string of preempt_dynamic_none
Posted by Thomas Weißschuh 6 months, 2 weeks ago
Zero is a valid value for "preempt_dynamic_mode", namely
"preempt_dynamic_none".

Fix the off-by-one in preempt_model_str(), so that "preempty_dynamic_none"
is correctly formatted as PREEMPT(none) instead of PREEMPT(undef).

Fixes: 8bdc5daaa01e ("sched: Add a generic function to return the preemption string")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index dce50fa57471dffc4311b9d393ae300a43d38d20..021b0a703d094b3386c5ba50e0e111e3a7c2b3df 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7663,7 +7663,7 @@ const char *preempt_model_str(void)
 
 		if (IS_ENABLED(CONFIG_PREEMPT_DYNAMIC)) {
 			seq_buf_printf(&s, "(%s)%s",
-				       preempt_dynamic_mode > 0 ?
+				       preempt_dynamic_mode >= 0 ?
 				       preempt_modes[preempt_dynamic_mode] : "undef",
 				       brace ? "}" : "");
 			return seq_buf_str(&s);

---
base-commit: 546b1c9e93c2bb8cf5ed24e0be1c86bb089b3253
change-id: 20250603-preempt-str-none-d21231cc2238

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Re: [PATCH] sched: Fix preemption string of preempt_dynamic_none
Posted by Sebastian Andrzej Siewior 6 months, 1 week ago
On 2025-06-03 11:52:13 [+0200], Thomas Weißschuh wrote:
> Zero is a valid value for "preempt_dynamic_mode", namely
> "preempt_dynamic_none".
> 
> Fix the off-by-one in preempt_model_str(), so that "preempty_dynamic_none"
> is correctly formatted as PREEMPT(none) instead of PREEMPT(undef).
> 
> Fixes: 8bdc5daaa01e ("sched: Add a generic function to return the preemption string")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

A gentle ping.

Sebastian
Re: [PATCH] sched: Fix preemption string of preempt_dynamic_none
Posted by Shrikanth Hegde 6 months, 2 weeks ago

On 6/3/25 15:22, Thomas Weißschuh wrote:
> Zero is a valid value for "preempt_dynamic_mode", namely
> "preempt_dynamic_none".
> 
> Fix the off-by-one in preempt_model_str(), so that "preempty_dynamic_none"
> is correctly formatted as PREEMPT(none) instead of PREEMPT(undef).
> 
> Fixes: 8bdc5daaa01e ("sched: Add a generic function to return the preemption string")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
>   kernel/sched/core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index dce50fa57471dffc4311b9d393ae300a43d38d20..021b0a703d094b3386c5ba50e0e111e3a7c2b3df 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7663,7 +7663,7 @@ const char *preempt_model_str(void)
>   
>   		if (IS_ENABLED(CONFIG_PREEMPT_DYNAMIC)) {
>   			seq_buf_printf(&s, "(%s)%s",
> -				       preempt_dynamic_mode > 0 ?
> +				       preempt_dynamic_mode >= 0 ?
>   				       preempt_modes[preempt_dynamic_mode] : "undef",
>   				       brace ? "}" : "");
>   			return seq_buf_str(&s);
> 

Yes. It looks correct with patch:
latency: 0 us, #1/1, CPU#0 | (M:PREEMPT(none) VP:0, KP:0, SP:0 HP:0 #P:80)

Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com>

Re: [PATCH] sched: Fix preemption string of preempt_dynamic_none
Posted by Sebastian Andrzej Siewior 6 months, 2 weeks ago
On 2025-06-03 11:52:13 [+0200], Thomas Weißschuh wrote:
> Zero is a valid value for "preempt_dynamic_mode", namely
> "preempt_dynamic_none".
> 
> Fix the off-by-one in preempt_model_str(), so that "preempty_dynamic_none"
> is correctly formatted as PREEMPT(none) instead of PREEMPT(undef).
> 
> Fixes: 8bdc5daaa01e ("sched: Add a generic function to return the preemption string")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Sebastian