From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010071.outbound.protection.outlook.com [52.101.46.71]) (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 7456A14EC73 for ; Mon, 19 Jan 2026 04:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.71 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768796039; cv=fail; b=aly6EesS4FlInkRry/qGfP/sHfvs43zBo0JDAbaFAqocRKDSxKPbwv4u9cgbcX/YfpMZKoJUsILXd0G4QRlrQmmIKgdiLYr0fopa9MKJel+eDytkNPvPQqCjLq9LSH1GuRYzUZeY0L/3IT8nCsu6LrYHx5kMj0hcTPvY1J14hgQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768796039; c=relaxed/simple; bh=tl1U/tlyl23xDQ23QLp0GCUSLecWDTznbqPn+9LROWk=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=R20dg2XumzdKPdnKvIvUNetjgV90c9Dq1SVgJ2DNyKKiYsVLNhnw+9beyH0uNhcsf/NDaV2Fo39IWLBN9XtObgHgmI4ihMcKQoI8ZKrLuu6IK+NyoPk1qz5sm7tN1gbErprKwtWp2mREUtnvjR6RjgR3EAf3g6PWNq03qxgp3Mk= 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=5VTv1HeJ; arc=fail smtp.client-ip=52.101.46.71 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="5VTv1HeJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nul+RlQhqx4qmMBa7efV7yGGeC6Dsxd4YUTOdfBYxE3ZR/K12/Sad9yt1qVXPNvBtxXd5iClg3LBxBNG3A4f8feEeXu9lBMEKe81xQ/clzt1NM5w0hP3gpZze3CiR6fPncTump4Q+p7N9LOeYpSTyKtONDV4xnGh75aJwPezY4xyOppMPNgF+Hh0rrBpXoCJSCBtUAdi2XvHwZ/aibsmCp2qlc0C794gyejGYV7PBqq0isEdqWDQpEaS6YbYr3xLTo20Q3rAi2SF+xCNXNvzkoY9huzD5eriKjtdfKdvBwhRBvTm8qsH52igcrJ/XDnQcHIdnX9yNTItj1Q4UY44OQ== 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=fJzbqo38u4sPmXEYf+lReom+gn6DWW0jh6n8v9eJS+c=; b=p/QhwU7JSBxjfZfiiWIZgnBNbUZoDW0cdyJ3P6yTp7CADddnlnfQ+baVfYAcxJSDiB1oZjCSdzPF2G0vVExzHicFYLdjM20K4VLwbfKOBlNL2s7hKZ3PBPogL8YusQtwwhRng7/DT0SivPWCRQ8/7qaZ3B6H2uIcKgDIhhdOivb3es0voWCTHxjUS4/1i3sJv6X+M7EL25JPalN+C2zQ8ChjMUX+RYYnVSc9t1NeVhNd6vxD/eixvKC6YjPRrS3b6MLP2Xx6KvqoI/7Xr+UFp5FTAkCbUYbjp+/HAZFvAuplfccTUbmOQWz2hN0xv4rNoD1ARxAzubgJA4dVGmADKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linaro.org 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=fJzbqo38u4sPmXEYf+lReom+gn6DWW0jh6n8v9eJS+c=; b=5VTv1HeJSB0HYf4eZAY9xCIOm4xSe6iuaumRamMR5mnmGz+OKu2bXnskgTOATI1yDECVtjiLAwp8noNtW1KWU3hBJD4M8U53AzYF+nt1OvIzhI/OlAb02IGsueGyJ48SvT/dOOUbziDCNpjui++mWVrbO3RgbZqjHiYnaEG5KzI= Received: from BN9P223CA0025.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::30) by MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.12; Mon, 19 Jan 2026 04:13:55 +0000 Received: from BN3PEPF0000B071.namprd04.prod.outlook.com (2603:10b6:408:10b:cafe::c6) by BN9P223CA0025.outlook.office365.com (2603:10b6:408:10b::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.11 via Frontend Transport; Mon, 19 Jan 2026 04:13:47 +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=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by BN3PEPF0000B071.mail.protection.outlook.com (10.167.243.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Mon, 19 Jan 2026 04:13:55 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.17; Sun, 18 Jan 2026 22:13:54 -0600 Received: from satlexmb08.amd.com (10.181.42.217) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 18 Jan 2026 22:13:54 -0600 Received: from [10.85.36.78] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Sun, 18 Jan 2026 22:13:50 -0600 Message-ID: <653ac450-2f00-4eb0-bb97-e40576435462@amd.com> Date: Mon, 19 Jan 2026 09:43:49 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] sched/clock: Avoid false sharing for sched_clock_irqtime To: Vincent Guittot CC: Wangyang Guo , Peter Zijlstra , Ingo Molnar , Juri Lelli , Dietmar Eggemann , "Steven Rostedt" , Ben Segall , Mel Gorman , Valentin Schneider , , Shrikanth Hegde , Benjamin Lei , Tim Chen , Tianyou Li References: <20260116023945.1849329-1-wangyang.guo@intel.com> <95f2091c-273e-4e36-b543-735748efd5fc@amd.com> <648b2b54-7432-4578-b785-030d98f6e31c@amd.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Received-SPF: None (SATLEXMB04.amd.com: kprateek.nayak@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B071:EE_|MN2PR12MB4192:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a1e636b-e4cd-4f23-0a23-08de5711294b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?czRTTXVPSjljM1lDNy96OU93YlkyNGcyeThzcUtXTU53UUZuUWJ5RWNaSFp3?= =?utf-8?B?Yy9tVGhHc3ZzUnNscnBZN0Jjb0N4MjZ2RDhyYXZQbG9jZHVjaENNQ0hrYWI3?= =?utf-8?B?aUdxWjl1YUhRa1k4cE8zMm5iZ0xFMnh1NVp6ZkpxL29pQnBKd0NYSHVLL1Na?= =?utf-8?B?M25ycFprbUlBU1JONmFncGZwTmtSZ21lVGdsQjhqaFo2Ukd4cjBWMzllekNR?= =?utf-8?B?RFU2QWlSTVRMcTNUcTRjSDE1RXliMjJhWWIrb1RHcHhDUjZtaUlHQldZNlN6?= =?utf-8?B?bnFrRU9LWE4xMUxlQ1ZBcm9YSWhISG53Z0RiWEtJN0s5dkRsMmxud1lxSHNq?= =?utf-8?B?ZVZDckhLdklGRWxTbHgrSVpVeVlNSmNpVFc5b2ZuczUyQnpDVzUzd0R5d3JD?= =?utf-8?B?SG5HTjJoYlNoU3dpUnNVQUF2RXhSOUJ0c0QrbWtFRDh2U3RLZUtNM2pKWG9t?= =?utf-8?B?ZEVTMi92MG5RZGh5alJVNDR0Q25XYytOMVVtaVNvVFFRRWRMZnBQMEtkcUFY?= =?utf-8?B?M2FNYS9QbjBRYTA5RVNZV09OUDJxOWxaV2hJMUdHc2tQSHBWQXpQWUpBd2tE?= =?utf-8?B?dWxwMlpUUzVCeHo0NldTUnk0WFpqQm94QlJWb3U0Z1hqTHZHYUpnNWJscXkr?= =?utf-8?B?V2JvaGF4dVhIL1Z6aGo1ZmVGODN0dEszZDVOSnVmaVk1dy9ySVhxK2gzTVp3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BR?= =?utf-8?B?d1N1OU51V0Z4a2g1anFTL29vbnEyNDFTUWl4THhIUnVadVdUZ0NFUHcwZy81?= =?utf-8?B?NEhYa1BYc21BNENDd1JtSEM5bHZ5ck9nQmZicGJsNHByb1VUemFPM3ZNMEF4?= =?utf-8?B?ZFZ3Tlk1Y0pkWllPa1FJUkRtSmJoWEhrb3VrclhycEhoRFJrd3pQSVZwQWxD?= =?utf-8?B?Zm5mRDRRMjBDdm5WU0NyTzlDZzh6K1dWbm1KUnAxYVFYVE9TM3R6a2JpS2hK?= =?utf-8?B?bG14YjV3MFBtc1VzbmNEaVB3TjVjUkhLaVg3UEJJTXVKSzhVQTJaY3BvU3c2?= =?utf-8?B?RjMzeHp0TGdUa3RBaHk4aVhwSWF3ejllVkRlNFRleTB5YUR6a200dU13OHVj?= =?utf-8?B?WXNhQlo5cldOSVRZREJ0dHU1UHBWTTBjdVhyU2tncUdHazlqNVp2UFh4Y2lS?= =?utf-8?B?L1BCUEZsT0VBL0hSaEppZW5hZG9JVVc4NXJ0NXFUY0llelJiMDF4NllPTk1L?= =?utf-8?B?aVp2Nit2aGNBVVgyeWJJdWR5R3YrYURoanRvS3ZaTUxMZGt4VitZQTBrMzBn?= =?utf-8?B?YnBvMTUrN0xTbVpncy9JR2RXVlRSN1BWZFBEVFpyekpFYzNXOGw2YzlpTU9M?= =?utf-8?B?VHlNWFl5OHVwVEkyQitsclgxRFV3PT0=?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2026 04:13:55.1610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a1e636b-e4cd-4f23-0a23-08de5711294b 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=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B071.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4192 Hello Vincent, On 1/16/2026 10:11 PM, Vincent Guittot wrote: >>> I think that disabling irq time accounting if it was enabled in >>> __sched_clock_work() should be good >> >> I though about this and you can have this particular case as a result >> of when TSC vs sched_clock is marked unstable: >> >> tsc_init() >> enable_sched_clock_irqtime() # irqtime accounting is enabled here >> ... >> if (unsynchronized_tsc()) # true >> mark_tsc_unstable() >> clear_sched_clock_stable() >> __sched_clock_stable_early = 0; >> ... >> if (static_key_count(&sched_clock_running.key) == 2) # Only happens at sched_clock_init_late() >> __clear_sched_clock_stable(); # Never executed >> ... >> >> # late_initcall() phase >> sched_clock_init_late() >> if (__sched_clock_stable_early) # Already false >> __set_sched_clock_stable(); # sched_clock is never marked stable >> >> # TSC unstable; irqtime_enabled() is true >> >> >> The current approach from Wangyang covers this case so the v3 should be >> good as is. > > The need of a workqueue is only for CONFIG_HAVE_UNSTABLE_SCHED_CLOCK > and I'd like to keep it there instead of making the use of a workqueue > the default behavior for disabling irq time accounting whereas it's > not needed > > So either we can use a single workqueue in unstable clock to handle > the disabling of one or both __sched_clock_stable and > sched_clock_irqtime > > or unstable clock need another workqueue for disabling sched_clock_irqtime Ack! We'll likely need a second workqueue and call it early in __clear_sched_clock_stable(). AFAICT, PA-RISC already suffers from this since it marks sched_clock_unstable() on SMP but since it uses the generic sched_clock, on a >= 1MHz processor, it enabled irqtime anyways and nothing disables it later (unlike TSC, the clocksource doesn't have a "mark_unstable" callback). If we can delay enabling the irqtime accounting until we do __set_sched_clock_stable() for CONFIG_HAVE_UNSTABLE_SCHED_CLOCK (I have no clue if this is acceptable of not), then we can move the enabling / disabling of irqtime to the same spots as when we flip __sched_clock_stable. -- Thanks and Regards, Prateek