From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.47 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796398863; b=TpUBw9fOHGubGrTQDWoEeBakvyfWaf71E5/L3HU5KKbQix0rEnGI49pTKZf9TQzKQHUH ZQgihoY3JfSf01/gA69frmYjk1TpeL/IVkgBlE8UWvPqjuIxAi57lan72j18KdtuUvxpu e8/bwzXkrmkEb1/OMUFGaPkFM6YWn8cGRL/nenTe6WKbYKM71CB2gG59TvaQw90VwBA2q aQRgk62tYb8qCBMRB/2FOgXwIM6zHnUcaZ+V2OiSM66kOoOelMeHDJhZV4Xwom3EXxNUb vFdtPpGFiP9Oe/rvwydhj4h8nzsNe/8cycNlXWhPFVeea+VpYJCAqvmsdsbw+aqBA/g== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796398863; h=DMARC-Filter:DKIM-Signature:Received:Received:Date:From:To:Cc: Subject:Message-ID:References:Content-Type:Content-Disposition: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=hMoPYKldJ1xbTW8hK1NIypPQs+ZXJGi8vA2eCsbMNnM=; b=Fdw9k7r2rWmiNpxTaHJzYLcd//Yao+2W/aKgl1V9+Frgk5rIqGUVI3jt55YD3vJB1OfI u8S7YfJ1OUdokAgphsj0RlXc+Y5NKK4vLk8xdAWwtvY4RO5RexsEanSlWLwiqR930yLKR B4Q1xRYWPlve9kgWixDlv3QZpHciW3vkTJN+TIR7pVubdM0eQHvBx8Uopuj7xMyE49F3D 8UbJHZ3NU77MAZ0Yeket5I2y7Z0NanyD53WQKYu2YUnb9gYHOM3e7XD3nMYbo8Cs0RMV2 fC72oHeLRjygC2cb4Nrt7RUJEJn9GVxPu3OLXiG/nGU4Wq9hb78MR3CnnewwJAmsZow== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=flgJXXrZ; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.47 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010047.outbound.protection.outlook.com [52.101.61.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10F00606A322 for ; Fri, 4 Dec 2026 15:41:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 10F00606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=flgJXXrZ ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ecnNUEgBOsODU7Xq+5dYi3/qgWObGHCCltS59AhKDX/htHuZ5qK6o6cE4v2r09aI520+HC8GWMMgqQu6Ekj8m8yrbNC3oAD+GZwallYGlZSwRmHw2KXhgES6YaSDnMOZOlPbNWti4bnr+ivugLfNc7E4Uale5agv8pmDkBuWsM3thF4b6H7PEzEIigJ3q4NEwl5VA1j+i7X2xxekoxlXOiihXMquuUQDg3NxsyNvNQFnA5K8tc3bMVCizRc7GCRVS8FLcZX16H5rQfOL20Tewem51UrS5C+jRgKQNzTTbqZXGgOxgUr/ZIQSTHXkB3rKlQwBQumDA9TFS3EEwuTWvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hMoPYKldJ1xbTW8hK1NIypPQs+ZXJGi8vA2eCsbMNnM=; b=Rqd31+fOU/0Fox0CMaBMPfmE4gE7Bw2r++9yhBiRDDuv7l0peH32G/J+jE9UU0r8JitdKNnYX+VQs+vTR+n27JrznErQa3gXiX7oVOEKbVbluiWZq2gH1kP7MOq8+R1jC5icxkB9avP18+3C+2ELPI+L0ssHaeDt7RlWX+GPTn+7KZQTOYVcqLZ+p9yPp/YfSJ7gax85GDtIHvL5VhxzJTHm0Cj9GPmOKClyGBVv0g5nj891rGixS0goSva0IWwlBvrzTiJNMx7BqcM+1nB2n5eKiK/7LUFnscPTDbWtmSnCZCkaldk+d8cr3VqwzSqep9QTgN0WYSk0r5b2drIhkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hMoPYKldJ1xbTW8hK1NIypPQs+ZXJGi8vA2eCsbMNnM=; b=flgJXXrZo0SOJa27ydIWQEOXD0AWlup6i7q+LhCFUQa4RCUUtgIKRb7Cp9gQHjNsvdt53cqXUYs6+djHkeAWNayhRsEKZuV6njH6KPOkrBcX1f31ipvpqYiACNup0XTtBll3M9SWTjIJETT9Qptrshzdg1VFJjrdgtz3rBP/5ma+e1LcjSnMZUd9g7nSsfsDRqQeTZpQgstlH4eFAYHe+yBsmbvM5yNOutTl61S8T1r+FFnLQymCPmK/qg1tc2WYLibv/IHwCwRzbhVZ5zQbCA/xP8E3rhKp6/M75DqFPL8ZXMvCxYxH27YvqM4YxxH1V2NUUukSpWJ060Iq26eekg== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BL1PR12MB5174.namprd12.prod.outlook.com (2603:10b6:208:31c::19) by LV2PR12MB5917.namprd12.prod.outlook.com (2603:10b6:408:175::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Fri, 4 Dec 2026 15:40:35 +0000 Received: from BL1PR12MB5174.namprd12.prod.outlook.com ([fe80::58de:822b:868:96e9]) by BL1PR12MB5174.namprd12.prod.outlook.com ([fe80::58de:822b:868:96e9%5]) with mapi id 15.21.0688.010; Fri, 4 Dec 2026 15:40:34 +0000 Date: Fri, 4 Dec 2026 16:40:23 +0100 From: Andrea Righi To: Steven Rostedt Cc: LKML , sched-ext@lists.linux.dev, Tejun Heo , David Vernet , Changwoo Min , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Jonathan Corbet , Greg Kroah-Hartman , Sasha Levin , Zicheng Qu Subject: Re: [RANT][PATCH] sched_ext: Fix stale fair load weight after renice under SCX Message-ID: References: <20261204093507.424049cf@gandalf.local.home> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261204093507.424049cf@gandalf.local.home> X-ClientProxiedBy: MI3PEPF0000753C.ITAP293.PROD.OUTLOOK.COM (2603:10a6:298:1::4d8) To BL1PR12MB5174.namprd12.prod.outlook.com (2603:10b6:208:31c::19) 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 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR12MB5174:EE_|LV2PR12MB5917:EE_ X-MS-Office365-Filtering-Correlation-Id: ab1f0b71-ddfe-4c47-0553-08df521cef9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|366016|1800799024|11063799006|5023799004|18002099003|22082099003|56012099006|261026121527099003|261102123227099003|10067099003|261021121427099003|261028144727099003|261026140227099003|261021135927099003|261022105027099003|261022075727099003; X-Microsoft-Antispam-Message-Info: PyVb/Y9N9I/oZFyZsDlYJOJC9tw3o80822f1DqNFhSFmoaa9LI5/IvdH9gCGHJu9cLGTCPvwgudGd8uP+M1QMACEY7CfQZt1ASLJAYRsKWt2JC6RpR+9e05dpTofU0gRjZ7b/iXsg2QLSL8P3PE6QMHtkL8SsRRB9GE8EE7oBek6/7JRiB4R7fbu7kM9MbyFJAP1yWDz57YPu9kO6TKNrT4ZRh0o8j+9Ww5ER1VZJ/AJL5AngsH+on6gLEYAlITSQni95nnP4yQvozD5EykgRKNZBc5hnTh2pJb2uJ2TEVyDAXrOCruIEYLrK5ZvKLa2R+UVr6DynUeOVEpVBfagAlh2TLm254VVag4SVgVsjtWhJZbRUTQbK1fUZMu/w6nOwhjRz3vk0DSMzMgGC5DmlpEnvq1EewpklPH3yj/abaqtb+IYNyhYHkuEioKds/RezjcqKIHu3h8kVovokxXjU81J90zRNmowq9Ulkxt0cPWvuag1UrpPmd4fS7SpsVASLZUi0gc0BwZ5MxH4nxxSWAq1h7/ehhZPyawLYY8Rq5x5JYwCE4I9rauRM+vcMq+0t8GjLR+cW132tFezVFoHBnbTjbZeg2D6uEinJK5wCKNJNU7m63CHRTOceRuez0hZa9jVD4ByWrlgaksYPT5WmkZK/swBy6Vd4mmVfp/X01M= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5174.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(23010399003)(366016)(1800799024)(11063799006)(5023799004)(18002099003)(22082099003)(56012099006)(261026121527099003)(261102123227099003)(10067099003)(261021121427099003)(261028144727099003)(261026140227099003)(261021135927099003)(261022105027099003)(261022075727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2utp+9PtH9qTriyhjuvmOA+Npnp8O4hq3+CawKotm34NKOblv6y1racK+Q1l?= =?us-ascii?Q?ZYLdewt8F6upUeGox6Zl9++c0/rAhYzgpHIbFODpN16/saB4NTvJ8K2uquQD?= =?us-ascii?Q?7DGWaa6Epe5XpvIg39zSRBToMuEpzTPpcIcV/IMWrpsDdJqXZBZP0QKcTxw1?= =?us-ascii?Q?zSJul/+80VIA+YFkMlMTev/eyqVIjZC+KmrvnFlK8wByPQTibhKz3GZHYMvz?= =?us-ascii?Q?5jcfKeThEQ26+L/7xQAemN70IBrVB0ZMGTDWrKdT3fbWJt7O/nD0AgXNCwlW?= =?us-ascii?Q?Fc0B5ZD1C3GpCiYSTSuIGoypQvSpwLgjlsN2rETW9OB5CyY/gkQo3nAr0Cj2?= =?us-ascii?Q?aKl0Ad2zDC09ETU+7nJPh6O83gKHrLJPFczk00K6La1ZeD0x49HwhhpKxeRO?= =?us-ascii?Q?gvxk9YdFMnjd5zubORxysi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ascii?Q?h3dFBLCm+J5ylxkcbeT9e2RyxLKKxQX4vzul1oAIDYUcJtDfbkLrxfyJydYH?= =?us-ascii?Q?qx+e0n7F2n/ALEQe3t68LNUwKCrC13UqW0CrLDdpRUqqqXLLijVMSL1SqOIt?= =?us-ascii?Q?R10pFbNoG4JJmngrd/L08D9cKkxV9vJ+ySuGx7wKqjysJL3sKU1AGgKDSxkX?= =?us-ascii?Q?r9bWti4lBszEbIKHlKJ8PC2iDSR86lCm6jIjihRxMlYFAHnLqUPjAlgv1djC?= =?us-ascii?Q?daZsez2W/urmYAEKDq+b5B2cpIudidI2t0NBT9x24fdfsUIr38iZLDjzv+IY?= =?us-ascii?Q?8J0sd6EGwrfYHN91t5HQwu+mD+GueU81YiEd77tAEPscOQSH9JPh+0cS9s8R?= =?us-ascii?Q?g+RH7r/+CfFfjkkyfHYZx9NhnGybrZq4c7tC2bEoBHymJTywdKyeKlPAsaId?= =?us-ascii?Q?me9XCvAa4g=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab1f0b71-ddfe-4c47-0553-08df521cef9a X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5174.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 15:40:34.5964 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7X96HDmw920lWDkVnggziQqnL001qEmZhD/9XJ1ei/WF/GTuvLJkunNV4PnY2r6zqGTN5FdeKij50eNcs7u/Ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5917 Hi Steven, 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. We already discussed this with Zicheng and Peter [1]. The approach we settled on was to rebuild the load weight in switching_to_fair(), so fair prepares its own state before enqueue, rather than having sched_ext maintain fair's inactive state. > --- 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; > + There is also the associated PELT state to consider here, se->avg.load_avg depends on the load weight, so updating se.load alone can leave them inconsistent when the task returns to fair. Zicheng's v4 series [2] addressed both pieces: rebuilding the weight in switching_to_fair() and recalculating load_avg before attaching the entity back to fair. Peter, Zicheng, do you remember why that series did not land upstream? Was there any open issue to address, or did the series simply fall through the cracks? Could we revisit that approach before adding the fair-state update to reweight_task_scx()? [1] https://lore.kernel.org/r/20260527112624.GT3126523@noisy.programming.kicks-ass.net [2] https://lore.kernel.org/r/20260624091648.271891-1-quzicheng@huawei.com [3] https://lore.kernel.org/r/ajvGJ4Uui745fbBA@gpd4 Thanks, -Andrea