From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
sched-ext@lists.linux.dev
Cc: Gabriele Monaco <gmonaco@redhat.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Ingo Molnar <mingo@redhat.org>
Subject: [PATCH v14 1/3] sched: Add prev_sum_exec_runtime support for RT, DL and SCX classes
Date: Mon, 7 Jul 2025 16:48:22 +0200 [thread overview]
Message-ID: <20250707144824.117014-2-gmonaco@redhat.com> (raw)
In-Reply-To: <20250707144824.117014-1-gmonaco@redhat.com>
The fair scheduling class relies on prev_sum_exec_runtime to compute the
duration of the task's runtime since it was last scheduled. This value
is currently not required by other scheduling classes but can be useful
to understand long running tasks and take certain actions (e.g. during a
scheduler tick).
Add support for prev_sum_exec_runtime to the RT, deadline and sched_ext
classes by simply assigning the sum_exec_runtime at each set_next_task.
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
kernel/sched/deadline.c | 1 +
kernel/sched/ext.c | 1 +
kernel/sched/rt.c | 1 +
3 files changed, 3 insertions(+)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 89019a1408264..65ecd86bae37d 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2389,6 +2389,7 @@ static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first)
p->se.exec_start = rq_clock_task(rq);
if (on_dl_rq(&p->dl))
update_stats_wait_end_dl(dl_rq, dl_se);
+ p->se.prev_sum_exec_runtime = p->se.sum_exec_runtime;
/* You can't push away the running task */
dequeue_pushable_dl_task(rq, p);
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index b498d867ba210..a4ac4386b9795 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3255,6 +3255,7 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, bool first)
}
p->se.exec_start = rq_clock_task(rq);
+ p->se.prev_sum_exec_runtime = p->se.sum_exec_runtime;
/* see dequeue_task_scx() on why we skip when !QUEUED */
if (SCX_HAS_OP(sch, running) && (p->scx.flags & SCX_TASK_QUEUED))
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index e40422c370335..2c70ff2042ee9 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1693,6 +1693,7 @@ static inline void set_next_task_rt(struct rq *rq, struct task_struct *p, bool f
p->se.exec_start = rq_clock_task(rq);
if (on_rt_rq(&p->rt))
update_stats_wait_end_rt(rt_rq, rt_se);
+ p->se.prev_sum_exec_runtime = p->se.sum_exec_runtime;
/* The running task is never eligible for pushing */
dequeue_pushable_task(rq, p);
--
2.50.0
next prev parent reply other threads:[~2025-07-07 14:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 14:48 [PATCH v14 0/3] sched: Restructure task_mm_cid_work for predictability Gabriele Monaco
2025-07-07 14:48 ` Gabriele Monaco [this message]
2025-07-07 14:48 ` [PATCH v14 2/3] sched: Move task_mm_cid_work to mm timer Gabriele Monaco
2025-07-07 15:19 ` Mathieu Desnoyers
2025-07-10 4:56 ` kernel test robot
2025-07-10 13:23 ` Mathieu Desnoyers
2025-07-10 13:40 ` Gabriele Monaco
2025-07-10 14:18 ` Mathieu Desnoyers
2025-07-10 13:47 ` Gabriele Monaco
2025-07-07 14:48 ` [PATCH v14 3/3] selftests/rseq: Add test for mm_cid compaction Gabriele Monaco
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=20250707144824.117014-2-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=mingo@redhat.org \
--cc=peterz@infradead.org \
--cc=sched-ext@lists.linux.dev \
/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®