From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010007.outbound.protection.outlook.com [52.101.193.7]) (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 43762263C8A for ; Fri, 14 Nov 2025 07:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.7 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763105597; cv=fail; b=JZqsG+HQM1X2oXDsNYaqHISaNtPhId1VVRj7jOYbX1OESamSzWtYLT0obOZMvuMnkbhGL7BwyaqmPiQm6DIVpHuDnJBx0ZJu6xyVbleFhZ4UJ34T/4E2Gt65HRh8LpYYEQMUqOPtgYroe0h+Buo+0V5f5g3h+0346vkON+0AOgY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763105597; c=relaxed/simple; bh=qU3iTeVzF5SGZkBmJQW+ucQXxqIxB2lemJuehZyfXKM=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=WHChmVVjjYfnDj4sXwwPii0QdA9zskZbrll1/sVR7tt7EVZ6SgJ/ta43ahFnWxTFFJ+CZpPiVeMJAevYGrHQntYLEuAqQLmO7eBuMRdqyABGMt0TTjhBo9PUdIwLuCe/mzL72agvi7h8kR1P3QoAgai5z14BMexu7v9tGBojZeQ= 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=mqY1MdHd; arc=fail smtp.client-ip=52.101.193.7 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="mqY1MdHd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z16EDTI7w2HJs2O899KIqzil/y/LjEtagmV9+f5m+mvaySZH35oZj+q2AG3zPed9hiCWLI/3SSr2URI+9AETJIQIpcbaIs6N0uQTjdI+Co0EodLgQIuI7D2XgMlLAC4GVobXFHSrUt8hQa9EbaFVidoJlqRKIkLXWAcVx/mAbE2sQh35LncNYB8QKD8lnmuO1Rdj2v5UNUhGKaDE1iZ7lKNkLlYYFny2a8Ui7FMFwoYWfI3G7Eoj4uBkZPdYbd9BWS0uQGuo1TRV6AMWTIX6gSjV7+qVZEZJ/J57y3X35GrJI5xIjLTuSiYVc0b93XbYlCMgLbBPsNw4TgCaWDa7tg== 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=ywvAkZTAvTEDCfOJycQ3YpKplN8kk+ufvtbFoeqloCs=; b=ZbdTHQBCigxALQEP2K/En92ITtL7X5bmcSFopq38v+4JXyI5E+/0g9/0Zt6xI3Ju396TVGio0lV9Uz/uI6C+sSTZgR54yimcYZff1Q6irDMNtJssz46Aocq9SS8caCWLJXaWw+SrzdrMBoHTBVO/0laedVPKeBGeker2dX/jxP41xiPCixON/anSKtwqKcsCuJ99T1LBvWb7k7MKxCKqDLnrDG6/f2VhHOwqg8v3jN3kRQgOyQ8q48oivrdP/ia5dWj6nsuiHmSt5uJ6tajQKx+7hOax1RAu686fwousgzmefOZ7E547trh5CJCCxUPo62Eer/C7iABu0fmpHVIbxA== 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=ywvAkZTAvTEDCfOJycQ3YpKplN8kk+ufvtbFoeqloCs=; b=mqY1MdHdF6tE5cuJN26mbbl6OXAHgLq+bqo8WQMYdbrs4H3s3h+SLttzY0+WRGavg/6wcO1wqh35W+hiXcrtY3VVpdBNNkdrmL5+NPfbArYQUe93zu3bKIP4Aa9fRk/zMBHPCzEkPSa1GQQVTH+kPT969g2gbUCINmYyyCGtE87WEj8hWNbDXT6ACxlzVEHaS/HVLr9raNa3kaUpmaY9AffDhMu01YyU44H4OvuzcWh1I0bewTiyVqX96Bj0fw9l6jWhtIBbcRr8Tz89VeSHhJAbzg+9IPx24lHu9WieCcgb+0EMen9PhuCr4dpW5kOgsvFiA9NK8X05wkyKfiDLmg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS2PR12MB9615.namprd12.prod.outlook.com (2603:10b6:8:275::18) by PH7PR12MB6635.namprd12.prod.outlook.com (2603:10b6:510:210::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9320.15; Fri, 14 Nov 2025 07:33:13 +0000 Received: from DS2PR12MB9615.namprd12.prod.outlook.com ([fe80::ae0:e4b5:9c68:2ea4]) by DS2PR12MB9615.namprd12.prod.outlook.com ([fe80::ae0:e4b5:9c68:2ea4%5]) with mapi id 15.20.9320.018; Fri, 14 Nov 2025 07:33:12 +0000 Date: Fri, 14 Nov 2025 08:32:21 +0100 From: Andrea Righi To: Tejun Heo Cc: Doug Anderson , David Vernet , Changwoo Min , Dan Schatzberg , Emil Tsalapatis , sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH sched_ext/for-6.19] sched_ext: Pass locked CPU parameter to scx_hardlockup() and add docs Message-ID: References: <20251111191816.862797-1-tj@kernel.org> <20251111191816.862797-10-tj@kernel.org> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: ZR2P278CA0081.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:65::17) To LV8PR12MB9620.namprd12.prod.outlook.com (2603:10b6:408:2a1::19) 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: DS2PR12MB9615:EE_|PH7PR12MB6635:EE_ X-MS-Office365-Filtering-Correlation-Id: f142679e-7e25-479d-7e22-08de234ffff4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xNBK8fidZ54oRVFe+PTrjSGL0gXFli4f5cRqLv+/MIZXTTFtq2T3+eCH8x2W?= =?us-ascii?Q?+fQ2Gg2rjWqUBfAcKlNkcAdUk4rYHDv9Usn8IGnPq61L8+GvgGFb6/uOHVng?= =?us-ascii?Q?HEoqv5LOdhsQUDtL8pnJn8oM3VXUfhRhF5UWJO9KE3TCgD5FXBhGVeBXfzUQ?= =?us-ascii?Q?lkGrFsLep7kDMUVzGM2XpoR6QlJfGUfMYAAv/C4nMyz1gd6MXbsUTbb8Kk5s?= =?us-ascii?Q?H6C/PRNXminFqT9Xy8E638T2CDJyBmUB4FFQgLluf/vPUjzEnFhpZ0DhcHjv?= =?us-ascii?Q?6PjF95sIElfEbB1xboQffl/zRqWADpizcIF2Y7vKPyP9HPyfIuZXbsxePju2?= =?us-ascii?Q?pOXase0uhbKNmpwx0fxD+7B0ldGt49gYrjS9UyYe7JaLokEcpS9SW3CUUBMX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P/ZuHBmT6+twwXWyNdYRd4fexh+LbXlBSw?= =?us-ascii?Q?j5Sc3npTJwyhRqQpUbJhmE9GmKBifCeXs5jipfIMl16hCXbUBYYiquZlMU5/?= =?us-ascii?Q?kSKKBN90JvWR01bXVQcbKpx4K1JTvwn6HfW2bLziZgnWRF6/e9IxKWBM8ZB0?= =?us-ascii?Q?cBeyDq0XM9Bb23t+ojJDTTnITfvG4BkX?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS2PR12MB9615.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(7053199007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?P5I2WYWp+JpPPasgzgkcB7WA5bsxv26C/Y4q8aSu6baq0hOY1XX4zjjnfQr5?= =?us-ascii?Q?eEwRVchwa4ssqzPTKL1lGF016N1aJn+FG/ht+hsHA8N9VEvKswZjwWkgfG7F?= =?us-ascii?Q?QwDfJaGerPGgl6da9Dx8rGZHWGUpL3woqPsBEZbTQsAf1F7nIPeyCw1dXZjm?= =?us-ascii?Q?N1ArYmECgLq7ZE+xSQpObdFuk/vx/SypkKE86klXK68PacMPe1Kt1TDsVtne?= =?us-ascii?Q?jMNJWVIIuv5YLLnJ/fnSFgdheExqxbkkxjTkw/Gzogu955Fy8TUeTha/dLwa?= =?us-ascii?Q?+8BxyMUwuaWGY6YIbm8xqogNu73bDLBY0Us+K/HJ/qno8UwGDZuNPAeytc5V?= =?us-ascii?Q?Nbxi8C5JUQYDemLtnuEnp+ckLoLZ0mwTLTagvLDPiz1ubXLNDAGi1C4zQvNM?= =?us-ascii?Q?lGtmQzAJu7fjk9Ajd7jedXWhEL/DVr8uOM9QmrJae0hFN13ITnkY22oPdkAf?= =?us-ascii?Q?hU3C5rdq5swcnlUMenkqWmsySZq3T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eqmmS9pI5B7z8qf8Uo7Yho9RKRkQY27tfXR9+KhY7V7Kib54COE2b9eZyvxG?= =?us-ascii?Q?18F3d+8Tdndqg61sloYSXL+FafQfEuY2S+QxzoaYZMDSwbQS6hqHEOBgAGt8?= =?us-ascii?Q?QyD79ov5mbBVS8ul+P50ZuwRuX8xa7fkCPaVDo+FrmlMKzG5TEu1e5weMi+2?= =?us-ascii?Q?KJSQbiol3Fq2loD8GKUQcw0iwAim7gZ+QDmRm4H7?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f142679e-7e25-479d-7e22-08de234ffff4 X-MS-Exchange-CrossTenant-AuthSource: LV8PR12MB9620.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2025 07:33:12.7386 (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: BsyOHLdgmR6Q86aveRgpiGKrH1uL41LN9Ex4wKlkJ7Q9t4w216u0+aPpkRZy4MslyK/Ebrst/GoZ4yZ291ly3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6635 On Thu, Nov 13, 2025 at 03:33:41PM -1000, Tejun Heo wrote: > With the buddy lockup detector, smp_processor_id() returns the detecting CPU, > not the locked CPU, making scx_hardlockup()'s printouts confusing. Pass the > locked CPU number from watchdog_hardlockup_check() as a parameter instead. > > Also add kerneldoc comments to handle_lockup(), scx_hardlockup(), and > scx_rcu_cpu_stall() documenting their return value semantics. > > Suggested-by: Doug Anderson > Signed-off-by: Tejun Heo Makes sense. Acked-by: Andrea Righi Thanks, -Andrea > --- > include/linux/sched/ext.h | 4 ++-- > kernel/sched/ext.c | 25 ++++++++++++++++++++++--- > kernel/watchdog.c | 2 +- > 3 files changed, 25 insertions(+), 6 deletions(-) > > diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h > index 70ee5c28a74d..bcb962d5ee7d 100644 > --- a/include/linux/sched/ext.h > +++ b/include/linux/sched/ext.h > @@ -230,7 +230,7 @@ struct sched_ext_entity { > void sched_ext_dead(struct task_struct *p); > void print_scx_info(const char *log_lvl, struct task_struct *p); > void scx_softlockup(u32 dur_s); > -bool scx_hardlockup(void); > +bool scx_hardlockup(int cpu); > bool scx_rcu_cpu_stall(void); > > #else /* !CONFIG_SCHED_CLASS_EXT */ > @@ -238,7 +238,7 @@ bool scx_rcu_cpu_stall(void); > static inline void sched_ext_dead(struct task_struct *p) {} > static inline void print_scx_info(const char *log_lvl, struct task_struct *p) {} > static inline void scx_softlockup(u32 dur_s) {} > -static inline bool scx_hardlockup(void) { return false; } > +static inline bool scx_hardlockup(int cpu) { return false; } > static inline bool scx_rcu_cpu_stall(void) { return false; } > > #endif /* CONFIG_SCHED_CLASS_EXT */ > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index 8a3b8f64a06b..918573f3f088 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -3687,6 +3687,17 @@ bool scx_allow_ttwu_queue(const struct task_struct *p) > return false; > } > > +/** > + * handle_lockup - sched_ext common lockup handler > + * @fmt: format string > + * > + * Called on system stall or lockup condition and initiates abort of sched_ext > + * if enabled, which may resolve the reported lockup. > + * > + * Returns %true if sched_ext is enabled and abort was initiated, which may > + * resolve the lockup. %false if sched_ext is not enabled or abort was already > + * initiated by someone else. > + */ > static __printf(1, 2) bool handle_lockup(const char *fmt, ...) > { > struct scx_sched *sch; > @@ -3718,6 +3729,10 @@ static __printf(1, 2) bool handle_lockup(const char *fmt, ...) > * that may not be caused by the current BPF scheduler, try kicking out the > * current scheduler in an attempt to recover the system to a good state before > * issuing panics. > + * > + * Returns %true if sched_ext is enabled and abort was initiated, which may > + * resolve the reported RCU stall. %false if sched_ext is not enabled or someone > + * else already initiated abort. > */ > bool scx_rcu_cpu_stall(void) > { > @@ -3750,14 +3765,18 @@ void scx_softlockup(u32 dur_s) > * numerous affinitized tasks in a single queue and directing all CPUs at it. > * Try kicking out the current scheduler in an attempt to recover the system to > * a good state before taking more drastic actions. > + * > + * Returns %true if sched_ext is enabled and abort was initiated, which may > + * resolve the reported hardlockdup. %false if sched_ext is not enabled or > + * someone else already initiated abort. > */ > -bool scx_hardlockup(void) > +bool scx_hardlockup(int cpu) > { > - if (!handle_lockup("hard lockup - CPU %d", smp_processor_id())) > + if (!handle_lockup("hard lockup - CPU %d", cpu)) > return false; > > printk_deferred(KERN_ERR "sched_ext: Hard lockup - CPU %d, disabling BPF scheduler\n", > - smp_processor_id()); > + cpu); > return true; > } > > diff --git a/kernel/watchdog.c b/kernel/watchdog.c > index 8dfac4a8f587..873020a2a581 100644 > --- a/kernel/watchdog.c > +++ b/kernel/watchdog.c > @@ -203,7 +203,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) > * only once when sched_ext is enabled and will immediately > * abort the BPF scheduler and print out a warning message. > */ > - if (scx_hardlockup()) > + if (scx_hardlockup(cpu)) > return; > > /* Only print hardlockups once. */