Re: [PATCH 5/6] sched_ext: Allow SCX_DSQ_LOCAL_ON for direct dispatches

From: David Vernet
Date: Wed Jul 10 2024 - 22:05:54 EST


On Wed, Jul 10, 2024 at 03:14:02PM -1000, Tejun Heo wrote:
> In ops.dispatch(), SCX_DSQ_LOCAL_ON can be used to dispatch the task to the
> local DSQ of any CPU. However, during direct dispatch from ops.select_cpu()
> and ops.enqueue(), this isn't allowed. This is because dispatching to the
> local DSQ of a remote CPU requires locking both the task's current and new
> rq's and such double locking can't be done directly from ops.enqueue().
>
> While waking up a task, as ops.select_cpu() can pick any CPU and both
> ops.select_cpu() and ops.enqueue() can use SCX_DSQ_LOCAL as the dispatch
> target to dispatch to the DSQ of the picked CPU, the BPF scheduler can still
> do whatever it wants to do. However, while a task is being enqueued for a
> different reason, e.g. after its slice expiration, only ops.enqueue() is
> called and there's no way for the BPF scheduler to directly dispatch to the
> local DSQ of a remote CPU. This gap in API forces schedulers into
> work-arounds which are not straightforward or optimal such as skipping
> direct dispatches in such cases.
>
> Implement deferred enqueueing to allow directly dispatching to the local DSQ
> of a remote CPU from ops.select_cpu() and ops.enqueue(). Such tasks are
> temporarily queued on rq->scx.ddsp_deferred_locals. When the rq lock can be
> safely released, the tasks are taken off the list and queued on the target
> local DSQs using dispatch_to_local_dsq().
>
> v2: - Add missing return after queue_balance_callback() in
> schedule_deferred(). (David).
>
> - dispatch_to_local_dsq() now assumes that @rq is locked but unpinned
> and thus no longer takes @rf. Updated accordingly.
>
> - UP build warning fix.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> Tested-by: Andrea Righi <righi.andrea@xxxxxxxxx>
> Cc: David Vernet <void@xxxxxxxxxxxxx>
> Cc: Dan Schatzberg <schatzberg.dan@xxxxxxxxx>
> Cc: Changwoo Min <changwoo@xxxxxxxxxx>

Acked-by: David Vernet <void@xxxxxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature