From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, juri.lelli@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
tj@kernel.org, void@manifault.com, arighi@nvidia.com,
changwoo@igalia.com, sched-ext@lists.linux.dev, mingo@kernel.org,
vincent.guittot@linaro.org
Subject: Re: [PATCH 5/5] sched: Rework sched_class::wakeup_preempt() and rq_modified_*()
Date: Sun, 30 Nov 2025 18:33:37 +0530 [thread overview]
Message-ID: <38d96de6-f946-4cda-9301-c407425243d5@linux.ibm.com> (raw)
In-Reply-To: <20251130113227.GB411057@noisy.programming.kicks-ass.net>
On 11/30/25 5:02 PM, Peter Zijlstra wrote:
> On Sat, Nov 29, 2025 at 11:38:49PM +0530, Shrikanth Hegde wrote:
>
>>> @@ -2174,10 +2172,14 @@ void wakeup_preempt(struct rq *rq, struc
>>> {
>>> struct task_struct *donor = rq->donor;
>>> - if (p->sched_class == donor->sched_class)
>>> - donor->sched_class->wakeup_preempt(rq, p, flags);
>>> - else if (sched_class_above(p->sched_class, donor->sched_class))
>>> + if (p->sched_class == rq->next_class) {
>>> + rq->next_class->wakeup_preempt(rq, p, flags);
>>> +
>>> + } else if (sched_class_above(p->sched_class, rq->next_class)) {
>>> + rq->next_class->wakeup_preempt(rq, p, flags);
>>
>> Whats the logic of calling wakeup_preempt here?
>>
>> say rq was running CFS, now RT is waking up. but first thing we do is
>> return if not fair_sched_class. it is effectively resched_curr right?
>
> Yes, as-is this patch seems silly, but that is mostly to preserve
> current semantics :-)
>
> The idea is that classes *could* do something else. Notably this was a
> request from sched_ext. There are cases where when they pull a task from
> the global runqueue and stick it on the local runqueue, but then get
> preempted by a higher priority class (say RT) they would want to stick
> the task back on the global runqueue such that another CPU can select it
> again, instead of having that task linger on a CPU that is not
> available.
>
ok. This helps to understand.
> This issue has come up in the past as well but was never addressed.
>
> Anyway, this is just foundational work. It would let a class respond to
> loosing the runqueue to a higher priority class.
>
> I suppose I should go write a better changelog.
>
>>
>>> resched_curr(rq);
>>> + rq->next_class = p->sched_class;
>>
>> Since resched will happen and __schedule can set the next_class. it is necessary to set it
>> even earlier?
>
> Yes, because we can have another wakeup before that schedule.
>
> Imagine running a fair class, getting a fifo wakeup and then a dl
> wakeup. You want the fair class, then the rt class to get a preemption
> notification.
>
>>> @@ -3899,6 +3876,7 @@ void move_queued_task_locked(struct rq *
>>> deactivate_task(src_rq, task, 0);
>>> set_task_cpu(task, dst_rq->cpu);
>>> activate_task(dst_rq, task, 0);
>>> + wakeup_preempt(dst_rq, task, 0);
>>
>> Whats the need of wakeup_preempt here?
>
> Everything that places a task on the runqueue should do a 'wakeup'
> preemption to make sure the above mentioned class preemption stuff
> works.
>
> It doesn't really matter if the task is new due to an actual wakeup or
> due to a migration, the task is 'new' to this CPU and stuff might need
> to 'move'.
>
> IIRC this was the only such place that missed the check.
Point was, we might do resched_curr twice in this case.
Once in wakeup_preempt and once by explicit call following
move_queued_task_locked. May remove the later one?
next prev parent reply other threads:[~2025-11-30 13:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 15:39 [PATCH 0/5] sched: Random collection of patches Peter Zijlstra
2025-11-27 15:39 ` [PATCH 1/5] sched/fair: Fold the sched_avg update Peter Zijlstra
2025-12-14 7:46 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2025-12-14 7:46 ` [tip: sched/core] <linux/compiler_types.h>: Add the __signed_scalar_typeof() helper tip-bot2 for Peter Zijlstra
2025-11-27 15:39 ` [PATCH 2/5] sched/fair: Avoid rq->lock bouncing in sched_balance_newidle() Peter Zijlstra
2025-11-29 18:59 ` Shrikanth Hegde
2025-12-14 7:46 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2025-11-27 15:39 ` [PATCH 3/5] sched: Change rcu_dereference_check_sched_domain() to rcu-sched Peter Zijlstra
2025-11-28 10:57 ` Peter Zijlstra
2025-11-28 11:04 ` Peter Zijlstra
2025-11-28 11:21 ` Paul E. McKenney
2025-11-28 11:37 ` Peter Zijlstra
2025-12-14 7:46 ` [tip: sched/core] sched/fair: Remove superfluous rcu_read_lock() tip-bot2 for Peter Zijlstra
2025-11-27 15:39 ` [PATCH 4/5] sched: Add assertions to QUEUE_CLASS Peter Zijlstra
2025-12-14 7:46 ` [tip: sched/core] sched/core: " tip-bot2 for Peter Zijlstra
[not found] ` <CGME20251218100916eucas1p2258bd5447be988f61f3358963de1cebf@eucas1p2.samsung.com>
2025-12-18 10:09 ` [PATCH 4/5] sched: " Marek Szyprowski
2025-12-18 10:12 ` Peter Zijlstra
2025-11-27 15:39 ` [PATCH 5/5] sched: Rework sched_class::wakeup_preempt() and rq_modified_*() Peter Zijlstra
2025-11-28 13:26 ` Kuba Piecuch
2025-11-28 13:36 ` Peter Zijlstra
2025-11-28 13:44 ` Peter Zijlstra
2025-11-28 22:29 ` Andrea Righi
2025-11-29 18:08 ` Shrikanth Hegde
2025-11-30 11:32 ` Peter Zijlstra
2025-11-30 13:03 ` Shrikanth Hegde [this message]
2025-12-02 23:27 ` Tejun Heo
2025-12-14 7:46 ` [tip: sched/core] sched/core: " tip-bot2 for Peter Zijlstra
2025-12-15 6:07 ` error: implicit declaration of function ‘rq_modified_clear’ (was [PATCH 5/5] sched: Rework sched_class::wakeup_preempt() and rq_modified_*()) Thorsten Leemhuis
2025-12-15 7:12 ` Ingo Molnar
2025-12-15 11:51 ` Nathan Chancellor
2025-12-16 7:02 ` Thorsten Leemhuis
2025-12-16 18:40 ` Tejun Heo
2025-12-16 21:42 ` Peter Zijlstra
2025-12-17 9:58 ` Peter Zijlstra
2025-12-15 7:59 ` [tip: sched/core] sched/core: Rework sched_class::wakeup_preempt() and rq_modified_*() tip-bot2 for Peter Zijlstra
2025-12-17 10:02 ` tip-bot2 for Peter Zijlstra
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=38d96de6-f946-4cda-9301-c407425243d5@linux.ibm.com \
--to=sshegde@linux.ibm.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@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--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®