All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Add cookie API for early qseq capture
@ 2026-05-06  7:59 Cheng-Yang Chou
  2026-05-06 10:08 ` Kuba Piecuch
  2026-05-06 10:58 ` sashiko-bot
  0 siblings, 2 replies; 4+ messages in thread
From: Cheng-Yang Chou @ 2026-05-06  7:59 UTC (permalink / raw)
  To: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, yphbchou0911, Kuba Piecuch

scx_bpf_dsq_insert() captures qseq at insert time. Any BPF-side
pre-dispatch checks (e.g. CPU affinity validation) performed before
the insert are outside the qseq protection window: a dequeue/re-enqueue
race occurring between the check and the insert goes undetected by
finish_dispatch(), which sees a matching qseq and proceeds with stale
assumptions.

Introduce two new kfuncs to extend the qseq protection window:

- scx_bpf_task_get_cookie(p)
    Reads @p's current qseq from ops_state and returns it as an opaque
    u64 cookie. The BPF scheduler should call this before performing
    pre-dispatch validity checks. The cookie may be stored in BPF maps
    to support cross-CPU dispatch patterns.

- scx_bpf_dsq_insert_with_cookie(p, dsq_id, enq_flags, cookie)
    Like scx_bpf_dsq_insert() with slice=0, but uses the cookie's qseq
    instead of re-reading ops_state at insert time. If @p was dequeued
    and re-enqueued between get_cookie() and here, qseq will have
    changed and finish_dispatch() will silently discard the stale
    dispatch. Use scx_bpf_task_set_slice() to set a non-default slice.

To support explicit qseq passing, refactor scx_dsq_insert_commit() to
take qseq as a parameter; all existing callers capture ops_state at
their call site, preserving the original behavior.

This mechanism is intended for schedulers that do not implement
properly synchronized dequeue. A scheduler whose ops.dequeue()
synchronizes atomically with the dispatch path does not need cookies.

Suggested-by: Tejun Heo <tj@kernel.org>
Suggested-by: Kuba Piecuch <jpiecuch@google.com>
Suggested-by: Andrea Righi <arighi@nvidia.com>
Reported-by: Andrea Righi <arighi@nvidia.com>
Link: https://lore.kernel.org/r/20260203230639.1259869-1-arighi@nvidia.com/
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
---
As discussed in [1].
[1]: https://lore.kernel.org/r/20260319083518.94673-1-arighi@nvidia.com/

 kernel/sched/ext.c | 65 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 61 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index c80f0efd42c0..49577cca3104 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -8303,7 +8303,7 @@ static bool scx_dsq_insert_preamble(struct scx_sched *sch, struct task_struct *p
 }
 
 static void scx_dsq_insert_commit(struct scx_sched *sch, struct task_struct *p,
-				  u64 dsq_id, u64 enq_flags)
+				  u64 dsq_id, u64 enq_flags, unsigned long qseq)
 {
 	struct scx_dsp_ctx *dspc = &this_cpu_ptr(sch->pcpu)->dsp_ctx;
 	struct task_struct *ddsp_task;
@@ -8321,7 +8321,7 @@ static void scx_dsq_insert_commit(struct scx_sched *sch, struct task_struct *p,
 
 	dspc->buf[dspc->cursor++] = (struct scx_dsp_buf_ent){
 		.task = p,
-		.qseq = atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK,
+		.qseq = qseq,
 		.dsq_id = dsq_id,
 		.enq_flags = enq_flags,
 	};
@@ -8388,7 +8388,8 @@ __bpf_kfunc bool scx_bpf_dsq_insert___v2(struct task_struct *p, u64 dsq_id,
 	else
 		p->scx.slice = p->scx.slice ?: 1;
 
-	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags);
+	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags,
+			      atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK);
 
 	return true;
 }
@@ -8416,7 +8417,8 @@ static bool scx_dsq_insert_vtime(struct scx_sched *sch, struct task_struct *p,
 
 	p->scx.dsq_vtime = vtime;
 
-	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags | SCX_ENQ_DSQ_PRIQ);
+	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags | SCX_ENQ_DSQ_PRIQ,
+			      atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK);
 
 	return true;
 }
