From: sashiko-bot@kernel.org
To: "Cheng-Yang Chou" <yphbchou0911@gmail.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH v3 1/2] sched_ext: Add dispatch transaction API
Date: Sat, 09 May 2026 19:49:54 +0000 [thread overview]
Message-ID: <20260509194954.C87E0C2BCB2@smtp.kernel.org> (raw)
In-Reply-To: <20260509191223.168648-2-yphbchou0911@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scx_bpf_dsq_insert_commit() writes to p->scx.slice before token validation, causing a data race if the task is running
- [Low] Duplicate kfunc ID registration for scx_bpf_dsq_insert_begin
--
commit 1b5ec039cdfb5b4d5077f7a5cfcc34f6f7393655
Author: Cheng-Yang Chou <yphbchou0911@gmail.com>
sched_ext: Add dispatch transaction API
This commit introduces scx_bpf_dsq_insert_begin() and
scx_bpf_dsq_insert_commit() to provide a dispatch transaction API.
It extends the race detection window for schedulers that perform BPF-side
validity checks without properly synchronized dequeue.
Link: https://lore.kernel.org/r/20260203230639.1259869-1-arighi@nvidia.com/
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 1d7f206941f0c..05704a6a812a2 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
[ ... ]
> @@ -8518,13 +8520,72 @@ __bpf_kfunc void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id,
> +__bpf_kfunc bool scx_bpf_dsq_insert_commit(struct task_struct *p,
> + u64 dsq_id, u64 enq_flags,
> + u64 token,
> + const struct bpf_prog_aux *aux)
> +{
> + struct scx_sched *sch;
> +
> + guard(rcu)();
> + sch = scx_prog_sched(aux);
> + if (unlikely(!sch))
> + return false;
> +
> + if (!scx_dsq_insert_preamble(sch, p, dsq_id, &enq_flags))
> + return false;
> +
> + p->scx.slice = p->scx.slice ?: 1;
Since token validation happens asynchronously in finish_dispatch() after
ops.dispatch() returns, is it safe to write to p->scx.slice here?
If the transaction API is meant to handle cases where the task might be
claimed by another CPU between begin and commit, the task could be actively
running elsewhere when this function is called.
Could this lockless write race with the active CPU's timer tick executing
task_tick_scx() (which decrements the slice concurrently)?
It appears this could result in a read-modify-write that clobbers the
concurrent decrement and corrupts the task's slice accounting.
[ ... ]
> BTF_KFUNCS_START(scx_kfunc_ids_enqueue_dispatch)
> BTF_ID_FLAGS(func, scx_bpf_dsq_insert, KF_IMPLICIT_ARGS | KF_RCU)
> BTF_ID_FLAGS(func, scx_bpf_dsq_insert___v2, KF_IMPLICIT_ARGS | KF_RCU)
> +BTF_ID_FLAGS(func, scx_bpf_dsq_insert_commit, KF_IMPLICIT_ARGS | KF_RCU)
> BTF_ID_FLAGS(func, __scx_bpf_dsq_insert_vtime, KF_IMPLICIT_ARGS | KF_RCU)
> BTF_ID_FLAGS(func, scx_bpf_dsq_insert_vtime, KF_RCU)
> +BTF_ID_FLAGS(func, scx_bpf_dsq_insert_begin, KF_RCU)
> BTF_KFUNCS_END(scx_kfunc_ids_enqueue_dispatch)
[ ... ]
> @@ -10194,6 +10255,7 @@ BTF_ID_FLAGS(func, scx_bpf_put_cpumask, KF_RELEASE)
> BTF_ID_FLAGS(func, scx_bpf_task_running, KF_RCU)
> BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_RCU)
> BTF_ID_FLAGS(func, scx_bpf_task_cid, KF_RCU)
> +BTF_ID_FLAGS(func, scx_bpf_dsq_insert_begin, KF_RCU)
> BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS)
This isn't a bug, but is it intentional to register scx_bpf_dsq_insert_begin
in both kfunc ID sets?
Because scx_kfunc_context_filter() permits a kfunc if it is present in either
set, and both sets apply to the scheduler context, the duplicate registration
appears functionally redundant.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260509191223.168648-1-yphbchou0911@gmail.com?part=1
next prev parent reply other threads:[~2026-05-09 19:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 19:11 [PATCH v3 sched_ext/for-7.2 0/2] sched_ext: Add dispatch transaction API Cheng-Yang Chou
2026-05-09 19:11 ` [PATCH v3 1/2] " Cheng-Yang Chou
2026-05-09 19:49 ` sashiko-bot [this message]
2026-05-09 21:24 ` Andrea Righi
2026-05-10 14:02 ` Tejun Heo
2026-05-10 14:58 ` Andrea Righi
2026-05-15 14:50 ` Cheng-Yang Chou
2026-05-10 14:06 ` Tejun Heo
2026-05-15 14:36 ` Cheng-Yang Chou
2026-05-09 19:11 ` [PATCH v3 2/2] selftests/sched_ext: Add dispatch_cookie test Cheng-Yang Chou
2026-05-09 20:16 ` sashiko-bot
2026-05-09 21:43 ` Andrea Righi
2026-05-15 13:42 ` Cheng-Yang Chou
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=20260509194954.C87E0C2BCB2@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=yphbchou0911@gmail.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.