public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+00a022dc9979d67df050@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [kernel?] WARNING in enqueue_dl_entity
Date: Fri, 13 Dec 2024 19:03:05 +0800	[thread overview]
Message-ID: <20241213110305.1839-1-hdanton@sina.com> (raw)
In-Reply-To: <67410a37.050a0220.363a1b.0150.GAE@google.com>

On Fri, 22 Nov 2024 14:48:23 -0800
> syzbot has found a reproducer for the following issue on:
> 
> HEAD commit:    28eb75e178d3 Merge tag 'drm-next-2024-11-21' of https://gi..
> git tree:       upstream
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1016fec0580000

Test fix (https://lore.kernel.org/lkml/20241213032244.877029-1-vineeth@bitbyteword.org/ )

#syz test upstream master

diff -pur x/include/linux/sched.h y/include/linux/sched.h
--- x/include/linux/sched.h	2024-12-13 18:53:21.592682100 +0800
+++ y/include/linux/sched.h	2024-12-13 18:55:17.754180400 +0800
@@ -656,6 +656,12 @@ struct sched_dl_entity {
 	 * @dl_defer_armed tells if the deferrable server is waiting
 	 * for the replenishment timer to activate it.
 	 *
+	 * @dl_server_active tells if the dlserver is active(started).
+	 * dlserver is started on first cfs enqueue on an idle runqueue
+	 * and is stopped when a dequeue results in 0 cfs tasks on the
+	 * runqueue. In other words, dlserver is active only when cpu's
+	 * runqueue has atleast one cfs task.
+	 *
 	 * @dl_defer_running tells if the deferrable server is actually
 	 * running, skipping the defer phase.
 	 */
@@ -664,6 +670,7 @@ struct sched_dl_entity {
 	unsigned int			dl_non_contending : 1;
 	unsigned int			dl_overrun	  : 1;
 	unsigned int			dl_server         : 1;
+	unsigned int			dl_server_active  : 1;
 	unsigned int			dl_defer	  : 1;
 	unsigned int			dl_defer_armed	  : 1;
 	unsigned int			dl_defer_running  : 1;
diff -pur x/kernel/sched/deadline.c y/kernel/sched/deadline.c
--- x/kernel/sched/deadline.c	2024-12-13 18:51:17.093081100 +0800
+++ y/kernel/sched/deadline.c	2024-12-13 18:55:17.770211500 +0800
@@ -1647,6 +1647,7 @@ void dl_server_start(struct sched_dl_ent
 	if (!dl_se->dl_runtime)
 		return;
 
+	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);
@@ -1661,6 +1662,7 @@ void dl_server_stop(struct sched_dl_enti
 	hrtimer_try_to_cancel(&dl_se->dl_timer);
 	dl_se->dl_defer_armed = 0;
 	dl_se->dl_throttled = 0;
+	dl_se->dl_server_active = 0;
 }
 
 void dl_server_init(struct sched_dl_entity *dl_se, struct rq *rq,
@@ -2421,8 +2423,10 @@ again:
 	if (dl_server(dl_se)) {
 		p = dl_se->server_pick_task(dl_se);
 		if (!p) {
-			dl_se->dl_yielded = 1;
-			update_curr_dl_se(rq, dl_se, 0);
+			if (dl_server_active(dl_se)) {
+				dl_se->dl_yielded = 1;
+				update_curr_dl_se(rq, dl_se, 0);
+			}
 			goto again;
 		}
 		rq->dl_server = dl_se;
diff -pur x/kernel/sched/fair.c y/kernel/sched/fair.c
--- x/kernel/sched/fair.c	2024-12-13 18:50:13.649803300 +0800
+++ y/kernel/sched/fair.c	2024-12-13 18:56:11.779225700 +0800
@@ -1159,8 +1159,6 @@ static inline void update_curr_task(stru
 	trace_sched_stat_runtime(p, delta_exec);
 	account_group_exec_runtime(p, delta_exec);
 	cgroup_account_cputime(p, delta_exec);
-	if (p->dl_server)
-		dl_server_update(p->dl_server, delta_exec);
 }
 
 static inline bool did_preempt_short(struct cfs_rq *cfs_rq, struct sched_entity *curr)
@@ -1237,11 +1235,16 @@ static void update_curr(struct cfs_rq *c
 		update_curr_task(p, delta_exec);
 
 		/*
-		 * Any fair task that runs outside of fair_server should
-		 * account against fair_server such that it can account for
-		 * this time and possibly avoid running this period.
+		 * If the fair_server is active, we need to account for the
+		 * fair_server time whether or not the task is running on
+		 * behalf of fair_server or not:
+		 *  - If the task is running on behalf of fair_server, we need
+		 *    to limit its time based on the assigned runtime.
+		 *  - Fair task that runs outside of fair_server should account
+		 *    against fair_server such that it can account for this time
+		 *    and possibly avoid running this period.
 		 */
-		if (p->dl_server != &rq->fair_server)
+		if (dl_server_active(&rq->fair_server))
 			dl_server_update(&rq->fair_server, delta_exec);
 	}
 
diff -pur x/kernel/sched/sched.h y/kernel/sched/sched.h
--- x/kernel/sched/sched.h	2024-12-13 18:50:42.985005300 +0800
+++ y/kernel/sched/sched.h	2024-12-13 18:55:17.801793100 +0800
@@ -398,6 +398,11 @@ extern void __dl_server_attach_root(stru
 extern int dl_server_apply_params(struct sched_dl_entity *dl_se,
 		    u64 runtime, u64 period, bool init);
 
+static inline bool dl_server_active(struct sched_dl_entity *dl_se)
+{
+	return dl_se->dl_server_active;
+}
+
 #ifdef CONFIG_CGROUP_SCHED
 
 extern struct list_head task_groups;
--

  parent reply	other threads:[~2024-12-13 11:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-28 17:15 [syzbot] [kernel?] WARNING in enqueue_dl_entity syzbot
2024-11-22 22:48 ` syzbot
2024-11-23  2:10   ` Hillf Danton
2024-11-23  2:12     ` syzbot
2024-12-13 11:03   ` Hillf Danton [this message]
2024-12-13 11:32     ` syzbot

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=20241213110305.1839-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+00a022dc9979d67df050@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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