@@ -8505,13 +8507,67 @@ __bpf_kfunc void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id,
 	scx_dsq_insert_vtime(sch, p, dsq_id, slice, vtime, enq_flags);
 }
 
+/**
+ * scx_bpf_task_get_cookie - Get an opaque dispatch cookie for a task
+ * @p: task_struct to read cookie from
+ *
+ * Returns an opaque u64 cookie encoding @p's current qseq. Call this
+ * before pre-dispatch validity checks and pass the result to
+ * scx_bpf_dsq_insert_with_cookie() to extend the qseq protection window.
+ *
+ * For schedulers that do not implement properly synchronized dequeue only.
+ */
+__bpf_kfunc u64 scx_bpf_task_get_cookie(struct task_struct *p)
+{
+	return atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK;
+}
+
+/**
+ * scx_bpf_dsq_insert_with_cookie - Insert a task using an early-captured cookie
+ * @p: task_struct to insert
+ * @dsq_id: DSQ to insert into
+ * @enq_flags: SCX_ENQ_*
+ * @cookie: cookie from scx_bpf_task_get_cookie()
+ * @aux: implicit BPF argument
+ *
+ * Like scx_bpf_dsq_insert() with slice=0, but uses @cookie's qseq instead
+ * of re-reading ops_state at insert time. A stale cookie causes
+ * finish_dispatch() to silently discard the dispatch. Use
+ * scx_bpf_task_set_slice() to set a non-default slice.
+ *
+ * Returns %true on success, %false on failure.
+ */
+__bpf_kfunc bool scx_bpf_dsq_insert_with_cookie(struct task_struct *p,
+						 u64 dsq_id, u64 enq_flags,
+						 u64 cookie,
+						 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;
+
+	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags, (unsigned long)cookie);
+
+	return true;
+}
+
 __bpf_kfunc_end_defs();
 
 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_with_cookie, 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_task_get_cookie, KF_RCU)
 BTF_KFUNCS_END(scx_kfunc_ids_enqueue_dispatch)
 
 static const struct btf_kfunc_id_set scx_kfunc_set_enqueue_dispatch = {
@@ -10181,6 +10237,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_task_get_cookie, KF_RCU)
 BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_IMPLICIT_ARGS | KF_RET_NULL)
 BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED)
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] sched_ext: Add cookie API for early qseq capture
  2026-05-06  7:59 [PATCH] sched_ext: Add cookie API for early qseq capture Cheng-Yang Chou
