From: Andrea Righi <arighi@nvidia.com>
To: Samuele Mariotti <smariotti@disroot.org>
Cc: tj@kernel.org, void@manifault.com, changwoo@igalia.com,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org,
Paolo Valente <paolo.valente@unimore.it>
Subject: Re: [PATCH BUGFIX 1/1] sched_ext: Fix missing warning in scx_set_task_state() default case
Date: Thu, 2 Apr 2026 15:07:08 +0200 [thread overview]
Message-ID: <ac5p_Ct9uE5JlYLn@gpd4> (raw)
In-Reply-To: <20260402115707.1200476-1-smariotti@disroot.org>
Hi Samuele,
On Thu, Apr 02, 2026 at 01:57:07PM +0200, Samuele Mariotti wrote:
> In scx_set_task_state(), the default case was setting the
> warn flag, but then returning immediately. This is problematic
> because the only purpose of the warn flag is to trigger
> WARN_ONCE, but the early return prevented it from ever firing,
> leaving invalid task states undetected and untraced.
>
> To fix this, a WARN_ONCE call is now added directly in the
> default case.
>
> The fix addresses two aspects:
>
> - Guarantees the invalid task states are properly logged
> and traced.
>
> - Provides a distinct warning message
> ("sched_ext: Invalid task state") specifically for
> states outside the defined scx_task_state enum values,
> making it easier to distinguish from other transition
> warnings.
>
> This ensures proper detection and reporting of invalid states.
>
> Signed-off-by: Samuele Mariotti <smariotti@disroot.org>
> Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Nice catch, we should probably add:
Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
With that:
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Thanks,
-Andrea
> ---
> kernel/sched/ext.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 1594987d637b..10683ce4e415 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -2863,7 +2863,8 @@ static void scx_set_task_state(struct task_struct *p, enum scx_task_state state)
> warn = prev_state != SCX_TASK_READY;
> break;
> default:
> - warn = true;
> + WARN_ONCE(1, "sched_ext: Invalid task state %d -> %d for %s[%d]",
> + prev_state, state, p->comm, p->pid);
> return;
> }
>
> --
> 2.47.3
>
prev parent reply other threads:[~2026-04-02 13:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 11:57 [PATCH BUGFIX 1/1] sched_ext: Fix missing warning in scx_set_task_state() default case Samuele Mariotti
2026-04-02 13:07 ` Andrea Righi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ac5p_Ct9uE5JlYLn@gpd4 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@unimore.it \
--cc=sched-ext@lists.linux.dev \
--cc=smariotti@disroot.org \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox