From 9a13ab9323bc8b49b6de3a5622fc633a4c839d81 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 18 Apr 2024 15:46:21 -1000 Subject: [PATCH] scx: Move p->scx.dsq_flags into p->scx.dsq_node 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. --- include/linux/sched/ext.h | 12 +++++++----- kernel/sched/ext.c | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h index 29cb680703916..793efa68fe1de 100644 --- a/include/linux/sched/ext.h +++ b/include/linux/sched/ext.h @@ -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; diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index cb801fa7f4313..46fd51b7a602e 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -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) { @@ -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); /* @@ -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); @@ -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",