@ 2026-05-06 10:08 ` Kuba Piecuch
  2026-05-06 12:39   ` Cheng-Yang Chou
  2026-05-06 10:58 ` sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: Kuba Piecuch @ 2026-05-06 10:08 UTC (permalink / raw)
  To: Cheng-Yang Chou, sched-ext, Tejun Heo, David Vernet, Andrea Righi,
	Changwoo Min
  Cc: Ching-Chun Huang, Chia-Ping Tsai, Kuba Piecuch

Hi Cheng-Yang,

On Wed May 6, 2026 at 7:59 AM UTC, Cheng-Yang Chou wrote:
> @@ -8505,13 +8507,67 @@ __bpf_kfunc void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id,
>  	scx_dsq_insert_vtime(sch, p, dsq_id, slice, vtime, enq_flags);
>  }
>  
> +/**
> + * scx_bpf_task_get_cookie - Get an opaque dispatch cookie for a task
> + * @p: task_struct to read cookie from
> + *
> + * Returns an opaque u64 cookie encoding @p's current qseq. Call this
> + * before pre-dispatch validity checks and pass the result to
> + * scx_bpf_dsq_insert_with_cookie() to extend the qseq protection window.

This is just my opinion, but I thought the point of introducing cookies is to
not have to expose qseq as a concept to the BPF schedulers (or people writing
them). This includes comments documenting the kfuncs.

Wouldn't it be better if we just focus on describing the semantics without
mentioning qseq? Perhaps something like:

  Returns an opaque u64 dispatch cookie. Pass the cookie to
  scx_bpf_dsq_insert_with_cookie() to extend the time window during which
  sched_ext will detect racing dequeues/enqueues of the task being dispatched.
  The extended time window begins with the call to scx_bpf_task_get_cookie()
  and ends at the same point as for dispatches without cookies, i.e. at the
  point where sched_ext attempts to finish the dispatch.

> + *
> + * For schedulers that do not implement properly synchronized dequeue only.

"only" seems quite strong here. How about "This API is intended for schedulers
that do not implement properly synchronized dequeue"?

> + */
> +__bpf_kfunc u64 scx_bpf_task_get_cookie(struct task_struct *p)
> +{
> +	return atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK;
> +}
> +
> +/**
> + * scx_bpf_dsq_insert_with_cookie - Insert a task using an early-captured cookie
> + * @p: task_struct to insert
> + * @dsq_id: DSQ to insert into
> + * @enq_flags: SCX_ENQ_*
> + * @cookie: cookie from scx_bpf_task_get_cookie()
> + * @aux: implicit BPF argument
> + *
> + * Like scx_bpf_dsq_insert() with slice=0, but uses @cookie's qseq instead
> + * of re-reading ops_state at insert time. A stale cookie causes
> + * finish_dispatch() to silently discard the dispatch. Use
> + * scx_bpf_task_set_slice() to set a non-default slice.
> + *
> + * Returns %true on success, %false on failure.
> + */
> +__bpf_kfunc bool scx_bpf_dsq_insert_with_cookie(struct task_struct *p,
> +						 u64 dsq_id, u64 enq_flags,
> +						 u64 cookie,
> +						 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;
> +
> +	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags, (unsigned long)cookie);
> +
> +	return true;
> +}
> +
>  __bpf_kfunc_end_defs();
>  
>  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_with_cookie, 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_task_get_cookie, KF_RCU)
>  BTF_KFUNCS_END(scx_kfunc_ids_enqueue_dispatch)
>  
>  static const struct btf_kfunc_id_set scx_kfunc_set_enqueue_dispatch = {
> @@ -10181,6 +10237,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_task_get_cookie, KF_RCU)
>  BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS)
>  BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_IMPLICIT_ARGS | KF_RET_NULL)
>  BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED)

Thank you for the patch!

Could you add a simple selftest for the two new kfuncs?

Thanks,
Kuba

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sched_ext: Add cookie API for early qseq capture
  2026-05-06  7:59 [PATCH] sched_ext: Add cookie API for early qseq capture Cheng-Yang Chou
  2026-05-06 10:08 ` Kuba Piecuch
