From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796396438; b=d141w6Y52/EHLhyID3e7DAnzrPJ6ReZuHEhZOu+fSN615RV60Cv5A66tMLwDxisLi6D9 NfSO6c2S6ZyW+6pnjouIlPBOTE5Q5kFwaDuS7vjy8vWJeBF17nfP7IInUKdyg9eJnPvLE n37fAEh3SukJV2gBBZdt7if8Bg5EKHqEUf10gU62LAc6vCzscjd8mhPtMY9B9N2AjzlZ5 HqnAn+ByL6kmmUxfvPP8x3vJkICsartesMNlEH4eFIxnDqQs+KU0rnxLfiwXbClbUcmza WnZ+mBkjNuOtTNdWvJvJZ3tSWQPSFsxGVnGyzkO1XUjoz/vB+9Nd9rOjgdXc6KVUKoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796396438; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=QQsWIro+pzx8CGaU0OZ8REuSKxJwO2qSxsRCEmhfjqY=; b=RmMfExaMTKxZ653Pdvd3ImnbpKAmwBlzfIvA278/aSwcfoLWGMt8tSBhyhqZA+q8cgT2 wUSWHFr/Q1QA4biQSyJJaGEXCKHEcG72wI41qkZ+wW1WnRI6Aq2AUS+3I2GXlvwYzKPAK iCxpxghitrFKn/7g0AVfoEBrzMSd3oB/Z6vYjWAYj/UfbrDDjSN0NPeUH31/IYqr6DdUE j+3mW1lDhr11WfJGsEWL2aXywyzlIBdX3U+GtvVqfwUHBgyr6cyWf9Y1RME/D1kG+0649 AL5gQoqY8msY7hfDSEkIa7zbarjHian+ZxH1PnnO6w12sJIkdETyNpCTaLvtgwIMgvg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z8SpM7So; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDC31606A681 for ; Fri, 4 Dec 2026 15:00:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z8SpM7So Received: by smtp.kernel.org (Postfix) with ESMTPSA id 387F41F000CE; Fri, 4 Dec 2026 15:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796396438; bh=QQsWIro+pzx8CGaU0OZ8REuSKxJwO2qSxsRCEmhfjqY=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Z8SpM7Soe4GlPpWEi9mpeIjRTrQRsETrZFMCZiZzTLqE9RsbsJlG8tqcfGjGj8HLH CqpRBC4IrFOK+2SOYc0tWXpHqWpQqzIgFe713HmQALeYTiiwg9GcuB8csR8+RD7Rdn 5lSTAciVLG+VrAwG3TprJpOx3kDurVOo8oN5VGQ1c48Pks1hVLlcQw/wUuq8mhyyra vyKZGr4OrX7r+KUbSSKSNUVMK8nhB5Qd/pLtT5zm5+jKvBtdfRVV6D/jXXpWieujA+ +XZul3kHmCqFnUOStvBXAm8G3htiyaKEtDX13ayi1wDHnvZAhz4Ef+pXwKTShb4Z+6 QV34MiJ/Vefjw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RANT][PATCH] sched_ext: Fix stale fair load weight after renice under SCX Reply-To: sashiko-reviews@lists.linux.dev To: "Steven Rostedt" , sched-ext@lists.linux.dev In-Reply-To: <20261204093507.424049cf@gandalf.local.home> References: <20261204093507.424049cf@gandalf.local.home> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 15:00:37 +0000 X-Mailing-List: sched-ext@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] sched_ext: reweight_task_scx() updates se.load without rescaling load_avg -- commit 1b86025ef32391b326ae8f39902ded0ecc0ca419 Author: Steven Rostedt (LLM) sched_ext: Fix stale fair load weight after renice under SCX This commit stores the new weight in p->se.load at the start of reweight_task_scx() so that tasks whose nice value changes while in ext_sched_class carry the updated fair load weight back to fair_sched_class. > diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c > index a9e36b5bb0386..5aca62ef08a75 100644 > --- a/kernel/sched/ext/ext.c > +++ b/kernel/sched/ext/ext.c > @@ -5018,6 +5018,15 @@ static void reweight_task_scx(struct rq *rq, struc= t task_struct *p, > =20 > lockdep_assert_rq_held(task_rq(p)); > =20 > + /* > + * 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 =3D *lw; [Severity: Medium] Does updating p->se.load without rescaling p->se.avg.load_avg violate PELT load invariants when the task returns to fair_sched_class? If a task lowers its weight in ext_sched_class (for example, switching from SCHED_EXT at nice 0 to SCHED_IDLE via sched_setattr()) and returns to fair_sched_class within the same 1024us PELT period, __update_load_avg_se() skips ___update_load_avg(). se->avg.load_avg then remains scaled to the old, higher weight when switched_to_fair() -> attach_entity_cfs_rq() calls attach_entity_load_avg(): kernel/sched/fair.c:attach_entity_load_avg() { ... se->avg.load_sum =3D se->avg.load_avg * divider; if (se_weight(se) < se->avg.load_sum) se->avg.load_sum =3D div_u64(se->avg.load_sum, se_weight(se)); else se->avg.load_sum =3D 1; enqueue_load_avg(cfs_rq, se); ... } Dividing by the new smaller se_weight(se) without clamping to LOAD_AVG_MAX inflates se->avg.load_sum (up to ~341x LOAD_AVG_MAX for nice 0 to SCHED_IDL= E) and enqueues the inflated load onto cfs_rq->avg, distorting CFS load balancing and cgroup share calculations. Should p->se.avg.load_avg be rescaled alongside p->se.load (as reweight_entity() does) when updating the weight here? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204093507.4240= 49cf@gandalf.local.home?part=3D1