From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012056.outbound.protection.outlook.com [52.101.48.56]) (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 58F3F3B0ADB for ; Wed, 26 Aug 2026 06:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.56 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787725969; cv=fail; b=PKrhTcDU9IXvGjtdXJ8WCmAM61zQU7wrGpHW9lrd52rYfw0QZ8WkJy+EQBm1Viegq0k0IJ1ow5SdvfXQX7bE/Dv0jL5GUVUOM+LzTJ8gUUzGcLBCqg6RN4WlnzZWPD9x6SMRnLm1snnNDWEZa+0/rJBTHkeKYBpV8gxKLLRK0+I= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787725969; c=relaxed/simple; bh=LsLmrIRszRIUzjH5DAvm3gWbgiWLs5UqzAMQxLqnt70=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IQF0mUBKX+jdABM9k5iJO99hvRc6kBnF+KBwP3wtAtA82/rXna5pSk2D5LAxNpcE437jkxKO/3QE/Dn0qW8ilZj0gsegVfxK0P//vu2XXDBU3pfSWnluiQtyN9fR+gLIi+hJoLgfEyqwHIziSXDpGHuOhxpDzqoJS7WzcGA4d5g= 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=G/KCgWS3; arc=fail smtp.client-ip=52.101.48.56 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="G/KCgWS3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WE9px8nFEwMwaX0rNqnV8aq/kLU6yrhupWdh/1GVw5YNL6IiTuG3pVnEBPbWhZY9KnsFDE69ci6NDhe3qhA4nAJ2iX3zk7Qc/6vIePsbOjlnGFNnI+bk6XupfP+eOoFXzhG7UzdaWU5aQa2qNnIkCVS0fzzmGjZf3GdC68tW8L5LLFElDBldBn0SWmPFK0Y15P+5fpXshM/2XWNbPDsmiA+V1+HNX1NWqzSjAI1me2/yNIxpVS+yqG0ctHOJ9//aX3nw7TljbMmexZcl0iEqhKnKUupwo9Ds12vJeEcMFzEtnQqxknlPAX/f/jOJGI+7SZkfFtKL2H437a5HjPLzvg== 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=P0yMohpyRdd0l6l1x+hbhb4zJ0nWOSacRiCkL0tnmUY=; b=NmjzzKAfNVjuTabNL0I5Vw9LyXejce2hRqiTEM/GUd4iuVJaaP+2OOBRnduZZQnfxQaiooTCpJA6+sS4Vb4fA9yKhCbrUToxP/qfdss3XjS+CIwM5MAWPUgx4vRNKbz30mGiW+fhPkGxwonRcPIVkvOBMRncMgMNBTQqJOu1GZKUI6y3p3+7pvkI9QaoNBe2bTnytn0TWwiTY+YpmDHDrdyWHqh79lYsH+dF2omqnOd8WCwklfsH1tubmVZjXWJ8CrWMzs90ZBsdiG33EHB37krGPTFgPLa9xM5i+8ygZd5HK/kDC03Zd4Rsl5cfYEMM9jnguqYPIpheb+bcJc16DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 149.199.90.133) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=fail (p=quarantine sp=quarantine pct=100) action=quarantine 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=P0yMohpyRdd0l6l1x+hbhb4zJ0nWOSacRiCkL0tnmUY=; b=G/KCgWS3sYDlrUaENH0psXo8vjFQdlKdwJPijUQ04s9li3cJipeiqnPwfpgo2bHo0Y6xtMpjDMGCavt6BtUFzHrrE+Bb07VFZ7J/U6AWY5AhXIXtJtHpEm8we12fWtli5EvIfKuc1bqNefU9UpYAPRvX7Srbcnf+oiVldcYd79I= Received: from DS1PR05CA0026.namprd05.prod.outlook.com (2603:10b6:8:23f::8) by MN2PR12MB4159.namprd12.prod.outlook.com (2603:10b6:208:1da::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.7; Wed, 26 Aug 2026 06:32:44 +0000 Received: from CY4PEPF0000E9D9.namprd05.prod.outlook.com (2603:10b6:8:23f:cafe::7c) by DS1PR05CA0026.outlook.office365.com (2603:10b6:8:23f::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.382.5 via Frontend Transport; Wed, 26 Aug 2026 06:32:44 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 149.199.90.133) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=fail action=quarantine header.from=amd.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning amd.com discourages use of 149.199.90.133 as permitted sender) Received: from satlexmb07.amd.com (149.199.90.133) by CY4PEPF0000E9D9.mail.protection.outlook.com (10.167.241.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.3 via Frontend Transport; Wed, 26 Aug 2026 06:32:44 +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.45; Wed, 26 Aug 2026 01:32:38 -0500 From: K Prateek Nayak To: John Stultz , Suleiman Souhlal , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot , Will Deacon , Boqun Feng , Andrea Righi , CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Waiman Long , K Prateek Nayak Subject: [RFC PATCH 09/16] sched/core: Track CPU where the task was blocked on Date: Wed, 26 Aug 2026 06:28:53 +0000 Message-ID: <20260826062901.2137-10-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826062901.2137-1-kprateek.nayak@amd.com> References: <20260826062901.2137-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: 8bit Content-Type: text/plain 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: CY4PEPF0000E9D9:EE_|MN2PR12MB4159:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f786194-2edf-426e-cd86-08df033bd62f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|7416014|1800799024|23010399003|82310400026|921020|10067099003|56012099006|11063799006|5023799004|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: DtRK5GagehO2tjZ5S24r08G6N42QQMthhJJerfV/ExnRT7MyGs5kZfLxyHUHRG5NN3JL6GTynWjGrN6cHBdOlUYjbGe5tY+dw2C1XdtSaGIJG4FY6vibgCnUWiprN9PGopdUDnXY5rRWx3oxaWGLV4aMQQ/d6RFBdsS94QuNfsMMw7L933JVyouaYnSpHhT42Bl7qbOq0J+KlYRukXH+ocjL70VqWuEJXRiG7ivOUqs7gxYd3YuUh3pgAn1L6Ii0Djlso/QJ44bP3ImS5pibO6cq5SsvESTYg3dXFb+GVp6svSZfP02B4FQqXaxO0s4xf3Tx/+s7Cj2hocKfLU0ioty08+aXZvC/5Z6KXWvKsKeop2Ol8vg18PA86Fi4pjwwjY44ultOADtonUC0NeDcgvWwyJG0Huvyj/n0bRA4nOo+fZLUOv2TyYVhMfmVjESLq+pyseF+NfkqqeWFlIGamQCensPmIKjhANApzSWkLH1bc65g8gK9/GlGzU6dXN5k6UytZmb79crbHSNFVQ+S3KAe4ZTQKN1/g4F3Is+jg8Ag+BIqJ2hjrQormAj6rpNX8C3S8zThCrcKVbpbEmjdrzBYVn9gsmM1R+I3qxKt2KkIv8Dc9CWuvEP3DagVbYpNQJadi2C6kAuvEtITkjwvw2drVOJfHuynpC0pwHDH5b8538UDG73/Eb+S/H7pi9WbFChq9TJTlP0h6Ow+LQYQKhb+dghdl733sD/pjtX4VGsj5RUnggTHxX8Kz7+nOud5 X-Forefront-Antispam-Report: CIP:149.199.90.133;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:unknown-90-133.xilinx.com;CAT:NONE;SFS:(13230040)(36860700016)(376014)(7416014)(1800799024)(23010399003)(82310400026)(921020)(10067099003)(56012099006)(11063799006)(5023799004)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w/2PRdsv/G6J5+FLNG7qHCGs0MfIbRY0zUB6NoxIc8WHX4Z1iQ98bhHo4jmbY50l27ThUOvMjXqNZUYoT44ztMvga+D+tKijYpFTZI/N91VrX5AWLg/J1aAHuPJepZ0CBCJCh5nNdDRHYNcg8BOPjQMXDj6ENiONHwSYW8Dgqjs8XrBwY3p4sq/V/viRAUr0fL/9SasKib+EEgaTHGaTS9fA5VZlPo8Lcug5Yn7ccAmpBtgn1hvqIJzXaHqK/htk5J5KlWymJ8zS5f1ykp90lPWIWKkioPKnGrxn6johe8be7m07qgfx7n+lTEzZEASdGO5US37TB8ceLne/d2p6KTgTe/xrCKno9FsHBMe2c51HOFl9uWgKMq+G+TJN4CPHO48iNU4mHuv8aaCNcWf4q5QRii4uUd00ITF0p4CtDLTIbqBiIt/HPs7VrS1PtDdb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2026 06:32:44.0427 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f786194-2edf-426e-cd86-08df033bd62f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[149.199.90.133];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4159 Track the CPU where task was blocked on when running with sched_proxy_exec(). This is used to re-direct the activation of blocked donors queued on the blocked_head via the said CPU in the activation slowpath that will be added in the subsequent patches. p->wake_cpu or task_cpu() is not sufficient for this purpose since p->wake_cpu is not stable when !task_on_rq_queued() and there is a window between set_task_cpu() and activet_blocked_task() in the wakeup path that needs to be plugged in. Signed-off-by: K Prateek Nayak --- include/linux/sched.h | 1 + kernel/sched/core.c | 16 ++++++++++++++++ kernel/sched/sched.h | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index bf0f4b6be7c4..2360fdb1ce3f 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1255,6 +1255,7 @@ struct task_struct { struct list_head blocked_head; /* tasks blocked on this task */ struct list_head blocked_node; /* our entry on someone elses blocked_head */ struct task_struct *sleeping_owner; /* task our blocked_node is enqueued on */ + int blocked_cpu; /* CPU where task was blocked. */ #endif /* diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d635f5452a1b..b5cc5612a12c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3773,6 +3773,22 @@ static inline void proxy_reset_donor(struct rq *rq) resched_curr(rq); } +void __proxy_block_task(struct task_struct *p) +{ + if (!sched_proxy_exec()) + return; + + /* + * This is the CPU where the __active_blocked_donor() slowpath will + * resume activation of blocked donors queued on this task. + * + * This exists to cover the race between set_task_cpu() changing the + * task_cpu() before task is transitioned to TASK_ON_RQ_QUEUED in + * activate_blocked_task(). + */ + WRITE_ONCE(p->blocked_cpu, task_cpu(p)); +} + /* * Checks to see if task p has been proxy-migrated to another rq * and needs to be returned. If so, we deactivate the task here diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 56d9c09c485e..0d90506c34f1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1445,11 +1445,15 @@ static inline void rq_set_donor(struct rq *rq, struct task_struct *t) { rcu_assign_pointer(rq->donor, t); } + +void __proxy_block_task(struct task_struct *p); #else static inline void rq_set_donor(struct rq *rq, struct task_struct *t) { /* Do nothing */ } + +static inline void __proxy_block_task(struct task_struct *p) {} #endif #ifdef CONFIG_SCHED_CORE @@ -3039,6 +3043,8 @@ static inline void __block_task(struct rq *rq, struct task_struct *p) delayacct_blkio_start(); } + __proxy_block_task(p); + ASSERT_EXCLUSIVE_WRITER(p->on_rq); /* -- 2.34.1