Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp53322lqk; Fri, 8 Mar 2024 23:45:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcIVKIXPLKYMTyFlqlHA+Kc+sp6gGGbWylxK5JNO1R935FOtS82VL0/czOOSkt7cw9y9AfKudCLokxvNgAekoL9y/SJh2nYgUe1x9fcA== X-Google-Smtp-Source: AGHT+IFcJl/dhZVvLkw50ynKlzCUX4TRKxGAzpGfxq6wMkPIaVevl7Old6koC7UzmYL7R3BdLA0Z X-Received: by 2002:a05:6870:46ac:b0:221:35d6:ec1f with SMTP id a44-20020a05687046ac00b0022135d6ec1fmr1667155oap.8.1709970352523; Fri, 08 Mar 2024 23:45:52 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q131-20020a632a89000000b005dc42a836a3si1045872pgq.625.2024.03.08.23.45.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 23:45:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97798-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@nokia.com header.s=selector2 header.b=kgiZuphv; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-97798-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nokia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 286E0282089 for ; Sat, 9 Mar 2024 07:45:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 021CE3716D; Sat, 9 Mar 2024 07:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="kgiZuphv" Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2073.outbound.protection.outlook.com [40.107.8.73]) (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 BC88B2103; Sat, 9 Mar 2024 07:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.73 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709970344; cv=fail; b=u/jNxiVn9JAm4uxXQU8oxDYBxjGQ/YDx1Yfarkr/JiH6UkIrF/tekW05/+Z5gBhFajfRiPKZsMQH6OynT+Sw75bTU3MX+T6DtemUFfQ4NVyNVz5hrV2li72UalTceXeI/triMjJPyYbDu8r8hII8Ni69E9Ye1CCQm/EIBQOwPTA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709970344; c=relaxed/simple; bh=iEo63V2tkkDX2R3C2nb6NyPbm5qjMALpf74fhW6jpZQ=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=qYfmxycU6IKW2MBTqYLnDD8fh5b5rHB38O6aSEpyH4xP7FfudvRF1T9uuBxD3mbQ2C/UsFczh8xgJB59gcxU/BFkKrURcDj8eQa5gdyBGbG3I2/Fmt+Hwa5nXZ/0DkhVxEs5BwWE55mPUGBjSyp0kjOhX0vU5GfFMj/4oPp8b7o= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=kgiZuphv; arc=fail smtp.client-ip=40.107.8.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmC8N9XYruCqLP1WMqhhEA0jp9cUSMPrpsClSMBpct8N8gdzfxEqnJbZlWSbYLjs99/eOURy87JfrLhZzV3rBXFfh2tQPA3M/zAoZE4NIjaTJznBIFKGp6g6wj/MF9ikWZwb9YpC2Ghi1mwvszvQ7B6dWX6NKR9wv7Ru6+MqYuIPb178kGdHVKnBqSvHD+qUeDC7UN+4uFlmYfr6nvoOuoY3QbdpipzGdgfKf6dBg738m5Mhh+gwTUR8HSvOwXWZjnQ767ptPx3ENafJTNw9FuhnsjchVttbVhvwPigqEBzxBPT50ZtArMUXtoXHPWqBCNmLuNvApVwGJVDs3XuvEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=s8QMtjGRVgHw7Iyy7rPMkowb+dmNNCdz2QJOeRotc4A=; b=J9DUgVfipdoPOvlF/FxvwjPBcK7Nmp8d3+lX6sbBHpypxLAnVbCyLvxMcCsreBoBhS9kSWLflDu8CZxP6kYx9xvAIRxDFNubtC5ARFozO6gbYABXfHD3rqOoKvvJxDp2YnlIFc1rz5CEs1Z46e6waSYXWj0LZKS2Uxf2MpgIR7/FRVv4rf58QP3BrxuAPRSaHRH05ikdBUUVFTrLIJL89TpMCqA5H1cv667e1AkwFrQ/xjhpK97PIRWxnmDp/a5yWipGOfZrYB1JJkpivc7dZmXN6AzprC4TaV3SVcUbJea2VqaTvzK6sMOMoSmdRLNIuPD0wpXchiCMhjmL5HIeaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s8QMtjGRVgHw7Iyy7rPMkowb+dmNNCdz2QJOeRotc4A=; b=kgiZuphvqKZ6etjvLmlbIWwmdVOI7XTpQYUXHEZZi7jfx/iSmXyeGXjfW0bI5b/lCJomd3XGV6IuN1fiR5eWMHtGYZHB0ybQnm6UA79Wb71UDQ/KQJw7Ny2nEIvHUm/c5fM/xf1WEveU36lU95Qtvh2LZGmfx7UkYC1/aUxv5EyjuYrOPjiFIn8vlu0BKJXvCyfdfYCYSoC6if6pV/0We9UkpfXa6dTolkh6LpOWarKD/YO6tItp7hQ+jczmDPxQbyWwAkiSx98B/DBCAogPgwhk3t+GRRJ2pBt+p0swUsqH5N/qebSnkGcy5h1Vz3ol0kayoJ/nZwsWMtfEz77XYw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) by GV1PR07MB8997.eurprd07.prod.outlook.com (2603:10a6:150:a2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.31; Sat, 9 Mar 2024 07:45:39 +0000 Received: from PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::995b:5be7:51dd:e540]) by PAWPR07MB9688.eurprd07.prod.outlook.com ([fe80::995b:5be7:51dd:e540%4]) with mapi id 15.20.7362.030; Sat, 9 Mar 2024 07:45:37 +0000 Message-ID: <66fdce3a-c7f6-4ef4-ab56-7c9ece0b00e2@nokia.com> Date: Sat, 9 Mar 2024 08:45:35 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat To: Joel Fernandes , Russell King , "Paul E. McKenney" , Josh Triplett , Boqun Feng Cc: Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240307160951.3607374-1-stefan.wiehler@nokia.com> Content-Language: en-US From: Stefan Wiehler Organization: Nokia In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR4P281CA0185.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ca::18) To PAWPR07MB9688.eurprd07.prod.outlook.com (2603:10a6:102:383::17) 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: PAWPR07MB9688:EE_|GV1PR07MB8997:EE_ X-MS-Office365-Filtering-Correlation-Id: 35f590dc-ac5a-4e83-ff87-08dc400ce90d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qYhbUHawrRXkyrErgTbKPO1RefIN5iW+RXHbWHyaw8IUZrgtDfg6yqhXGzJFWP2NkKRK//eK8VNgORrEwhg0+1OgGBLWtV5oawGPmUmzxcwsCkQbjwkQC48DO1e3IyT160l6g7BwmVlNgpa4ldIntUmg1J4haZjOg2ojYKI3uukaLpmfkPcJS1C7AmMmc8gAoLFidTVddquWoqeETx7R+lEXUHgb/rN+6tnS1Ls1GT5O8PdfLrGuRtchQ6Zc7K6zJPcdU6In8wCT0N0X8SKswulPXABMXAw7yWzV451RUH7kGAuytOUwUvgizAqs3RL1Ez78BUwRmZO5aXGQy0/Zdm1eyqGtk34vIrzs9UDC/tI9JlDXcrdagL00Qe4G50XbaMME2bkctCn6hbAj4s2/7m+Vx9FRjtpq9n+Jg59tMSxhrMDcCZ0bKkLiEOe7QpSqxvJSg2V652bmT4/PjAQGPqHnzZ7I62rucdyzk80j/ODjMAmvVbkCVg38DGcy9izKtZ9636RAimWkAXd3OsUiaZWcFtTFcyurocFjU+pWIZb7gQGBB2glOkpMmMpAkycExTKodulHo1G/Gl6ejzPIHOsfSKnmGlXcXqtnskVZCmQLypvwVlIXpv9YtFJp2dUvlAwx3GAbz8YtEiz/CIr/OSNTNSm85lIKxZuKp46WEuM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR07MB9688.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dXhQWm1RYmVHQkcvRi9laTBsbStPZ1BrTUluQ0JsUm9hY3lDd3B0ZDZLNnhT?= =?utf-8?B?OFVaVUJ3eEV3YTJFVW0wS3J5ZkYrUGRYT1JtcHo4MElnSFFDbEVMZGVML2hz?= =?utf-8?B?S0l0Y0JJY3RDbFlMK2l1bzlwMnpmSGw4bnI1cGxhYkkwSXd1ZjdnL3VxRjdo?= =?utf-8?B?SW14K3p5cW9tUlZURmkxeHNTa29JWXRNb2FScFlxbTlyYWVpejBRSkR1VGRn?= =?utf-8?B?dHY0dmZENFVHdGNzNkc2MHpRT05HejNlRzhFSkl6QzNUNG5DMk84V0VtMnc2?= =?utf-8?B?NTFWK1lQMkxORzVNR2I2ZFlVN3E0eDRTbTl0djhRV3BkRVY4QlZSbGVXTHNH?= =?utf-8?B?cFFoY1dJdlNSNXVGZzlseXJhZytsdDRLQllLb1RITXkyRHNjbUJGR294Umg1?= =?utf-8?B?WGdvdHoxTU5CYU5CUmhsckNTTmVOZVVRdjZnNFV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HpjaHpVbm13PT0=?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35f590dc-ac5a-4e83-ff87-08dc400ce90d X-MS-Exchange-CrossTenant-AuthSource: PAWPR07MB9688.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2024 07:45:37.4633 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W7ZpP+NTMbC+6bHqRSTVMjE0aGYoZ3EypEAG9Eh3Rdk30iXsBL2HrAZHitNqHgvvOl0Zb0CynwtoEvD4imTNQMggjOR3lJ0wiREVuIwQD3Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR07MB8997 > I agree with the problem but disagree with the patch because it feels like a > terrible workaround. > > Can we just use arch_spin_lock() for the cpu_asid_lock? This might require > acquiring the raw_lock within the raw_spinlock_t, but there is precedent: > > arch/powerpc/kvm/book3s_hv_rm_mmu.c:245: > arch_spin_lock(&kvm->mmu_lock.rlock.raw_lock); > > IMO, lockdep tracking of this lock is not necessary or possible considering the > hotplug situation. > > Or is there a reason you need lockdep working for the cpu_asid_lock? I was not aware of this possibility to bypass lockdep tracing, but this seems to work and indeed looks like less of a workaround: diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c index 4204ffa2d104..4fc2c559f1b6 100644 --- a/arch/arm/mm/context.c +++ b/arch/arm/mm/context.c @@ -254,7 +254,8 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk) && atomic64_xchg(&per_cpu(active_asids, cpu), asid)) goto switch_mm_fastpath; - raw_spin_lock_irqsave(&cpu_asid_lock, flags); + local_irq_save(flags); + arch_spin_lock(&cpu_asid_lock.raw_lock); /* Check that our ASID belongs to the current generation. */ asid = atomic64_read(&mm->context.id); if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) { @@ -269,7 +270,8 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk) atomic64_set(&per_cpu(active_asids, cpu), asid); cpumask_set_cpu(cpu, mm_cpumask(mm)); - raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); + arch_spin_unlock(&cpu_asid_lock.raw_lock); + local_irq_restore(flags); switch_mm_fastpath: cpu_switch_mm(mm->pgd, mm); @Russell, what do you think?