Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F0DAC6379F for ; Tue, 14 Feb 2023 02:10:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbjBNCJ7 (ORCPT ); Mon, 13 Feb 2023 21:09:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjBNCJ4 (ORCPT ); Mon, 13 Feb 2023 21:09:56 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAA1912F17; Mon, 13 Feb 2023 18:09:55 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id g18so16103921qtb.6; Mon, 13 Feb 2023 18:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=b0+HenZNoKThrL9wix0Mx2a4DCWq8ldMDRHK+a4MjSI=; b=FRtdaCSMOqUMFiLr5EA7VHivdDV8PBAwUlmYDWmHk3FjPPZBrA92/CpiUGnywDNrzW gvtm3forCiGREhmqQ6Zd1U2umPlavkVTRiptJEoGvwVxt6M9eqJnskl6HeCSh89WAlhg Or90PeVl9eQEke/PSOYR4Z/asaXrp0b1/L9w1ZYCZM5QYu5cdrBRiOodG8c3W7b0XL/x NVertr+7exT9RKsGVxVh1heTp+9Xe44WFfAk3Nml2OCdEStyIjjU11ppiVnSpcRzRZ+b hT79NGx51/gXTupeV3aTV134OJySPpJnECFUES/YgJEoiMiIpZu0e5ykjnPIBnrts/Ub sufQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b0+HenZNoKThrL9wix0Mx2a4DCWq8ldMDRHK+a4MjSI=; b=6rKEgB8g072s15ZNyXE5jI9LBpXbkAXpImoQCDwxX9wE5WlYGYOrPYL7k1vB2pphg/ 0l6Np9RyrqHHW/GIHaYgzLEnzSL+Nkv9qfcm6n9WSUU0FKilENX9lICKZ4G7iRbmqo7v 6RqrSe3BzO0cUMWzwvIxjADvyy8mtyw8ZAvBXUx5bDyOe9UucYyPHAvLDMCfLPMxBnb4 pmQPwfJl2C/HjLV7aDJ44DgSBw6L2lNZhxpLuyN5ThaEBI6H3NJAiKtoMPjX0dTYA+n/ tOQpK2Hj6pUbJZbqLUwcX6UFSRjayGudu4LYJsDRQNVYH+G1RZ/bUt4iAEjSyJ7XWxDv D+qw== X-Gm-Message-State: AO0yUKX3h8RH2MM++klIdfCqCz/ZGGiLAZCTGPSTgRFtWcREJob4OmM+ gSvs2TO1uH+XisD2lhpLb4c= X-Google-Smtp-Source: AK7set9WiiGg3n7cZ5WmiTdlMMMoWlmE0t6H59xFWsd9QmQmy7TFHt1NQayAxAmFc/EzNTzLgqIhvw== X-Received: by 2002:ac8:59cc:0:b0:3b9:a4bb:e53d with SMTP id f12-20020ac859cc000000b003b9a4bbe53dmr806835qtf.34.1676340595032; Mon, 13 Feb 2023 18:09:55 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id y129-20020a376487000000b00738e8e81dc9sm10921256qkb.75.2023.02.13.18.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 18:09:54 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id E592327C0054; Mon, 13 Feb 2023 21:09:53 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 13 Feb 2023 21:09:53 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeivddggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Feb 2023 21:09:52 -0500 (EST) Date: Mon, 13 Feb 2023 18:09:16 -0800 From: Boqun Feng To: Alan Stern Cc: Peter Zijlstra , Kent Overstreet , Kent Overstreet , Linus Torvalds , Coly Li , Tetsuo Handa , syzkaller , Dmitry Vyukov , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ingo Molnar , LKML , USB list , Hillf Danton Subject: Re: [PATCH RFC] drivers/core: Replace lockdep_set_novalidate_class() with unique class keys Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 13, 2023 at 09:03:14PM -0500, Alan Stern wrote: > On Mon, Feb 13, 2023 at 05:51:11PM -0800, Boqun Feng wrote: > > Basically if you have two lock instances A and B with the same class, > > and you know that locking ordering is always A -> B, then you can do > > > > mutex_lock(A); > > mutex_lock_nest_lock(B, A); // lock B. > > > > to tell the lockdep this is not deadlock, plus lockdep will treat the > > acquisition of A and the precondition of acquisition B, so the following > > is not a deadlock as well: > > > > T1: > > mutex_lock(A); > > mutex_lock(C); > > mutex_lock_nest_lock(B, A); > > > > T2: > > mutex_lock(A); > > mutex_lock_nest_lock(B, A); > > mutex_lock(C); > > Why isn't this treated as a deadlock? It sure looks like a deadlock to > me. Is this an example where lockdep just doesn't get the right answer? > Because A serializes B and C, so that particular piece of code doesn't cause deadlock. Note that you can still use you normal mutex_lock() for B, so if there is more code: T3: mutex_lock(C); mutex_lock(B); lockdep will report deadlock. Regards, Boqun > Alan Stern