From: Honglei Wang <jameshongleiwang@126.com>
To: tj@kernel.org, void@manifault.com, arighi@nvidia.com,
changwoo@igalia.com
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, joshdon@google.com, brho@google.com,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
jameshongleiwang@126.com
Subject: [PATCH 2/2] sched_ext: add helper for refill task with default slice
Date: Thu, 17 Apr 2025 16:07:08 +0800 [thread overview]
Message-ID: <20250417080708.1333-3-jameshongleiwang@126.com> (raw)
In-Reply-To: <20250417080708.1333-1-jameshongleiwang@126.com>
Add helper for refilling task with default slice and event
statistics accordingly.
Signed-off-by: Honglei Wang <jameshongleiwang@126.com>
---
kernel/sched/ext.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 594087ac4c9e..df7319bd9079 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1815,6 +1815,12 @@ static void dsq_mod_nr(struct scx_dispatch_q *dsq, s32 delta)
WRITE_ONCE(dsq->nr, dsq->nr + delta);
}
+static void refill_task_slice_dfl(struct task_struct *p)
+{
+ p->scx.slice = SCX_SLICE_DFL;
+ __scx_add_event(SCX_EV_REFILL_SLICE_DFL, 1);
+}
+
static void dispatch_enqueue(struct scx_dispatch_q *dsq, struct task_struct *p,
u64 enq_flags)
{
@@ -2196,16 +2202,14 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
* higher priority it becomes from scx_prio_less()'s POV.
*/
touch_core_sched(rq, p);
- p->scx.slice = SCX_SLICE_DFL;
- __scx_add_event(SCX_EV_REFILL_SLICE_DFL, 1);
+ refill_task_slice_dfl(p);
local_norefill:
dispatch_enqueue(&rq->scx.local_dsq, p, enq_flags);
return;
global:
touch_core_sched(rq, p); /* see the comment in local: */
- p->scx.slice = SCX_SLICE_DFL;
- __scx_add_event(SCX_EV_REFILL_SLICE_DFL, 1);
+ refill_task_slice_dfl(p);
dispatch_enqueue(find_global_dsq(p), p, enq_flags);
}
@@ -3294,10 +3298,8 @@ static struct task_struct *pick_task_scx(struct rq *rq)
*/
if (keep_prev) {
p = prev;
- if (!p->scx.slice) {
- p->scx.slice = SCX_SLICE_DFL;
- __scx_add_event(SCX_EV_REFILL_SLICE_DFL, 1);
- }
+ if (!p->scx.slice)
+ refill_task_slice_dfl(p);
} else {
p = first_local_task(rq);
if (!p) {
@@ -3312,8 +3314,7 @@ static struct task_struct *pick_task_scx(struct rq *rq)
p->comm, p->pid, __func__);
scx_warned_zero_slice = true;
}
- p->scx.slice = SCX_SLICE_DFL;
- __scx_add_event(SCX_EV_REFILL_SLICE_DFL, 1);
+ refill_task_slice_dfl(p);
}
}
@@ -3397,9 +3398,8 @@ static int select_task_rq_scx(struct task_struct *p, int prev_cpu, int wake_flag
cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags, 0);
if (cpu >= 0) {
- p->scx.slice = SCX_SLICE_DFL;
+ refill_task_slice_dfl(p);
p->scx.ddsp_dsq_id = SCX_DSQ_LOCAL;
- __scx_add_event(SCX_EV_REFILL_SLICE_DFL, 1);
} else {
cpu = prev_cpu;
}
--
2.45.2
next prev parent reply other threads:[~2025-04-17 8:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 8:07 [PATCH 0/2] rename var for slice refill event and add helper Honglei Wang
2025-04-17 8:07 ` [PATCH 1/2] sched_ext: change the variable name for slice refill event Honglei Wang
2025-04-17 18:30 ` Andrea Righi
2025-04-18 2:05 ` Honglei Wang
2025-04-17 8:07 ` Honglei Wang [this message]
2025-04-17 17:32 ` [PATCH 0/2] rename var for slice refill event and add helper Tejun Heo
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=20250417080708.1333-3-jameshongleiwang@126.com \
--to=jameshongleiwang@126.com \
--cc=arighi@nvidia.com \
--cc=bpf@vger.kernel.org \
--cc=brho@google.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.com \
--cc=joshdon@google.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®