All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Changwoo Min <changwoo@igalia.com>
Cc: tj@kernel.org, void@manifault.com, david.dai@linux.dev,
	Gavin Guo <gavinguo@igalia.com>,
	kernel-dev@igalia.com, sched-ext@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/8] sched_ext: Mark a task enabled before ops.enable()
Date: Fri, 4 Dec 2026 07:10:45 +0100	[thread overview]
Message-ID: <axJZZUtd5tVYhpn8@gpd4> (raw)
In-Reply-To: <20261203045618.982539-3-changwoo@igalia.com>

On Thu, Dec 03, 2026 at 01:56:12PM +0900, Changwoo Min wrote:
> scx_enable_task() sets SCX_TASK_ENABLED only after ops.enable() returns.
> A task kfunc that accepts only enabled tasks, as scx_bpf_task_set_priv()
> will, then refuses calls from ops.enable(). That is where a scheduler
> sets up what it keeps for @p while controlling it.
> 
> Set the state before ops.enable() instead. ops.enable() can't fail, so @p
> can't end up marked enabled without having been enabled. The other
> SCX_TASK_ENABLED checks, in set_cpus_allowed_scx() and
> reweight_task_scx(), run under the rq lock, which ops.enable() also
> holds, so they can't see the earlier transition.
> 
> Suggested-by: Andrea Righi <arighi@nvidia.com>
> Signed-off-by: Changwoo Min <changwoo@igalia.com>

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> ---
>  kernel/sched/ext/ext.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index eaa68a1e9198..7e5f58f1d844 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -4740,8 +4740,12 @@ static void __scx_enable_task(struct scx_sched *sch, struct task_struct *p)
>  
>  void scx_enable_task(struct scx_sched *sch, struct task_struct *p)
>  {
> -	__scx_enable_task(sch, p);
> +	/*
> +	 * Task kfuncs must recognize @p as enabled from ops.enable() on. Setting
> +	 * the state before ops.enable() is safe because it can't fail.
> +	 */
>  	scx_set_task_state(p, SCX_TASK_ENABLED);
> +	__scx_enable_task(sch, p);
>  }
>  
>  /**
> -- 
> 2.56.1
> 

  reply	other threads:[~2026-12-04  6:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  4:56 [PATCH v2 0/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03  4:56 ` [PATCH v2 1/8] sched_ext: Reset task fields after ops.exit_task() Changwoo Min
2026-12-04  6:10   ` Andrea Righi
2026-12-04 17:04   ` Tejun Heo
2026-12-03  4:56 ` [PATCH v2 2/8] sched_ext: Mark a task enabled before ops.enable() Changwoo Min
2026-12-04  6:10   ` Andrea Righi [this message]
2026-12-04 17:02   ` Tejun Heo
2026-12-03  4:56 ` [PATCH v2 3/8] sched_ext: Add scx_bpf_sched_id() and scx_bpf_task_sched_id() Changwoo Min
2026-12-03  5:14   ` sashiko-bot
2026-12-04  6:44   ` Andrea Righi
2026-12-04 17:17   ` Tejun Heo
2026-12-03  4:56 ` [PATCH v2 4/8] selftests/sched_ext: Test " Changwoo Min
2026-12-03  5:14   ` sashiko-bot
2026-12-03  4:56 ` [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03  5:20   ` sashiko-bot
2026-12-04 17:09   ` Tejun Heo
2026-12-03  4:56 ` [PATCH v2 6/8] sched_ext: scx_qmap: Cache task_ctx in p->scx.bpf_priv Changwoo Min
2026-12-03  5:19   ` sashiko-bot
2026-12-03  4:56 ` [PATCH v2 7/8] selftests/sched_ext: Test p->scx.bpf_priv across class changes Changwoo Min
2026-12-03  5:26   ` sashiko-bot
2026-12-03  4:56 ` [PATCH v2 8/8] selftests/sched_ext: Test task field reset across sub-scheduler handoffs Changwoo Min
2026-12-03  5:32   ` sashiko-bot
2026-12-04 17:19 ` [PATCH v2 0/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Tejun Heo

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=axJZZUtd5tVYhpn8@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=david.dai@linux.dev \
    --cc=gavinguo@igalia.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.