From: liuwenfang <liuwenfang@honor.com>
To: 'Tejun Heo' <tj@kernel.org>
Cc: 'David Vernet' <void@manifault.com>,
'Andrea Righi' <arighi@nvidia.com>,
'Changwoo Min' <changwoo@igalia.com>,
'Ingo Molnar' <mingo@redhat.com>,
'Peter Zijlstra' <peterz@infradead.org>,
'Juri Lelli' <juri.lelli@redhat.com>,
'Vincent Guittot' <vincent.guittot@linaro.org>,
'Dietmar Eggemann' <dietmar.eggemann@arm.com>,
'Steven Rostedt' <rostedt@goodmis.org>,
'Ben Segall' <bsegall@google.com>, 'Mel Gorman' <mgorman@suse.de>,
'Valentin Schneider' <vschneid@redhat.com>,
"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: [PATCH] sched_ext: introduce cpu tick
Date: Tue, 10 Jun 2025 08:59:45 +0000 [thread overview]
Message-ID: <2d771c1f293845e09edf73f5db5b2837@honor.com> (raw)
Assume one CPU is running one RT task and one runnable scx task on
its local dsq, the scx task cannot be scheduled until RT task enters
sleep, if RT task will run for 100ms, the scx task should be migrated
to other dsqs, then it can have a chance to be scheduled by other CPUs.
So cpu_tick is added to notitfy BPF scheduler to check long runnable
scx on its local dsq, related policy can be taken to improve the
performance.
Signed-off-by: liuwenfang liuwenfang@honor.com
---
kernel/sched/ext.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index f5133249f..2232f616c 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -337,6 +337,16 @@ struct sched_ext_ops {
*/
void (*tick)(struct task_struct *p);
+ /**
+ * @tick: Periodic tick
+ * @rq: current CPU's rq
+ *
+ * This operation is called every 1/HZ seconds on each CPU which is
+ * not idle. Notify BPF scheduler to take policy for runnable tasks
+ * on local dsq.
+ */
+ void (*cpu_tick)(struct rq *rq);
+
/**
* @runnable: A task is becoming runnable on its associated CPU
* @p: task becoming runnable
@@ -3569,6 +3579,9 @@ void scx_tick(struct rq *rq)
}
update_other_load_avgs(rq);
+
+ if (SCX_HAS_OP(cpu_tick))
+ SCX_CALL_OP(SCX_KF_REST, cpu_tick, rq);
}
static void task_tick_scx(struct rq *rq, struct task_struct *curr, int queued)
@@ -5753,6 +5766,7 @@ static void sched_ext_ops__enqueue(struct task_struct *p, u64 enq_flags) {}
static void sched_ext_ops__dequeue(struct task_struct *p, u64 enq_flags) {}
static void sched_ext_ops__dispatch(s32 prev_cpu, struct task_struct *prev__nullable) {}
static void sched_ext_ops__tick(struct task_struct *p) {}
+static void sched_ext_ops__cpu_tick(struct rq *rq) {}
static void sched_ext_ops__runnable(struct task_struct *p, u64 enq_flags) {}
static void sched_ext_ops__running(struct task_struct *p) {}
static void sched_ext_ops__stopping(struct task_struct *p, bool runnable) {}
@@ -5790,6 +5804,7 @@ static struct sched_ext_ops __bpf_ops_sched_ext_ops = {
.dequeue = sched_ext_ops__dequeue,
.dispatch = sched_ext_ops__dispatch,
.tick = sched_ext_ops__tick,
+ .cpu_tick = sched_ext_ops__cpu_tick,
.runnable = sched_ext_ops__runnable,
.running = sched_ext_ops__running,
.stopping = sched_ext_ops__stopping,
--
2.17.1
next reply other threads:[~2025-06-10 9:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 8:59 liuwenfang [this message]
2025-06-10 17:59 ` 'Tejun Heo'
2025-06-11 2:22 ` liuwenfang
2025-06-11 5:47 ` Andrea Righi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d771c1f293845e09edf73f5db5b2837@honor.com \
--to=liuwenfang@honor.com \
--cc=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®