@ 2026-05-06 10:58 ` sashiko-bot
  1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-05-06 10:58 UTC (permalink / raw)
  To: Cheng-Yang Chou; +Cc: sched-ext

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Unprotected task state mutation causing data race on slice
- [High] Missing acquire memory barrier in scx_bpf_task_get_cookie() defeats sequence-lock protection
- [Medium] Missing API variant for PRIQ (vtime-ordered) DSQ insertion
--

commit c9d30798b70b7101ea880a0f906790c5875384ac
Author: Cheng-Yang Chou <yphbchou0911@gmail.com>

sched_ext: Add cookie API for early qseq capture

This commit introduces two new kfuncs, scx_bpf_task_get_cookie() and
scx_bpf_dsq_insert_with_cookie(), to allow BPF schedulers to capture a
task's qseq before performing pre-dispatch checks and safely insert it
if the sequence hasn't changed.

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 5600618dcef8e..5ee74c964a971 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c

[ ... ]

> +/**
> + * scx_bpf_task_get_cookie - Get an opaque dispatch cookie for a task
> + * @p: task_struct to read cookie from
> + *
> + * Returns an opaque u64 cookie encoding @p's current qseq. Call this
> + * before pre-dispatch validity checks and pass the result to
> + * scx_bpf_dsq_insert_with_cookie() to extend the qseq protection window.
> + *
> + * For schedulers that do not implement properly synchronized dequeue only.
> + */
> +__bpf_kfunc u64 scx_bpf_task_get_cookie(struct task_struct *p)
> +{
> +	return atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK;

Should this use atomic_long_read_acquire() instead of a relaxed atomic read?

Since this conceptually starts a sequence-lock read-side critical section,
a relaxed read doesn't emit hardware memory barriers. On weakly-ordered
architectures, the CPU could reorder the subsequent BPF memory loads (the
validity checks) to execute before the ops_state read.

If a concurrent dequeue/re-enqueue race occurs, the BPF checks could be
evaluated using stale task data, but the delayed ops_state read captures
the new qseq. The protection window is defeated, and finish_dispatch()
would accept the dispatch despite violated constraints.

> +}
> +
> +/**
> + * scx_bpf_dsq_insert_with_cookie - Insert a task using an early-captured cookie
> + * @p: task_struct to insert
> + * @dsq_id: DSQ to insert into
> + * @enq_flags: SCX_ENQ_*
> + * @cookie: cookie from scx_bpf_task_get_cookie()
> + * @aux: implicit BPF argument
> + *
> + * Like scx_bpf_dsq_insert() with slice=0, but uses @cookie's qseq instead
> + * of re-reading ops_state at insert time. A stale cookie causes
> + * finish_dispatch() to silently discard the dispatch. Use
> + * scx_bpf_task_set_slice() to set a non-default slice.
> + *
> + * Returns %true on success, %false on failure.
> + */
> +__bpf_kfunc bool scx_bpf_dsq_insert_with_cookie(struct task_struct *p,
> +						 u64 dsq_id, u64 enq_flags,
> +						 u64 cookie,
> +						 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;

Does modifying the slice here create a data race if the task is currently
running on another CPU?

Because this kfunc is meant for scenarios where the task reference might be
stale due to a concurrent dequeue/re-enqueue race, the task might be in the
TASK_RUNNING state elsewhere.

Modifying p->scx.slice without holding the task's current rq->lock can race
with update_curr_scx() on the other CPU, potentially overwriting the slice
decrement from the timer tick.

> +
> +	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags, (unsigned long)cookie);
> +
> +	return true;
> +}

Is there a missing API variant for inserting into PRIQ (vtime-ordered) DSQs
with a cookie?

To insert a task into a PRIQ DSQ, SCX_ENQ_DSQ_PRIQ must be set. However,
BPF schedulers cannot manually pass this flag in enq_flags because
scx_dsq_insert_preamble() rejects it as part of __SCX_ENQ_INTERNAL_MASK.
This prevents BPF schedulers from using the new cookie mechanism for
vtime-ordered priority queues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260506075925.371138-1-yphbchou0911@gmail.com?part=1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sched_ext: Add cookie API for early qseq capture
  2026-05-06 10:08 ` Kuba Piecuch
