Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #135 from sched-ext/htejun
Browse files Browse the repository at this point in the history
scx: Implement scx_bpf_dispatch_cancel()
  • Loading branch information
htejun authored Feb 4, 2024
2 parents 5a82ae3 + 7684264 commit 1ecced8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -4534,6 +4534,25 @@ u32 scx_bpf_dispatch_nr_slots(void)
return scx_dsp_max_batch - __this_cpu_read(scx_dsp_ctx.buf_cursor);
}

/**
* scx_bpf_dispatch_cancel - Cancel the latest dispatch
*
* Cancel the latest dispatch. Can be called multiple times to cancel further
* dispatches. Can only be called from ops.dispatch().
*/
void scx_bpf_dispatch_cancel(void)
{
struct scx_dsp_ctx *dspc = this_cpu_ptr(&scx_dsp_ctx);

if (!scx_kf_allowed(SCX_KF_DISPATCH))
return;

if (dspc->buf_cursor > 0)
dspc->buf_cursor--;
else
scx_ops_error("dispatch buffer underflow");
}

/**
* scx_bpf_consume - Transfer a task from a DSQ to the current CPU's local DSQ
* @dsq_id: DSQ to consume
Expand Down Expand Up @@ -4581,6 +4600,7 @@ bool scx_bpf_consume(u64 dsq_id)

BTF_SET8_START(scx_kfunc_ids_dispatch)
BTF_ID_FLAGS(func, scx_bpf_dispatch_nr_slots)
BTF_ID_FLAGS(func, scx_bpf_dispatch_cancel)
BTF_ID_FLAGS(func, scx_bpf_consume)
BTF_SET8_END(scx_kfunc_ids_dispatch)

Expand Down

0 comments on commit 1ecced8

Please sign in to comment.