From nobody Tue Dec 2 03:00:11 2025 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013067.outbound.protection.outlook.com [40.107.201.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E543E33DECC for ; Mon, 17 Nov 2025 18:57:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763405865; cv=fail; b=iFZa5Z2HSwR8XpxLA69jonqHj0ETQljTnjKiVpkw+YBwvn9a+SY8vnMsU6JSf3O7eISPFN+neVSYnGIyPxQJw4HADZDn7y/IGm5xdGcWCoJesfGfTe4I3iyiCmxhSDqjjbdzNIv/NJuT/28E9ibdC/YYVOis80h3BH3A+hWwEZY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763405865; c=relaxed/simple; bh=evq3ESIgItipZMPf8zn1vTgfjGZl9cOcrg9/dIjnQ74=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lp4vk5PjfoffWV0eck3LH0bIQOtAdwjAK3ERD20PkewwTt5GZfMBsMthGxTpLzRRKFXDi7z5O61Ja7K7YNMKuvODIrdGUOUuWoOud+3/eJD7ApXNdwOTKXZmuXOhWPKaZUHIxgCeBXqi3BmxdylYWTeYp67IVPJh4bI7z2YddOY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=gsfufuK9; arc=fail smtp.client-ip=40.107.201.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gsfufuK9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X1mmfvW1xGozEhoe0GOkZsg6334isHjKkxswZOtum8Ch7UwnvClSJRoIJJ9INIEonXu+QmnumiCy4ctcg0BVeZbgXncR4eM6SaWhn/oevd3RFNH/+pCoHBEjiSOG3EoJ/uaZSTbx+8XL0md78GDG/hLkZDE0ZGyHRcMkYnm9rupjC2mVzgBtM0PAiZacaju7iQCY9V6kc7stJZsPOhF2t1Bnr8eOzdMjJJI0nykwVwVVfbrQKe8MJyAGvb6FMTNMZK0h8QQyLbdCQXxosFK7zhj+p4fMpyhNJLu/Dp7vEHLT92XhTn9p3Hdct+bVOdHUdqs5m8mAzQwXnDryrs7vRA== 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=E4dDDMBxGJU6p7ih3h0hnTtR1ltg7tY3YCJmskw0Ku0=; b=qSj4T6mvuqu8M4SNjO8FEo4m+CbZVBFLBQjuIro0CK4YFXpaFX44A3F7y/TyOqWfo8eofFVgueZHWvqiNqf16oJ4qy6oCUWEHEdoQgp9NRzgVEVxeBnNzNj4OZlkYquZLdAN75gga8dSjUfCTi5vX+3DjJ6fR2B/Zqp4PenhqGsSIQi4o1V7jaYM/qyvebFHK5C7q9bu/mneBG5n1GATR6CXLtf4s5EqoHZPffDIslkf8Pxc22mwfAd31h9ZQjI5VqW5Dsc3Ou+Hg5x87BOU+Qus+QNZtgDPFt10pNlHNWWCybMDZvHiJtyLZMNAh+pAB7PST5perlUW+shqGOrLNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E4dDDMBxGJU6p7ih3h0hnTtR1ltg7tY3YCJmskw0Ku0=; b=gsfufuK9nhvcupde+n7CBSTrd3btVXDN7jK77b/1c9ml9xthVefb0xkMS9pQyPDkLgcGsb2T1PAX+zL6ngA1CznzvGmEukCLxf2Sknd6MJy+W3uiwmlU6xbdU0pi0lAbUl9QRsq/yUZjY4MyLHp50dXFoYvPUPzRgdj/AlDhhag= Received: from SJ0PR05CA0195.namprd05.prod.outlook.com (2603:10b6:a03:330::20) by DS0PR12MB8564.namprd12.prod.outlook.com (2603:10b6:8:167::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.17; Mon, 17 Nov 2025 18:57:37 +0000 Received: from CO1PEPF000066E8.namprd05.prod.outlook.com (2603:10b6:a03:330:cafe::7f) by SJ0PR05CA0195.outlook.office365.com (2603:10b6:a03:330::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9343.10 via Frontend Transport; Mon, 17 Nov 2025 18:57:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CO1PEPF000066E8.mail.protection.outlook.com (10.167.249.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9343.9 via Frontend Transport; Mon, 17 Nov 2025 18:57:37 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Mon, 17 Nov 2025 10:57:32 -0800 From: K Prateek Nayak To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , John Stultz , "Johannes Weiner" , Suren Baghdasaryan , CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak Subject: [RFC PATCH 5/5] sched/psi: Fix PSI signals of blocked tasks retained for proxy Date: Mon, 17 Nov 2025 18:55:50 +0000 Message-ID: <20251117185550.365156-6-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251117185550.365156-1-kprateek.nayak@amd.com> References: <20251117185550.365156-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066E8:EE_|DS0PR12MB8564:EE_ X-MS-Office365-Filtering-Correlation-Id: aa250f29-7c00-4078-dbfd-08de260b2cff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vsaj0ypz3qVF9b/XXLRuGJCyQ0tiwDyTvbJMCzfITjWpFs6nONsN9Bw4Em8I?= =?us-ascii?Q?lTlMGxJhc58aeZcnAm0Z+kfXn3NQraDRaaH+XzA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Tk+vMHx7/XiEVAVFLWtP1ltLbZOXude4sFTvIhxSsuYUlAsIu7F?= =?us-ascii?Q?dG/Eq5MPc75jlFKIyqZL8/jP6aKQtHtd69y1cXbSZKNowvjb655g6EWzmKg4?= =?us-ascii?Q?wha9CWCcO95QCq+y0YZSm50iP21bg2Ez4k1DIId5H6KYTodFwSkvPBthrG0w?= =?us-ascii?Q?XOOv8ri++TwsS1bjIDK4wMO18fm/qUUDmxdWuGOEBzN/Ket1yAsux7xXHcZ+?= =?us-ascii?Q?bP1VANj5weAC5emad49TPvj9dcxSY2eDcrszrgvHhijXpt9ivaRHhWOBPxmM?= =?us-ascii?Q?ZjaI4u9vMuMgK7zJ+ZWvdi2aZkUJCHxBDvzgUE2q3uLQ7A1Et0lZPLT0q4hm?= =?us-ascii?Q?C1gNPZvNHKWarvGEGmf8PxjaS2EiOnRhi5T79PeKqx55dO/ctKegnRzxG3OU?= =?us-ascii?Q?chd6DC8KLs9adfcL9td4H9zqVC8zsRC9RH8Vox7ZYAfbT1rCe3aCk7pdjHBb?= =?us-ascii?Q?M0ec5vLk9PU6JhNCNHSUXUWAmGY6eKntW5X39SCSTAt3mEPbfw2dm+pjceaI?= =?us-ascii?Q?5qgKzF+SVccKtu8eS6tz2jivYLbkDCiZrc0X7xjMh8KUnTGLlxwZE26Umg10?= =?us-ascii?Q?qZHw2WNxg429UnP+lgE=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2025 18:57:37.3315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aa250f29-7c00-4078-dbfd-08de260b2cff X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066E8.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8564 Content-Type: text/plain; charset="utf-8" Booting a machine with CONFIG_SCHED_PROXY_EXEC=3Dy leads to a PSI warning similar to following early into the boot: psi: inconsistent task state! task=3D... cpu=3D... psi_flags=3D4 clear= =3D0 set=3D4 Investigating the set of events that led to warning indicated that psi_sched_switch() never dequeued the signals for a blocked task since it was retained on the runqueue as a potential donor but the psi_enqueue() that follows the wakeup tries to re-enqueue these signals for the blocked tasks thus leading to the inconsistent state warning. When fixing PSI state corruption for delayed dequeue in commit c6508124193d ("sched/psi: Fix mistaken CPU pressure indication after corrupted task state bug"), Johannes mentioned that delayed tasks are in-fact blocked and the PSI signals should treat them as such in [1]. With proxy execution, the same argument holds true for blocked tasks that are kept around to donate the vruntime context - the tasks are essentially blocked and their PSI signals should be treated as such until they are woken up again. Treat is_proxy_task() as blocked for psi_sched_switch() and call psi_enqueue(ENQUEUE_WAKEUP) when the "sched_proxy" signal is cleared. For all the transitions in-between, treat the task similar to a delayed task and just move the block signals on migration of blocked donor. Fixes: be41bde4c3a8 ("sched: Add an initial sketch of the find_proxy_task()= function") Link: https://lore.kernel.org/all/20241010130316.GA181795@cmpxchg.org/ [1] Signed-off-by: K Prateek Nayak --- kernel/sched/core.c | 9 +++++++-- kernel/sched/stats.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d6265f38e93a..765365b81b12 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3696,8 +3696,12 @@ static int ttwu_runnable(struct task_struct *p, int = wake_flags) rq =3D __task_rq_lock(p, &rf); if (task_on_rq_queued(p)) { update_rq_clock(rq); - if (is_proxy_task(p)) + if (is_proxy_task(p)) { clear_task_proxy(p); + /* Task was never fully blocked to be delayed. */ + WARN_ON_ONCE(p->se.sched_delayed); + psi_enqueue(p, ENQUEUE_WAKEUP); + } if (p->se.sched_delayed) enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED); if (!task_on_cpu(rq, p)) { @@ -6903,7 +6907,8 @@ static void __sched notrace __schedule(int sched_mode) =20 psi_account_irqtime(rq, prev, next); psi_sched_switch(prev, next, !task_on_rq_queued(prev) || - prev->se.sched_delayed); + prev->se.sched_delayed || + is_proxy_task(prev)); =20 trace_sched_switch(preempt, prev, next, prev_state); =20 diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h index 3323d773fec3..b2d7461c1ea9 100644 --- a/kernel/sched/stats.h +++ b/kernel/sched/stats.h @@ -142,7 +142,7 @@ static inline void psi_enqueue(struct task_struct *p, i= nt flags) if (task_on_cpu(task_rq(p), p)) return; =20 - if (p->se.sched_delayed) { + if (p->se.sched_delayed || is_proxy_task(p)) { /* CPU migration of "sleeping" task */ WARN_ON_ONCE(!(flags & ENQUEUE_MIGRATED)); if (p->in_memstall) --=20 2.34.1