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

Commit

Permalink
scx: Move p->scx.dsq_flags into p->scx.dsq_node
Browse files Browse the repository at this point in the history
and give p->scx.dsq_node's type the name of scx_dsq_node. This will be used
to implement DSQ iterator.

This wastes 8 bytes on 64bit. Oh well.
  • Loading branch information
htejun committed Apr 19, 2024
1 parent ca1cf72 commit 9a13ab9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions include/linux/sched/ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,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 list; /* 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
10 changes: 5 additions & 5 deletions kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ static void dispatch_enqueue(struct scx_dispatch_q *dsq, struct task_struct *p,
bool is_local = dsq->id == SCX_DSQ_LOCAL;

WARN_ON_ONCE(p->scx.dsq || !list_empty(&p->scx.dsq_node.list));
WARN_ON_ONCE((p->scx.dsq_flags & SCX_TASK_DSQ_ON_PRIQ) ||
WARN_ON_ONCE((p->scx.dsq_node.flags & SCX_TASK_DSQ_ON_PRIQ) ||
!RB_EMPTY_NODE(&p->scx.dsq_node.priq));

if (!is_local) {
Expand Down Expand Up @@ -1425,7 +1425,7 @@ static void dispatch_enqueue(struct scx_dispatch_q *dsq, struct task_struct *p,
scx_ops_error("DSQ ID 0x%016llx already had FIFO-enqueued tasks",
dsq->id);

p->scx.dsq_flags |= SCX_TASK_DSQ_ON_PRIQ;
p->scx.dsq_node.flags |= SCX_TASK_DSQ_ON_PRIQ;
rb_add(&p->scx.dsq_node.priq, &dsq->priq, scx_dsq_priq_less);

/*
Expand Down Expand Up @@ -1492,10 +1492,10 @@ static void dispatch_enqueue(struct scx_dispatch_q *dsq, struct task_struct *p,
static void task_unlink_from_dsq(struct task_struct *p,
struct scx_dispatch_q *dsq)
{
if (p->scx.dsq_flags & SCX_TASK_DSQ_ON_PRIQ) {
if (p->scx.dsq_node.flags & SCX_TASK_DSQ_ON_PRIQ) {
rb_erase(&p->scx.dsq_node.priq, &dsq->priq);
RB_CLEAR_NODE(&p->scx.dsq_node.priq);
p->scx.dsq_flags &= ~SCX_TASK_DSQ_ON_PRIQ;
p->scx.dsq_node.flags &= ~SCX_TASK_DSQ_ON_PRIQ;
}

list_del_init(&p->scx.dsq_node.list);
Expand Down Expand Up @@ -4318,7 +4318,7 @@ static void scx_dump_task(struct seq_buf *s, struct task_struct *p, char marker,
seq_buf_printf(s, " scx_state/flags=%u/0x%x dsq_flags=0x%x ops_state/qseq=%lu/%lu\n",
scx_get_task_state(p),
p->scx.flags & ~SCX_TASK_STATE_MASK,
p->scx.dsq_flags,
p->scx.dsq_node.flags,
ops_state & SCX_OPSS_STATE_MASK,
ops_state >> SCX_OPSS_QSEQ_SHIFT);
seq_buf_printf(s, " sticky/holding_cpu=%d/%d dsq_id=%s\n",
Expand Down

0 comments on commit 9a13ab9

Please sign in to comment.