@ 2026-05-06 12:39   ` Cheng-Yang Chou
  0 siblings, 0 replies; 4+ messages in thread
From: Cheng-Yang Chou @ 2026-05-06 12:39 UTC (permalink / raw)
  To: Kuba Piecuch
  Cc: sched-ext, Tejun Heo, David Vernet, Andrea Righi, Changwoo Min,
	Ching-Chun Huang, Chia-Ping Tsai

Hi Kuba,

On Wed, May 06, 2026 at 10:08:11AM +0000, Kuba Piecuch wrote:
> On Wed May 6, 2026 at 7:59 AM UTC, Cheng-Yang Chou wrote:
> > @@ -8505,13 +8507,67 @@ __bpf_kfunc void scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id,
> >  	scx_dsq_insert_vtime(sch, p, dsq_id, slice, vtime, enq_flags);
> >  }
> >  
> > +/**
> > + * scx_bpf_task_get_cookie - Get an opaque dispatch cookie for a task
> > + * @p: task_struct to read cookie from
> > + *
> > + * Returns an opaque u64 cookie encoding @p's current qseq. Call this
> > + * before pre-dispatch validity checks and pass the result to
> > + * scx_bpf_dsq_insert_with_cookie() to extend the qseq protection window.
> 
> This is just my opinion, but I thought the point of introducing cookies is to
> not have to expose qseq as a concept to the BPF schedulers (or people writing
> them). This includes comments documenting the kfuncs.
> 
> Wouldn't it be better if we just focus on describing the semantics without
> mentioning qseq? Perhaps something like:
> 
>   Returns an opaque u64 dispatch cookie. Pass the cookie to
>   scx_bpf_dsq_insert_with_cookie() to extend the time window during which
>   sched_ext will detect racing dequeues/enqueues of the task being dispatched.
>   The extended time window begins with the call to scx_bpf_task_get_cookie()
>   and ends at the same point as for dispatches without cookies, i.e. at the
>   point where sched_ext attempts to finish the dispatch.

Agreed, will update in v2 patch.

> 
> > + *
> > + * For schedulers that do not implement properly synchronized dequeue only.
> 
> "only" seems quite strong here. How about "This API is intended for schedulers
> that do not implement properly synchronized dequeue"?
> 

Ack.

> > + */
> > +__bpf_kfunc u64 scx_bpf_task_get_cookie(struct task_struct *p)
> > +{
> > +	return atomic_long_read(&p->scx.ops_state) & SCX_OPSS_QSEQ_MASK;
> > +}
> > +
> > +/**
> > + * scx_bpf_dsq_insert_with_cookie - Insert a task using an early-captured cookie
> > + * @p: task_struct to insert
> > + * @dsq_id: DSQ to insert into
> > + * @enq_flags: SCX_ENQ_*
> > + * @cookie: cookie from scx_bpf_task_get_cookie()
> > + * @aux: implicit BPF argument
> > + *
> > + * Like scx_bpf_dsq_insert() with slice=0, but uses @cookie's qseq instead
> > + * of re-reading ops_state at insert time. A stale cookie causes
> > + * finish_dispatch() to silently discard the dispatch. Use
> > + * scx_bpf_task_set_slice() to set a non-default slice.
> > + *
> > + * Returns %true on success, %false on failure.
> > + */
> > +__bpf_kfunc bool scx_bpf_dsq_insert_with_cookie(struct task_struct *p,
> > +						 u64 dsq_id, u64 enq_flags,
> > +						 u64 cookie,
> > +						 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;
> > +
> > +	scx_dsq_insert_commit(sch, p, dsq_id, enq_flags, (unsigned long)cookie);
> > +
> > +	return true;
> > +}
> > +
> >  __bpf_kfunc_end_defs();
> >  
> >  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_with_cookie, 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_task_get_cookie, KF_RCU)
> >  BTF_KFUNCS_END(scx_kfunc_ids_enqueue_dispatch)
> >  
> >  static const struct btf_kfunc_id_set scx_kfunc_set_enqueue_dispatch = {
> > @@ -10181,6 +10237,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_task_get_cookie, KF_RCU)
> >  BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_IMPLICIT_ARGS)
> >  BTF_ID_FLAGS(func, scx_bpf_locked_rq, KF_IMPLICIT_ARGS | KF_RET_NULL)
> >  BTF_ID_FLAGS(func, scx_bpf_cpu_curr, KF_IMPLICIT_ARGS | KF_RET_NULL | KF_RCU_PROTECTED)
> 
> Thank you for the patch!
> 
> Could you add a simple selftest for the two new kfuncs?

Sure, will add a selftest in v2, thanks! ^_^

-- 
Cheers,
Cheng-Yang

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-06 12:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06  7:59 [PATCH] sched_ext: Add cookie API for early qseq capture Cheng-Yang Chou
2026-05-06 10:08 ` Kuba Piecuch
2026-05-06 12:39   ` Cheng-Yang Chou
2026-05-06 10:58 ` sashiko-bot

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.