From: Peter Zijlstra <peterz@infradead.org>
To: mingo@kernel.org
Cc: 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, tj@kernel.org, void@manifault.com,
linux-kernel@vger.kernel.org
Subject: [RFC][PATCH 5/6] sched: Add flags to the switch{ing,ed}_{to,from}() methods
Date: Wed, 30 Oct 2024 16:13:00 +0100 [thread overview]
Message-ID: <20241030152142.820157837@infradead.org> (raw)
In-Reply-To: <20241030151255.300069509@infradead.org>
... and remove switched_to_scx(), since all methods are now optional.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/sched/core.c | 8 ++++----
kernel/sched/deadline.c | 4 ++--
kernel/sched/ext.c | 6 ++----
kernel/sched/fair.c | 4 ++--
kernel/sched/idle.c | 2 +-
kernel/sched/rt.c | 4 ++--
kernel/sched/sched.h | 8 ++++----
kernel/sched/stop_task.c | 2 +-
8 files changed, 18 insertions(+), 20 deletions(-)
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10531,7 +10531,7 @@ struct sched_change_ctx sched_change_beg
lockdep_assert_rq_held(rq);
if ((flags & DEQUEUE_CLASS) && p->sched_class->switching_from)
- p->sched_class->switching_from(rq, p);
+ p->sched_class->switching_from(rq, p, flags);
struct sched_change_ctx ctx = {
.p = p,
@@ -10546,7 +10546,7 @@ struct sched_change_ctx sched_change_beg
put_prev_task(rq, p);
if ((flags & DEQUEUE_CLASS) && p->sched_class->switched_from)
- p->sched_class->switched_from(rq, p);
+ p->sched_class->switched_from(rq, p, flags);
return ctx;
}
@@ -10559,7 +10559,7 @@ void sched_change_end(struct sched_chang
lockdep_assert_rq_held(rq);
if ((ctx.flags & ENQUEUE_CLASS) && p->sched_class->switching_to)
- p->sched_class->switching_to(rq, p);
+ p->sched_class->switching_to(rq, p, ctx.flags);
if (ctx.queued)
enqueue_task(rq, p, ctx.flags | ENQUEUE_NOCLOCK);
@@ -10567,5 +10567,5 @@ void sched_change_end(struct sched_chang
set_next_task(rq, p);
if ((ctx.flags & ENQUEUE_CLASS) && p->sched_class->switched_to)
- p->sched_class->switched_to(rq, p);
+ p->sched_class->switched_to(rq, p, ctx.flags);
}
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2968,7 +2968,7 @@ void dl_clear_root_domain(struct root_do
#endif /* CONFIG_SMP */
-static void switched_from_dl(struct rq *rq, struct task_struct *p)
+static void switched_from_dl(struct rq *rq, struct task_struct *p, int flags)
{
/*
* task_non_contending() can start the "inactive timer" (if the 0-lag
@@ -3022,7 +3022,7 @@ static void switched_from_dl(struct rq *
* When switching to -deadline, we may overload the rq, then
* we try to push someone off, if possible.
*/
-static void switched_to_dl(struct rq *rq, struct task_struct *p)
+static void switched_to_dl(struct rq *rq, struct task_struct *p, int flags)
{
if (hrtimer_try_to_cancel(&p->dl.inactive_timer) == 1)
put_task_struct(p);
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3663,7 +3663,7 @@ static void prio_changed_scx(struct rq *
{
}
-static void switching_to_scx(struct rq *rq, struct task_struct *p)
+static void switching_to_scx(struct rq *rq, struct task_struct *p, int flags)
{
scx_ops_enable_task(p);
@@ -3676,13 +3676,12 @@ static void switching_to_scx(struct rq *
(struct cpumask *)p->cpus_ptr);
}
-static void switched_from_scx(struct rq *rq, struct task_struct *p)
+static void switched_from_scx(struct rq *rq, struct task_struct *p, int flags)
{
scx_ops_disable_task(p);
}
static void wakeup_preempt_scx(struct rq *rq, struct task_struct *p,int wake_flags) {}
-static void switched_to_scx(struct rq *rq, struct task_struct *p) {}
int scx_check_setscheduler(struct task_struct *p, int policy)
{
@@ -3971,7 +3970,6 @@ DEFINE_SCHED_CLASS(ext) = {
.switching_to = switching_to_scx,
.switched_from = switched_from_scx,
- .switched_to = switched_to_scx,
.reweight_task = reweight_task_scx,
.prio_changed = prio_changed_scx,
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -13175,12 +13175,12 @@ static void attach_task_cfs_rq(struct ta
attach_entity_cfs_rq(se);
}
-static void switched_from_fair(struct rq *rq, struct task_struct *p)
+static void switched_from_fair(struct rq *rq, struct task_struct *p, int flags)
{
detach_task_cfs_rq(p);
}
-static void switched_to_fair(struct rq *rq, struct task_struct *p)
+static void switched_to_fair(struct rq *rq, struct task_struct *p, int flags)
{
SCHED_WARN_ON(p->se.sched_delayed);
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -494,7 +494,7 @@ static void task_tick_idle(struct rq *rq
{
}
-static void switching_to_idle(struct rq *rq, struct task_struct *p)
+static void switching_to_idle(struct rq *rq, struct task_struct *p, int flags)
{
BUG();
}
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2420,7 +2420,7 @@ static void rq_offline_rt(struct rq *rq)
* When switch from the rt queue, we bring ourselves to a position
* that we might want to pull RT tasks from other runqueues.
*/
-static void switched_from_rt(struct rq *rq, struct task_struct *p)
+static void switched_from_rt(struct rq *rq, struct task_struct *p, int flags)
{
/*
* If there are other RT tasks then we will reschedule
@@ -2451,7 +2451,7 @@ void __init init_sched_rt_class(void)
* with RT tasks. In this case we try to push them off to
* other runqueues.
*/
-static void switched_to_rt(struct rq *rq, struct task_struct *p)
+static void switched_to_rt(struct rq *rq, struct task_struct *p, int flags)
{
/*
* If we are running, update the avg_rt tracking, as the running time
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2417,10 +2417,10 @@ struct sched_class {
void (*task_fork)(struct task_struct *p);
void (*task_dead)(struct task_struct *p);
- void (*switching_from)(struct rq *this_rq, struct task_struct *task);
- void (*switched_from) (struct rq *this_rq, struct task_struct *task);
- void (*switching_to) (struct rq *this_rq, struct task_struct *task);
- void (*switched_to) (struct rq *this_rq, struct task_struct *task);
+ void (*switching_from)(struct rq *this_rq, struct task_struct *task, int flags);
+ void (*switched_from) (struct rq *this_rq, struct task_struct *task, int flags);
+ void (*switching_to) (struct rq *this_rq, struct task_struct *task, int flags);
+ void (*switched_to) (struct rq *this_rq, struct task_struct *task, int flags);
void (*reweight_task)(struct rq *this_rq, struct task_struct *task,
const struct load_weight *lw);
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -76,7 +76,7 @@ static void task_tick_stop(struct rq *rq
{
}
-static void switching_to_stop(struct rq *rq, struct task_struct *p)
+static void switching_to_stop(struct rq *rq, struct task_struct *p, int flags)
{
BUG(); /* its impossible to change to this class */
}
next prev parent reply other threads:[~2024-10-30 15:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 15:12 [RFC][PATCH 0/6] clean up class switching Peter Zijlstra
2024-10-30 15:12 ` [PATCH 1/6] sched/ext: Fix scx vs sched_delayed Peter Zijlstra
2024-10-30 15:50 ` Christian Loehle
2024-10-30 15:54 ` Peter Zijlstra
2024-10-30 17:17 ` Christian Loehle
2024-10-30 20:19 ` Tejun Heo
2024-10-30 15:12 ` [RFC][PATCH 2/6] sched: Employ sched_change guards Peter Zijlstra
2024-10-30 20:58 ` Tejun Heo
2024-10-30 21:09 ` Tejun Heo
2024-10-30 21:11 ` Peter Zijlstra
2024-10-30 15:12 ` [RFC][PATCH 3/6] sched: Re-arrange the {EN,DE}QUEUE flags Peter Zijlstra
2024-10-30 15:12 ` [RFC][PATCH 4/6] sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern Peter Zijlstra
2024-10-30 21:12 ` Tejun Heo
2024-10-30 21:15 ` Peter Zijlstra
2024-10-30 21:29 ` Tejun Heo
2024-10-30 21:37 ` Peter Zijlstra
2024-10-30 21:39 ` Tejun Heo
2024-10-30 15:13 ` Peter Zijlstra [this message]
2024-10-30 15:13 ` [RFC][PATCH 6/6] sched: Cleanup sched_delayed handling for class switches Peter Zijlstra
2024-10-30 15:45 ` Peter Zijlstra
2024-10-30 21:27 ` 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=20241030152142.820157837@infradead.org \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.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®