From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010040.outbound.protection.outlook.com [52.101.56.40]) (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 BE3643921C7 for ; Sat, 11 Jul 2026 09:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.40 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783762643; cv=fail; b=R1QHrw7kNSgFp0FqNvd/YZRXkvFJX9k+2up2qvaZPRwhSDal2O/uoFwvMkb0SkjQiC6QSZGx2FW3vWyT5gzFHt1q6PNJA0WicpQLoV/4nMPQgYk3eqCs0v7GHxS7NVz+q/MFk+Wy9N0aTndNguYZDpJatzex1cBBX/d3rZXsfTk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783762643; c=relaxed/simple; bh=IMJPwEhvSziaNMaaRi61y36kUTgBbZh6OhHsLUhgZ30=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=SPC0i6eeyGvMjgH652o9t05j2h7jvvKAGM8xEpKeROguwdEFR2YsuzxPzyrTsWdZfwUCIR0D9SS7dAY3/y8YA0sEJs6WlAVO7YVtw+V2z5ApRZdLCSt3NvHeVWTm8wYgAYWNcfWt1iYMaIDs44DbkV/tCeJ+Ez1zApsokJK9R+o= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=fwa9X1GH; arc=fail smtp.client-ip=52.101.56.40 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) header.d=Nvidia.com header.i=@Nvidia.com header.b="fwa9X1GH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AoUNtiCjIo1lWicDXU6hv0wRdrlYx63wckHQ76cN34/D+8YL+Grhxg/ELG4dV1BJzH3o4hZfGall/FVelX6YaT7GRRy/zryDzHKl2vFa3fWiUFLAiWqrk1Ctb+p8rAFsc1VO/snlmjD0cdsTotlyKjB0nhFUaK0CIKg6IiKEf3oVv71giZbDIZECr4IbQUDmfwlVSvkyVjJzhuJnx+jGcFK3PxmVvrnxkHH7RWZOBRodwTBRk3E/B8jNmsVxJQ6WM5n76Po1QlPsTepprhAwegrHo3TynTcEVbcxVcBzdZQTm/4nFe17JfNV7YqqpoC7/vwq7f/wLlwthvZqGoRoAA== 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=DTvUKqKh9SJQbtImzT1zfQUD94YxBvv8kUxi5ve48uY=; b=PCIcBZt9kVoMfRXdkXmhdjOrM/V0Z4TSHPA+oU4M37o456QEsBkCDQtZxlj9vqcOHqR+SVRGEJaKbP3j1w4ID+tbPIu+PVaq7fyaRtLSdkrKv4OGocKY9KcifJe2iwClmp8mlKgxKmBHcVsyEs2YvnX7c/2kB3WeMvF9oBhPrb0K0Al14Oujgrn4aCBt0nqgCr2g7CNqZJ1JdLo3VxCzUXMgO+V8U9cMM4N8PMshArKga+P0pisPLXiSQ7z5+kqmxOrtnBg1CR/MrTkLze40B8FVO2eZyGv7ho+cEQ2mklCEiB2qRLaDWmXKHOsrSgtPK0zwkopYpbT6JETkTH5v6A== 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=DTvUKqKh9SJQbtImzT1zfQUD94YxBvv8kUxi5ve48uY=; b=fwa9X1GHBvBlfSs0v3pA8tqPP2wEp5cUAeIOlQc8X4EmBi601X6cMbCGvzzZtU6yWpZ12KDq5JYzmRdOYhCJi0ZmA24LLFuSJaNMFhqXe1z4R8YNOSK6oacwBRfswAWAPOn3y29MBgCOfqxF+bB6Gb4CmjQ0B+o6C8tO1cUUcybBV8jTL+0CbMq102mgUGZraekXikaquvv2XPfhZI+y9KdFKMaVKz3MT1crldmVjfE4wzTMSuEiHQZWYKL8YiewrPWF4OW+iPkxiqIb6kDxAXsUbOU3bHAZiDMy/Ja6tGf4CcIUGXmZEGHR11DxFOELgZek4eAY4TOzUHfPZvAIhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4827.namprd12.prod.outlook.com (2603:10b6:5:1d6::14) by SJ2PR12MB7821.namprd12.prod.outlook.com (2603:10b6:a03:4d2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.17; Sat, 11 Jul 2026 09:37:16 +0000 Received: from DM6PR12MB4827.namprd12.prod.outlook.com ([fe80::6261:3040:864b:159c]) by DM6PR12MB4827.namprd12.prod.outlook.com ([fe80::6261:3040:864b:159c%3]) with mapi id 15.21.0181.014; Sat, 11 Jul 2026 09:37:15 +0000 Date: Sat, 11 Jul 2026 11:37:06 +0200 From: Andrea Righi To: John Stultz Cc: Tejun Heo , David Vernet , Changwoo Min , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Christian Loehle , David Dai , Koba Ko , Aiqun Yu , Shuah Khan , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/10] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Message-ID: References: <20260710083913.30573-1-arighi@nvidia.com> <20260710083913.30573-3-arighi@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: MI3PEPF00004E9B.ITAP293.PROD.OUTLOOK.COM (2603:10a6:298:1::457) To DM6PR12MB4827.namprd12.prod.outlook.com (2603:10b6:5:1d6::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB4827:EE_|SJ2PR12MB7821:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c9c46b3-e72c-4e1f-d3f1-08dedf2ffd56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|23010399003|1800799024|366016|13003099007|6133799003|5023799004|4143699003|11063799006|56012099006|22082099003|18002099003|3023799007; X-Microsoft-Antispam-Message-Info: H5hLL4mZAxfuBikuhR3jBMHgvvJKlVwj7FJT0s67Mj6IG7pkCdh61RBW0PWi7VMm2BJI0AhvgcKNs2jyc4TiTRNQgTPwspVsORd/PAobQPyYnCTiPPq0Qr/4YeD+c/xbS9APU4xavKJ5mHEcbgex9wQi/tRkiOHAeyS7hPMfHcqXmLDy75YbAJbvNpogoTSVFf3I1CxNE6Duq+cO+wzNzbnN/RVtsnEXTuEMkt+zSOuu6+gmmpTUORiCsihYYipHXbV5DciRl6zFdid6ohWpcvLkdn03ixkV/c8GUE9SXQsFhqm99Xc+pZ2/m0cuFGDQ1mr9VSdkSd4vY/NZlE9F5uxoM6PDSyN21IphCraaBRfovT24NwEj5MLQiFdsnIjCy/rYwXmJH65Ph0G5IJqV3KF8rJRnJQEJ/yYUXS6DggdKIibJrC96fz6uk1knAbwstDqrSq51hD4vII/dtb2BEJLmRhhe4K0AipfcDEA8b+Hw8xdP+K8fx1YrAdiBjfg3M/54r3q7vo2NgRFBSPZ62jPkSIBT7YN1EB23/clqC/eHoLh/niE+9Lm/Sqq7ozRUrRTbgOGGiCDPctd74iITRbpbLtnxa5Mv4xbBwHmmciy9WUx9XkAoT6T3jgF14qdtV2E6EKUHQMBRQAUTi8kQOn/4T3JE1HJhoquBp3DuL4k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4827.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(23010399003)(1800799024)(366016)(13003099007)(6133799003)(5023799004)(4143699003)(11063799006)(56012099006)(22082099003)(18002099003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bVRrUlF5aGRkMFphRFFjQ1F4Nzc5YlNqbXZsT3g5RFNNU1BpbXY3dnI1TlM4?= =?utf-8?B?dnlhaWVGd2c5QW92d2x5QjNRUzZlN01UeEZjbWlBTFFpcHlIR2JNQ2s4ZXNj?= =?utf-8?B?amlna2dWL0djSU9Hb0ZIRytGcEZnZ0tpRXZPUDV2L0FWZ2Ixbm1HQkhBZVhB?= =?utf-8?B?M3BVVzNUUlVjK2JvWVN6VWR0U3g4cndsazZuYkVXVXQ5RWZ0TE9OWWJ2TlBQ?= =?utf-8?B?RWZKS2U4MWpqWWRCQUVSYkREeW4yWmhyb3NGc0EzWFpnYnprUG11UkQyS1pU?= =?utf-8?B?RVUralBLbWcrMnhobXIrMTY4TGhrd2xrOWVicVdScjNpQytOeTcwMGtvZS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SdUo1WmlpZnQxd0pWUDRXM1dFYnVsMEZFYzk2?= =?utf-8?B?WWo4VWQzWktSN2lKSExZYkcveEh2Vlcvb0kxN1lEUVltakxvRWYxMVJxUmtm?= =?utf-8?B?SHZpc2lNTWZITCtPSktKNEhrcWFLc2ZBbFRPdjRmUjc4WS90RjJteUFONjBN?= =?utf-8?B?WmNIRFBUcndYckJJMzFkMXJXVWxwb1JvaThRYlRaMWxuNnRaS3BXdz09?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c9c46b3-e72c-4e1f-d3f1-08dedf2ffd56 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4827.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2026 09:37:14.7989 (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: EhH6Jo1VWq9i43fASZtd13s5OR5aN1DorpHDYCfEuVuo6vJal/r45WWRMoACypmqs/ssBckPOzxJ88H7FERcxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7821 On Fri, Jul 10, 2026 at 02:33:55PM -0700, John Stultz wrote: > On Fri, Jul 10, 2026 at 1:39 AM Andrea Righi wrote: > > > > With proxy-exec, pick_next_task() can return a task with blocked_on set > > (a proxy donor). put_prev_set_next_task() then calls set_next_task_scx() > > on this "ghost" task even though the task only provides scheduling > > context and never actually runs. > > > > Calling ops.running() for such a donor produces a spurious running > > event. Simply suppressing ops.running() is not sufficient because the > > following put_prev_task_scx() would still invoke ops.stopping(), > > resulting in an unpaired stopping event. > > > > Introduce SCX_TASK_IS_RUNNING to track whether a task entered a real > > running transition. Set and clear the flag independently of > > ops.running() and ops.stopping(), as the callbacks are independently > > optional. Invoke ops.running() only for non-blocked tasks and invoke > > ops.stopping() only after a real running transition. This keeps the > > callbacks paired for proxy donors while preserving stopping > > notifications for schedulers which only implement ops.stopping(). > > It took me a while to understand this. > > It seems you're wanting to distinguish normal task selection and > execution (without proxy) from just task selection for proxy-donation > (where it doesn't run). > > I think what makes it confusing is that TASK_IS_RUNNING is not set for > the case when the task is running (rq->curr) as a lock-owning proxy > for a waiting donor. > > Would it maybe make it easier to follow if the flag was > TASK_BLOCKED_DONOR? And the logic was flipped a bit? > > That might more clearly cover the case you intend here without extra > edge cases that you'll have to explain (well, you're running but > you're not the donor and running... ). I agree that SCX_TASK_IS_RUNNING is confusing, because it doesn't describe really well the rq->curr/physical execution. What the flag records is whether a task entered the sched_ext running/stopping state. With proxy-exec, the selected scheduling context (rq->donor) and the physical execution context (rq->curr) can differ, which creates two relevant cases: 1. a blocked EXT donor goes through set_next_task_scx() even though its mutex owner executes instead. We must suppress ops.running() for the donor and remember that it did not enter the running state, so that a later ops.stopping() is also suppressed, 2. an EXT mutex owner can execute as rq->curr for a non-EXT donor. The owner is not a blocked donor, but it did not go through set_next_task_scx(), so it must not receive ops.stopping() if it is subsequently dequeued. So, I don't think changing the flag to SCX_TASK_BLOCKED_DONOR captures the required state. SCX_TASK_IS_RUNNING handles both cases by recording whether the task entered the sched_ext ops.running/stopping() state, independently of whether either callback is implemented. How about renaming it to SCX_TASK_IN_RUNNING_TRANSITION and explicitly documenting that this is the sched_ext callback state, not physical rq->curr execution? Something like: /* entered the SCX ops.running/stopping() state, not necessarily rq->curr */ SCX_TASK_IN_RUNNING_TRANSITION = 1 << 6, Any other ideas for a more clear name? Thanks, -Andrea