From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>,
mingo@kernel.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, kprateek.nayak@amd.com,
linux-kernel@vger.kernel.org, ziqianlu@bytedance.com
Subject: Re: [PATCH v2 12/12] sched: Remove sched_class::balance()
Date: Wed, 11 Nov 2026 21:53:51 +0300 [thread overview]
Message-ID: <avSYpkVnyRKfaZIo@scheduler.schedules> (raw)
In-Reply-To: <20261111161522.GD1922751@noisy.programming.kicks-ass.net>
Hi!
On Wed, Nov 11, 2026 at 05:15:22PM +0100, Peter Zijlstra wrote:
> On Wed, Nov 11, 2026 at 04:47:24PM +0100, Peter Zijlstra wrote:
> >
> > Gah, you're right. This don't work right. Let me try again.
>
> Here, something like so then?
>
> ---
> Subject: sched/deadline: Fix wakeup_preempt() vs dl_server
> From: Peter Zijlstra <peterz@infradead.org>
> Date: Wed Nov 11 14:12:25 CET 2026
> ---
> kernel/sched/deadline.c | 40 +++++++++++++++++++++++++---------------
> 1 file changed, 25 insertions(+), 15 deletions(-)
>
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -715,8 +715,7 @@ static struct rq *dl_task_offline_migrat
> return later_rq;
> }
>
> -static void
> -enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags);
> +static void enqueue_dl_entity(struct rq *rq, struct sched_dl_entity *dl_se, int flags);
> static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags);
> static void dequeue_dl_entity(struct sched_dl_entity *dl_se, int flags);
> static void wakeup_preempt_dl(struct rq *rq, struct task_struct *p, int flags);
> @@ -1184,10 +1183,7 @@ static enum hrtimer_restart dl_server_ti
> dl_se->dl_defer_running = 1;
> }
>
> - enqueue_dl_entity(dl_se, ENQUEUE_REPLENISH);
> -
> - if (!dl_task(dl_se->rq->curr) || dl_entity_preempt(dl_se, &dl_se->rq->curr->dl))
> - resched_curr(rq);
> + enqueue_dl_entity(rq, dl_se, ENQUEUE_REPLENISH);
>
> __push_dl_task(rq, rf);
> }
> @@ -1520,7 +1516,7 @@ static void update_curr_dl_se(struct rq
> replenish_dl_new_period(dl_se, rq);
> start_dl_timer(dl_se);
> } else {
> - enqueue_dl_entity(dl_se, ENQUEUE_REPLENISH);
> + enqueue_dl_entity(rq, dl_se, ENQUEUE_REPLENISH);
> }
> } else {
> enqueue_task_dl(rq, dl_task_of(dl_se), ENQUEUE_REPLENISH);
> @@ -1812,9 +1808,7 @@ void dl_server_start(struct sched_dl_ent
>
> trace_sched_dl_server_start_tp(dl_se, cpu_of(rq), dl_get_type(dl_se, rq));
> dl_se->dl_server_active = 1;
> - enqueue_dl_entity(dl_se, ENQUEUE_WAKEUP);
> - if (!dl_task(dl_se->rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl))
> - resched_curr(dl_se->rq);
> + enqueue_dl_entity(rq, dl_se, ENQUEUE_WAKEUP);
> }
>
> void dl_server_stop(struct sched_dl_entity *dl_se)
> @@ -2379,8 +2373,8 @@ static void __dequeue_dl_entity(struct s
> dec_dl_tasks(dl_se, dl_rq);
> }
>
> -static void
> -enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> +static bool
> +_enqueue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> {
> WARN_ON_ONCE(on_dl_rq(dl_se));
>
> @@ -2418,7 +2412,7 @@ enqueue_dl_entity(struct sched_dl_entity
> if (flags & ENQUEUE_WAKEUP)
> task_contending(dl_se, flags);
>
> - return;
> + return false;
> }
>
> /*
> @@ -2442,7 +2436,7 @@ enqueue_dl_entity(struct sched_dl_entity
> * deferred task and still got to wait, don't enqueue.
> */
> if (dl_se->dl_throttled && start_dl_timer(dl_se))
> - return;
> + return false;
>
> /*
> * We're about to enqueue, make sure we're not ->dl_throttled!
> @@ -2457,6 +2451,22 @@ enqueue_dl_entity(struct sched_dl_entity
> }
>
> __enqueue_dl_entity(dl_se);
> + return true;
> +}
> +
> +static void enqueue_dl_entity(struct rq *rq, struct sched_dl_entity *dl_se, int flags)
> +{
> + /*
> + * Deadline can enqueue entities from various timers; and esp.
> + * dl_server() entities will not pass through wakeup_preempt().
> + */
> + if (!_enqueue_dl_entity(dl_se, flags))
> + return;
> +
> + if (!dl_task(rq->curr) || dl_entity_preempt(dl_se, &rq->curr->dl))
> + resched_curr(dl_se->rq);
> +
> + rq->next_class = &dl_sched_class;
> }
>
> static void dequeue_dl_entity(struct sched_dl_entity *dl_se, int flags)
> @@ -2534,7 +2544,7 @@ static void enqueue_task_dl(struct rq *r
> if (task_on_rq_migrating(p))
> flags |= ENQUEUE_MIGRATING;
>
> - enqueue_dl_entity(dl_se, flags);
> + enqueue_dl_entity(rq, dl_se, flags);
>
> if (dl_server(dl_se))
> return;
I tried running the tests, and the second I tried it crashed :/.
Then I added WARN_ON_ONCE(!dl_se->rq); to catch if dl_se->rq were
causing all this. And changed resched_curr(dl_se->rq)
to resched_curr(rq).
Warning triggered, and because I changed it I was able to test it,
it was around 13 us. (Base was around 12 us so I would count it the same)
Changing it to rq seem to work correct. If I'm not missing any gears in my
brain...
Here's the warning that I added since I wasn't able to get the real
crash logs:
[ 45.193366] ------------[ cut here ]------------
[ 45.193472] WARNING: kernel/sched/deadline.c:2466 at enqueue_dl_entity+0x4a/0x70, CPU#1: stress-ng-cycli/1918
[ 45.193480] Modules linked in:
[ 45.193573] CPU: 1 UID: 0 PID: 1918 Comm: stress-ng-cycli Not tainted 7.4.0-rc1+ #36 PREEMPT(lazy)
[ 45.193576] Hardware name: System manufacturer System Product Name/TUF B450M-PRO GAMING, BIOS 4604 03/22/2024
[ 45.193579] RIP: 0010:enqueue_dl_entity+0x4a/0x70
[ 45.193583] Code: 00 00 00 74 25 48 8b 43 20 8b 50 6c 85 d2 78 1e 48 89 df e8 48 36 fc ff 48 c7 83 a8 0c 00 00 30 e7 d1 96 5b 5d e9 c1 a4 c6 ff <0f> 0b eb d7 f6 45 53 10 75 dc 48 8b 80 50 02 00 00 48 39 45 48 79
[ 45.193586] RSP: 0018:ffffd38d4b597c70 EFLAGS: 00010046
[ 45.193590] RAX: 0000000000000001 RBX: ffff8b5a162b6b00 RCX: ffffd38d4b597bd4
[ 45.193592] RDX: 0000000000000003 RSI: ffff8b5713e1b0a8 RDI: ffff8b5713e1b090
[ 45.193594] RBP: ffff8b57059d0208 R08: ffff8b5713e1b090 R09: ffff8b57059d1048
[ 45.193596] R10: ffff8b57059d0000 R11: 0000000000000000 R12: ffff8b57059d0208
[ 45.193598] R13: ffff8b5a162b6b00 R14: ffff8b57059d0000 R15: ffffd38d4b597d78
[ 45.193600] FS: 00007f3fa07444c0(0000) GS:ffff8b5a7d950000(0000) knlGS:0000000000000000
[ 45.193603] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.193605] CR2: 00007ffd6f7c1688 CR3: 000000012dccc000 CR4: 0000000000f50ef0
[ 45.193608] PKRU: 55555554
[ 45.193610] Call Trace:
[ 45.193612] <TASK>
[ 45.193615] enqueue_task_dl+0x5b/0x170
[ 45.193622] enqueue_task+0x88/0x210
[ 45.193629] sched_change_end+0x147/0x1d0
[ 45.193636] __sched_setscheduler+0x23f/0xd10
[ 45.193648] __x64_sys_sched_setattr+0xb4/0x1f0
[ 45.193659] do_syscall_64+0xed/0x1560
[ 45.193664] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193668] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193671] ? find_held_lock+0x2b/0x80
[ 45.193677] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193680] ? __lock_release.isra.0+0x57/0x170
[ 45.193684] ? count_memcg_events+0x1c9/0x290
[ 45.193689] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193692] ? find_held_lock+0x2b/0x80
[ 45.193698] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193701] ? __lock_release.isra.0+0x57/0x170
[ 45.193704] ? handle_mm_fault+0x218/0x380
[ 45.193712] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193715] ? lock_release.part.0+0x1c/0x50
[ 45.193718] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193721] ? do_user_addr_fault+0x4ba/0x7e0
[ 45.193728] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193731] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193734] ? lockdep_hardirqs_on_prepare.part.0+0x9b/0x140
[ 45.193738] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193741] ? trace_hardirqs_off_finish+0xc6/0xe0
[ 45.193745] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.193749] ? do_syscall_64+0x5e/0x1560
--
[ 45.193815] ---[ end trace 0000000000000000 ]---
[ 57.602578] ------------[ cut here ]------------
[ 57.602584] WARNING: kernel/sched/deadline.c:2466 at enqueue_dl_entity+0x4a/0x70, CPU#0: stress-ng-cycli/1956
[ 57.602593] Modules linked in:
[ 57.602601] CPU: 0 UID: 0 PID: 1956 Comm: stress-ng-cycli Tainted: G W 7.4.0-rc1+ #36 PREEMPT(lazy)
[ 57.602606] Tainted: [W]=WARN
[ 57.602609] Hardware name: System manufacturer System Product Name/TUF B450M-PRO GAMING, BIOS 4604 03/22/2024
[ 57.602612] RIP: 0010:enqueue_dl_entity+0x4a/0x70
[ 57.602617] Code: 00 00 00 74 25 48 8b 43 20 8b 50 6c 85 d2 78 1e 48 89 df e8 48 36 fc ff 48 c7 83 a8 0c 00 00 30 e7 d1 96 5b 5d e9 c1 a4 c6 ff <0f> 0b eb d7 f6 45 53 10 75 dc 48 8b 80 50 02 00 00 48 39 45 48 79
[ 57.602621] RSP: 0018:ffffd38d4b6ffa70 EFLAGS: 00010046
[ 57.602626] RAX: 0000000000000001 RBX: ffff8b5a16236b00 RCX: ffffd38d4b6ff9d4
[ 57.602629] RDX: 0000000000000003 RSI: ffff8b5713e1b0a8 RDI: ffff8b5713e1b090
[ 57.602632] RBP: ffff8b57059c0208 R08: ffff8b5713e1b090 R09: ffff8b57059c1048
[ 57.602634] R10: ffff8b57059c0000 R11: 0000000000000000 R12: ffff8b57059c0208
[ 57.602637] R13: ffff8b5a16236b00 R14: ffff8b57059c0000 R15: ffffd38d4b6ffb78
[ 57.602640] FS: 00007f56864024c0(0000) GS:ffff8b5a7d8d0000(0000) knlGS:0000000000000000
[ 57.602644] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 57.602647] CR2: 00007fff971de0e8 CR3: 0000000127ad3000 CR4: 0000000000f50ef0
[ 57.602650] PKRU: 55555554
[ 57.602653] Call Trace:
[ 57.602656] <TASK>
[ 57.602661] enqueue_task_dl+0x5b/0x170
[ 57.602670] enqueue_task+0x88/0x210
[ 57.602680] sched_change_end+0x147/0x1d0
[ 57.602689] __sched_setscheduler+0x23f/0xd10
[ 57.602705] __x64_sys_sched_setattr+0xb4/0x1f0
[ 57.602720] do_syscall_64+0xed/0x1560
Cheers,
Kayra
next prev parent reply other threads:[~2026-11-11 18:53 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 11:59 [PATCH v2 00/12] sched: core-sched fixes and balancing Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 01/12] sched/core: Fix pick_next_task() self recursion Peter Zijlstra
2026-11-11 0:30 ` Tejun Heo
2026-11-11 10:45 ` Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 02/12] sched/core: Introduce rq_drop_lock() Peter Zijlstra
2026-11-08 9:25 ` Kayra Cizmeci
2026-11-11 10:46 ` Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 03/12] sched/core: Decompose update_rq_clock() Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 04/12] sched/core: Make __update_rq_clock() skip updates on UPDATED Peter Zijlstra
2026-11-11 1:11 ` Tejun Heo
2026-11-11 10:28 ` Peter Zijlstra
2026-11-11 12:25 ` Peter Zijlstra
2026-11-11 17:08 ` Tejun Heo
2026-11-07 11:59 ` [PATCH v2 05/12] sched/core: Abstract/fix rq_clock_start_loop_update() Peter Zijlstra
2026-11-08 22:26 ` Kayra Cizmeci
2026-11-11 9:10 ` K Prateek Nayak
2026-11-11 9:51 ` Kayra Cizmeci
2026-11-11 16:39 ` Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 06/12] sched/core: New rq_{pin,drop,repin,unpin}_lock() semantics Peter Zijlstra
2026-11-11 10:41 ` Tejun Heo
2026-11-07 11:59 ` [PATCH v2 07/12] sched/core: Simplify/fix time updates Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 08/12] sched/core: Allow newidle for core-sched Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 09/12] sched/rt: Add early exit on balance path Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 10/12] sched/fair: Reflow pick_task_fair() / newidle Peter Zijlstra
2026-11-11 11:02 ` Tejun Heo
2026-11-11 12:31 ` Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 11/12] sched/fair: Push sched_balance_newidle() unlock down Peter Zijlstra
2026-11-07 11:59 ` [PATCH v2 12/12] sched: Remove sched_class::balance() Peter Zijlstra
2026-11-11 11:18 ` Tejun Heo
2026-11-11 13:05 ` Peter Zijlstra
2026-11-11 13:11 ` Peter Zijlstra
2026-11-11 14:57 ` Kayra Cizmeci
2026-11-11 15:47 ` Peter Zijlstra
2026-11-11 16:15 ` Peter Zijlstra
2026-11-11 18:53 ` Kayra Cizmeci [this message]
2026-11-11 11:46 ` [PATCH v2 00/12] sched: core-sched fixes and balancing Tejun Heo
2026-11-11 13:57 ` 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=avSYpkVnyRKfaZIo@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=ziqianlu@bytedance.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®