From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.167.242.64 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796541932; b=ukWdGMY1NzjH2BzagcMZO9QLhtPF8HM97aGjmbpvgngNRSdMlBwXLPT6rWKXpsqr0NzF Rfux+zQsbrzCNPm3XODeff/UJ+VUYBYtwy9JGXlSQg0xCzVk129NN7fBlQ59oxxLZe87R PANMWkoqh4ucZPPanaEKLqsS8rvo66z3SGeDQkKte2fC9yt20BV1xnV87wb5ZoYsEWrTu t2H9YxNOwkqwkALqNwQ08vMz5do8QSGNRxcWd/SBQHtJ9KqBgB2SAkIGuk34L+ab+cIrM YrUCU8NJqd8VtAeuED4CX1p1sDDI9ka5a0xaFLCYTi80rN81JlU+UUu+JwjjI3wb7QA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796541932; h=DMARC-Filter:Received:DKIM-Signature:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=rZD177Evvb20eN6WxPAwAjZ/5JcDz1pxbhqGbHwEDFs=; b=3+pReUdB9Kw83mKEkXdDoWOel4TF8AzVJM4xUAeA4rQsNhsRdnxaXxwoXkFLU2JmXhts mh7APcNyRCPaPmcmorpqAKCY+liwUqeTvlZOscSrCSkUTACwt5bTXAlhLlmclGknTlj/T udFQOhyxTsoDnk3DqQoRJJC4OScVUDEvpibCZDscQJENQfIP+8HQjbDyGmUfLazPYIS8x 46jJrciNZj932yZRSeGqH+owc5sOtMukYGzTp43zqI4T3y3542WKDg3dUMcVEyqXQDi1k jYUMNq4roVc6+ZKlHd3glXBijk2TJLF8cQSnLlgAhyIrY+iKIZ9XCWxATkuiJUfF9eQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=KlrM9Zgu; arc=none smtp.remote-ip=213.167.242.64 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7A0F606A31F for ; Sun, 6 Dec 2026 07:25:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A7A0F606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=KlrM9Zgu Received: from killaraus.ideasonboard.com (fp7965754b.ap.nuro.jp [121.101.117.75]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 16402C3D; Sun, 6 Dec 2026 08:22:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796541768; bh=IX+ZNFFkEFW+q6j7hH7runVRX9OPqRqfbCEX8sfo2oQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KlrM9Zgu6Zd+yhq7f8TwYdE2CEyHHbimHRQAwg2rQr+vD62jszECkGiFIPHOpoQM+ LP1p4DCVgoJTaF5KLMBO7P6dgMJj/BEuoj0m3KHdQEsm+RERAs74TZ4yTp2F3k8kqS 6j4UCKJvimu/xfuK/y/hPR5CplCVb84u3lBSeU3s= Date: Sun, 6 Dec 2026 16:25:25 +0900 From: Laurent Pinchart To: Steven Rostedt Cc: LKML , sched-ext@lists.linux.dev, Tejun Heo , David Vernet , Andrea Righi , Changwoo Min , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Jonathan Corbet , Greg Kroah-Hartman , Sasha Levin Subject: Re: [RANT][PATCH] sched_ext: Fix stale fair load weight after renice under SCX Message-ID: <20261206072525.GA1047183@killaraus.ideasonboard.com> References: <20261204093507.424049cf@gandalf.local.home> X-Mailing-List: sched-ext@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261204093507.424049cf@gandalf.local.home> On Fri, Dec 04, 2026 at 09:35:07AM -0500, Steven Rostedt wrote: > From: Steven Rostedt (LLM) > > While working on my scheduler governors using Claude, it discovered a bug > with the sched_ext reweight_task_scx() function. It wrote up the change > log and created a patch. The change log is below which is mostly from > Claude, but I did tweak it a little. > > set_load_weight() hands a changed weight to the class's ->reweight_task > and only writes p->se.load itself when the class has no such hook: > > if (update_load && p->sched_class->reweight_task) > p->sched_class->reweight_task(task_rq(p), p, &lw); > else > p->se.load = lw; > > reweight_task_fair() updates se.load as part of reweighting, but > reweight_task_scx() only updates p->scx.weight. So a task whose nice > value changes while it is in the ext class keeps the fair load weight it > had before, and nothing refreshes it when the task goes back to fair: > neither switched_from_scx() nor scx_disable_task() does, and fair never > recomputes a task's weight when it switches in. Forks copy the stale > se.load too. > > There are two ways to hit it: > > - renice a task while a BPF scheduler runs it, then unload the > scheduler (or move the task out of SCHED_EXT); > > - move a task from SCHED_EXT to SCHED_NORMAL and change its nice value > in the same sched_setattr(). set_load_weight() then runs while the > task is still in the ext class but already disabled, and > reweight_task_scx() returns before it gets anywhere. > > Reproduced on v7.4-rc5 under QEMU with scx_simple (switch-all) for the > first case and scx_qmap -p for the second. Two CPU-bound tasks pinned to > one CPU, nice 0 and nice 10, measured for 3s after the nice-10 one was > reniced under SCX and the scheduler unloaded: > > nice 0 nice 10 ratio nice-10 weight > no sched_ext (control) 2711ms 290ms 9.33 112640 > reniced under sched_ext 1500ms 1501ms 1.00 1048576 (nice 0) > ... with this patch 2708ms 292ms 9.29 112640 > > In the sched_setattr() case, a SCHED_EXT task switched to SCHED_NORMAL > with nice 5 kept weight 1048576 (nice 0) instead of 343040. > > The stale weight survives wakeups and is only corrected by a later > set_load_weight() for the task, such as another renice while in fair. > > Store the new weight in se.load at the top of reweight_task_scx(), > before its early returns, so that the sched_setattr() case is covered > too: storing it next to the p->scx.weight update fixes the first case > but not the second. The task is not on a cfs_rq while it is in the ext > class, so this is the same plain store set_load_weight() already does for > rt, dl and idle-policy tasks. > > The bug was found by Claude Code while working on unrelated scheduler > changes. It also wrote the QEMU reproducer, the fix and this changelog. > > Cc: stable@vger.kernel.org > Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class") > Assisted-by: Claude:claude-opus-5-5 > Signed-off-by: Steven Rostedt > --- > > This is my first completely vibe coded patch. Working on my scheduler > governors project using Claude Max (thank you Anthropic for the tokens!), > the agent discovered this bug in sched_ext. It asked me if I wanted to send > it upstream. I first asked it to make sure that it was still an issue with > v7.4-rc5 as the tree I was working on was at v7.2. It looked at v7.4-rc5 > and told me that it didn't find anything to address the bug. It then built > v7.4-rc5, booted it in qemu, created a test for it, and found that it was > still a bug. > > I told it to fix it, which it did, but the first patch was a bit invasive > in the core scheduler code. I asked it if it could fix it in the sched_ext > code, where it said "That's a great idea" and created this one-line patch. > It then wrote the change log and told me how to send it and who to send it > to. It even asked me if I wanted it to send it! I told it "No!". (Does this > mean I've been talking with AI bots directly with no human in the loop?? I > thought they were simply cut-and-pasting the output :-/). > > It noticed that the "Assisted-by" tag is no longer needed, but I insisted > that it included it. As I looked at the "From:" line, I thought to myself, > it's going to say that I'm the author of this patch. THAT IS A LIE!!!! > > > > This is my first full experience with an AI agent doing code. It was not > much different than working with junior developers that I have mentored in > the past. I'm currently in Japan (I will present at OSSJ next week). A week ago I spent a few days of vacation in Teshima with a colleague of mine, who started working for my company when they were a junior straight out of university. Every time I hear someone comparing a coding agent to a junior developer, I think how sad it would be to travel, dine and go out for drinks with the sole company of an LLM. I think it's our collective responsibility (as a society, not just in the kernel) to fight against this dystopian narrative and refuse the future sold by AI companies. > I just told it what to do. It found a bug. It created a test case > and proved it to be true. I just sat back and watched the token counter rise. > Now it expects this patch to be sent with me as the author. I can't! God > Dammit! I entered open source programming because I loved looking at the > output from very talented programmers. I learned from them so one day I > could be just as talented and show off what I could do. Open Source is a > great place to find like minded individuals who are talented and you can > work together teaching and learning at the same time. I've always said that > my code was my art. I'm a huge advocate of "giving credit where credit is > due". If I got something from someone, I always gave them credit even when > it went against my interests. I love showing off the work of others too. > > I didn't write this patch. Putting my name on it is exactly the same as > going to ChatGPT and having it create a picture and say that I drew it. > The picture is art and so is code. I will not claim any code created by an > agent as my own. For this patch, I'm adding "(LLM)" to my "From:" line to > point out that this came from an agent and not from me. I only supervised > it, I didn't create it. > > God help us for the future of programming if most people entering are just > using AI agents and not ever writing the code themselves. The first version > of this patch worked perfectly fine. It was my decades of experience that > told me it wasn't proper engineering to do it that way. People who just > vide code will never get the experience for proper engineering. AI agents > could possibly handle these bad coding choices, but they are going to > compound and eventually these bad decisions AI makes will become an issue > even for AI. The reason I know these were bad decisions is because of > decades of experience in making bad decisions and understanding their > impact. I learned this the hard way and I'm much better because of that > now. AI makes mistakes all the time (I even saw in the logs that it tried > something and it accidentally deleted something it didn't mean to and had > to redo it). But the engineering design mistakes it makes now will require > destroying the entire project and rewriting later. Maybe AI could handle > that but will people understand what was wrong with the design if they were > not the ones that created it? It's going to be costly regardless. Tokens > had better become cheaper by then! Amen. This is a well documented issue, you're far from the first one to raise it. It honestly puzzle me to see so many people burrying their head in the send in response to AI, embracing the technology while refusing to see the vast amount of problems it generates. I'm cautiously optimistic though, I see an increasing number of maintainers who were quite positive about coding agents slowly realizing that this is not sustainable. > Anyway, I'm keeping the Assisted-by tag and marking my authorship with > "(LLM)" to make it obvious that I did not write this code. I wasn't invited > to the last Maintainers Summit so I couldn't voice my opinion on the matter > when they decided to get rid of the "Assisted-by" tag. One of the > complaints was people who vide coded didn't add that tag and we couldn't > enforce it. Well, to me, those that do that are no better than those using > ChatGPT to create artwork and calling it their own! > > This experience seems to have left a bitter taste in your mouth. I'm curious to know why you decided to inflict upon yourself something you described in such a negative way. Or maybe I'm misreading you and you didn't find it that negative overall. > kernel/sched/ext/ext.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c > index efa1d01d03af..81404b37fbd1 100644 > --- a/kernel/sched/ext/ext.c > +++ b/kernel/sched/ext/ext.c > @@ -5019,6 +5019,15 @@ static void reweight_task_scx(struct rq *rq, struct task_struct *p, > > lockdep_assert_rq_held(task_rq(p)); > > + /* > + * set_load_weight() leaves se.load to the class when it has > + * ->reweight_task. Keep it current: it is the weight the task takes > + * back to the fair class. This must come before the early returns > + * below, as a task switching from SCX to fair through > + * sched_setscheduler() is reweighted here after scx_disable_task(). > + */ > + p->se.load = *lw; > + > if (task_dead_and_done(p)) > return; > -- Regards, Laurent Pinchart