From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011027.outbound.protection.outlook.com [52.101.57.27]) (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 5E7FA37F8B1 for ; Mon, 29 Jun 2026 17:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.27 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782754521; cv=fail; b=Ez6vO09ersv/mY9AWfUIvge4ekcIFq6zFVx/QmwwQw8FhNBV135l6H4r2m/1R8VIVNbs0bVfEyvHCBw1WafhvSswl5O3V+BoA7b0aCOeS1ZS39cZynLIUISNZSlSdYcQ3k7TUviQXROJ7sJO/maPnM98PgzoqTV4Kv3p4W+InwA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782754521; c=relaxed/simple; bh=2VrISZo2FSTS59HWOYwa0xR4a2TTbXQ01MxZvJp0S3Y=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=oHBSio6VYZCLd8KK0/3N8wpn1tsvx7z0bJFZHn5kiFD0HeMwCDiNyOmFHc8yvkpS7ASm7qSWB/KDbQdmHEp719lb+IYZ8j1ULqmRgYYFQ9f3NbCT3fNNVPg3TbL8k6YdXQNaIVUyp3cwqmk1ehdim9lCWSW0fjNCDVeMPKy1yls= 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=vyQ2rG4c; arc=fail smtp.client-ip=52.101.57.27 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="vyQ2rG4c" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bhzJd2n/TGsJiIfuBdUa+kcttu6R04HsKQ0xFBdle5sUiM/7PUMMMG/8/WN/TEoOVpguAlAJydqPvpnGNdMY9LJgoFdIgiBrzCujMer8kYuAb9BPhRRVrTXeluw5HuwOvY3OfiydKUokhzF7cX1vuxVFnxNZRh7gYMZhwo9EBWuBXGOO9lt2j4R0KYz2MtTkItEexCXe6egG9IsL8SlbIrCW+5Az5DNHkl+RmEyc+Vk3Gn21tavSSxTKI5u0jNw3rT7SPpSpu91DOGNGDNpl6IhVgujxajdkEG4MI/+J8SgpjBnt/Qo/DamgbO2VqgWgkpuqULwOOMQjkFg6A1CbWg== 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=QYsbHiQLU9GAQNc4WLTGhlKWC1d/gMm1XbQT0TQbfN0=; b=ijKKTzGRH/WbTez1KYUP3NMO8ugjuwKbR+zngFgYZaHZ2MTmowCiOFVg+6RwPm+fS7OxCFB1FAGdcbmF6lpGBXRhnm94r3kEoYkPoXkebuTnP9KoIEiCJnePizvlXcl1pqqbWlBmwKfVrTYiqV5hXrPc9S4mjglCDm2vGatFBHoyN5IQwRJrDxT8M9ZxeP/+EDVoIAJ7VqjRIpwtZDugthKKUuWEnCtaDGt4MIDgAlpiy6EMSbgD/++oXLxKkBylfcAo6cl/hsUIsQPQWzHKWTNUltnaqL5h7dTQoTiiDwiwuVjecgL7Z8pLLFKZlxgacFjWjthzj1AqB3tUuG2Cww== 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=QYsbHiQLU9GAQNc4WLTGhlKWC1d/gMm1XbQT0TQbfN0=; b=vyQ2rG4cSXy6QL57m6tyJaiIBpxrTUtl01lJcBTZXmwC6DlbmwmQ6yqJ3guCZvYLSUHA8hjBpQV5PVFqMYeEZU31V292+OrGTMiN7SYsQ9ugQQ1UL1fpjzPd44U8Z3H/aPg69i6mPYTwyjzfXvakhyXNpZ/khYmp097v+sFUUn0= Received: from BLAPR03CA0079.namprd03.prod.outlook.com (2603:10b6:208:329::24) by MN2PR12MB4472.namprd12.prod.outlook.com (2603:10b6:208:267::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.159.13; Mon, 29 Jun 2026 17:35:16 +0000 Received: from BN3PEPF0000B370.namprd21.prod.outlook.com (2603:10b6:208:329:cafe::a3) by BLAPR03CA0079.outlook.office365.com (2603:10b6:208:329::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.159.19 via Frontend Transport; Mon, 29 Jun 2026 17:35:16 +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 BN3PEPF0000B370.mail.protection.outlook.com (10.167.243.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.0 via Frontend Transport; Mon, 29 Jun 2026 17:35:16 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 29 Jun 2026 12:35:16 -0500 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Mon, 29 Jun 2026 12:35:16 -0500 Received: from [172.31.184.125] (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Mon, 29 Jun 2026 12:35:13 -0500 Message-ID: <5f47566b-88f4-458d-87a4-7794e6ba8203@amd.com> Date: Mon, 29 Jun 2026 23:05:12 +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 v2] sched: set TIF_NEED_RESCHED before calling __trace_set_need_resched() To: Gabriele Monaco , Sechang Lim , Ingo Molnar , Peter Zijlstra , "Juri Lelli" , Vincent Guittot CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , References: <20260627081657.499781-1-rhkrqnwk98@gmail.com> <6cbcc3ea742b92b6a34b5994f5498c7611beac7e.camel@redhat.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <6cbcc3ea742b92b6a34b5994f5498c7611beac7e.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B370:EE_|MN2PR12MB4472:EE_ X-MS-Office365-Filtering-Correlation-Id: 49bbbf99-3ed5-470c-10e5-08ded604c8b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|376014|7416014|36860700016|1800799024|4143699003|56012099006|11063799006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: CQ0aT5euOUBQz0qIW4BuxJnGEnnk8dZUggZT2j94gQHp7/pfbWhtMUKKlMCqYwgDmtodIV9mXj8DD2MVy/nELK4ngrM+BMw2mrRIE5aAYQKr+RhOnm4nRFpZEg9zcS/xtkbPPhC+TcVM8M79eygGJUTEmgOGXgsqseNxK0vH5dk/IkNGShAGDLzaCQHmBBIVhc2/+j6bURuURanLoxphniPi22UUM3l6fMu2ugN5bWsU2Mes4ZGwgdBSL1Qqatnf7TG15Jqr2Bf3/vOAI1GhP5RvQ3dVke1UmnTvcfzDIJ0eaZ4bzN66GD7Oj6OHJ++EP0gJMiMxuRiq42865OC7By+W0uCvtR0ObPv99lrpF87gt5XPIeJRNw5I5HUqXZdKUoAD69hhZjereHZNaLw+VQ+Wjf9P+Sptv37BYzJv0Lera7NVCyzoYYO8WieYw+Tk0vvobeIITmFvWmFFiKREvkDFE4nohQl3KPlqGb7XQxQcuycif3nFqQZmLQTGdw4aY0VYtQnQyGvrWfDZf1OVpV/iRXyVNZL5En8rIvCuG96OVLWyNnjbioyCeLnq4gPztTAkp8skkTaapRqgSlijkdXKmERCr5+1nQqpdTxvuwLPidiq6YVe0ZsDKBVZzYYVCXbztbhq6v0hNgOASn4CMoayTgLXIhxcBaXglrZ8bKTAJeoRa3MImSDHbCBtR0vMqjeooF7gM+/8GqYOlsd1Gw== 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)(23010399003)(82310400026)(376014)(7416014)(36860700016)(1800799024)(4143699003)(56012099006)(11063799006)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8uE1gyTyZ0lujv3fcczDSLGbQEMMWmRvpaaWy2o5Jw3N6OoY026Ck/tFl8kFfCq2TDwGo1JlB/99w8hXf6FH+/xNfrUHFK3wjLGdqID/0vLGDZiK5Oa/PSzu2cXVGDAcKYaVk5TvY4/FPq4PLSyNRqepQJK4QpTCK6lPGqS0p0KLYuAPH+ze0AzGl3kIU7vvoSMGPPANWXjhI6/Nzjm9YLs89D2EdSmFGV++Cjdpb8wG5O5dN06tGXPSnxZ0inWUtFfi0c7nYrf2rG+zrrlZBWRl/TyL4uLy7mAIO+2KLHdE8TDoZylGZ2/ggoOCSKtpzoGFMtmq/QHxJgv0Ese+nuKecny+LirmjQ/GEgFuDDMMeSvyllsWiS+klbFyX7KFFRJ1wwjcYN+FYNrlDPkmI5btisSPOqqlVUnVMptw/fWyNOa8BjAq1Hc6i/8IGF62 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2026 17:35:16.8226 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49bbbf99-3ed5-470c-10e5-08ded604c8b4 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: BN3PEPF0000B370.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4472 Hello Gabriele, On 6/29/2026 6:10 PM, Gabriele Monaco wrote: > On Mon, 2026-06-29 at 09:41 +0530, K Prateek Nayak wrote: >> Unrelated to changes here: This tracepoint seems to be missing from >> wake_up_idle_cpu() which modifies the ti->flags without taking the >> rq_lock. >> >> A newly enqueued timer can race with the wakeup on idle CPU and you can >> see a wakeup + sched_switch without seeing a corresponding >> trace_sched_set_need_resched_tp() for the CPU. >> >> Gabriele, is that a concern for RV? > > Thanks Prateek for pointing this out. So as I'm understanding, we are missing > the tracepoint in that path, but even after putting it, this race might cause a > sched_switch to be visible concurrently or before the corresponding need_resched > for that CPU, right? Ack but if that comment in wake_up_idle_cpu() is accurate, it is a very infrequent operation and we might be able to get away with grabbing the rq_lock and synchronizing it too. > > That's potentially an issue. > > Currently the only model really relying on the need_resched event is nrp, > validating every kernel preemption has a corresponding need_resched set. > The scenario passing through wake_up_idle_cpu() is setting the flag on a CPU > that is idle (causing __schedule(SM_IDLE)), this doesn't count as a preemption > for the model. Or am I missing something? I just saw the npr monitor and yes, the SM_IDLE path will not count as preemption and the state machine should just stay at "any_thread_running" from the "schedule_entry" edge. Sorry for the scare! > That said, we should indeed add the tracepoint to that path and probably adapt > the monitor if that's making it fail indirectly. For the npr use-case, I think the current scheme is fine since only SM_PREEMPt counts as a "schedule_entry_preempt" transition and only that can transition the state machine out of the "any_thread_running" state. -- Thanks and Regards, Prateek