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

scx: Prepare for BPF DSQ iterator #182

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions include/linux/sched/ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ enum scx_dsq_id_flags {
};

/*
* Dispatch queue (dsq) is a simple FIFO which is used to buffer between the
* scheduler core and the BPF scheduler. See the documentation for more details.
* A dispatch queue (DSQ) can be either a FIFO or p->scx.dsq_vtime ordered
* queue. A built-in DSQ is always a FIFO. The built-in local DSQs are used to
* buffer between the scheduler core and the BPF scheduler. See the
* documentation for more details.
*/
struct scx_dispatch_q {
raw_spinlock_t lock;
struct list_head fifo; /* processed in dispatching order */
struct rb_root_cached priq; /* processed in p->scx.dsq_vtime order */
struct list_head list; /* tasks in dispatch order */
struct rb_root priq; /* used to order by p->scx.dsq_vtime */
u32 nr;
u64 id;
struct rhash_head hash_node;
Expand Down Expand Up @@ -119,18 +121,20 @@ enum scx_kf_mask {
__SCX_KF_TERMINAL = SCX_KF_ENQUEUE | SCX_KF_SELECT_CPU | SCX_KF_REST,
};

struct scx_dsq_node {
struct list_head list; /* dispatch order */
struct rb_node priq; /* p->scx.dsq_vtime order */
u32 flags; /* SCX_TASK_DSQ_* flags */
};

/*
* The following is embedded in task_struct and contains all fields necessary
* for a task to be scheduled by SCX.
*/
struct sched_ext_entity {
struct scx_dispatch_q *dsq;
struct {
struct list_head fifo; /* dispatch order */
struct rb_node priq; /* p->scx.dsq_vtime order */
} dsq_node;
struct scx_dsq_node dsq_node; /* protected by dsq lock */
u32 flags; /* protected by rq lock */
u32 dsq_flags; /* protected by dsq lock */
u32 weight;
s32 sticky_cpu;
s32 holding_cpu;
Expand Down
2 changes: 1 addition & 1 deletion init/init_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = {
#endif
#ifdef CONFIG_SCHED_CLASS_EXT
.scx = {
.dsq_node.fifo = LIST_HEAD_INIT(init_task.scx.dsq_node.fifo),
.dsq_node.list = LIST_HEAD_INIT(init_task.scx.dsq_node.list),
.flags = 0,
.sticky_cpu = -1,
.holding_cpu = -1,
Expand Down
2 changes: 1 addition & 1 deletion kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4586,7 +4586,7 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)

#ifdef CONFIG_SCHED_CLASS_EXT
p->scx.dsq = NULL;
INIT_LIST_HEAD(&p->scx.dsq_node.fifo);
INIT_LIST_HEAD(&p->scx.dsq_node.list);
RB_CLEAR_NODE(&p->scx.dsq_node.priq);
p->scx.flags = 0;
p->scx.weight = 0;
Expand Down
Loading