Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7855245rwr; Wed, 10 May 2023 13:43:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ709kCNfim8mIQqfA65quD3TPiUQqHLirDwZ89PDDmInNdulnDBw7MZSut9GdkV62nuuJYu X-Received: by 2002:a05:6a20:6a29:b0:ff:df0d:a6fb with SMTP id p41-20020a056a206a2900b000ffdf0da6fbmr14547535pzk.28.1683751433616; Wed, 10 May 2023 13:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683751433; cv=none; d=google.com; s=arc-20160816; b=gEadSuac+q6/UVBUmeRijtfSBHATnQ77wqcQmkBdc7IEM53e6Xvj/faS7Q9IY6npHP sIuc/1CA6YC1dKHJYk4lenS/prduZtMWFi1kGO2wiiz6OrcpVgGbt/BPOIWVa5rU1Umn cJuH1CARddDvo+jnUGcPAK/RZJ5GD1vmmX6AaLtXN/EooJEyCIyCu8x85Rao+mpyzVxf oAUuE4inp1IrcYbJ1Hcpwaqd9tarjN2DNW4DeY1ZHYBOJpM1GzgfygKqHWunn194ADMe 5xBwD4firo25c4weZ/Fs9oE1Ds+yLeXHEGDxQqPOY0Ya3OrudBxfUYTiUr3LAnK5ikiK R/Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=2Fntx7MeicDCqrqkDflloXBJRcdF7P6Ni3sDbF9MNgY=; b=QSDMBqLa8fi22oHLxEYMPGp6/jqR+v2vN/jA/+FiSfpT21tmqamUs4KCiAJ08L6WU/ 1ytLwqXmS39VNvkDK5onfwcOV6EM8q0NBiAkrjNOHKiRxTuoDmDp1FfyWi+Ule/6PBz+ QiVfJpCYCiFyqfbT9R6I7J2xmHV3TvkN2i+MBagNCkVAjuR1VbUxxvUsgGDlMeVi7m9d NILDdLV5SzfgyAxGRJqtwM+kQW+8KzlP/m9VSPgge5fxGNIHcwN+95SP1fE6+zDT9AOX gKW6+IlTlM2SyQLz2hEPvRX6yEFlZJQ0vN/4D4Y2oTQ5fR+sstRQckHR8wevn9ozlro+ Tlhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="sgO/UEIE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v7-20020a63b947000000b0050f66d53c3fsi4678852pgo.299.2023.05.10.13.43.41; Wed, 10 May 2023 13:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="sgO/UEIE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236499AbjEJUi0 (ORCPT + 99 others); Wed, 10 May 2023 16:38:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236451AbjEJUiZ (ORCPT ); Wed, 10 May 2023 16:38:25 -0400 Received: from out-20.mta0.migadu.com (out-20.mta0.migadu.com [91.218.175.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 362CE6184 for ; Wed, 10 May 2023 13:38:20 -0700 (PDT) Date: Wed, 10 May 2023 16:38:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1683751099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2Fntx7MeicDCqrqkDflloXBJRcdF7P6Ni3sDbF9MNgY=; b=sgO/UEIER2ve69V7tr81qDruo0+4xB0qMuqeM/8cdeT0yaaX6I/u4iRttuOzcQCIkedk7A R06RISg+MM0T5Pweyj+u2fbyUVH8fL50g+G1V7Ab/ISM3Pqn248qKrUvNY6tC1cpnhkhwp hgvyOqVblL24TSKV1xAEptkKxoz3d6s= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Subject: Re: [PATCH 03/32] locking/lockdep: lockdep_set_no_check_recursion() Message-ID: References: <20230509165657.1735798-1-kent.overstreet@linux.dev> <20230509165657.1735798-4-kent.overstreet@linux.dev> <20230509193147.GC2148518@hirez.programming.kicks-ass.net> <20230510085905.GJ4253@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230510085905.GJ4253@hirez.programming.kicks-ass.net> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 10, 2023 at 10:59:05AM +0200, Peter Zijlstra wrote: > On Tue, May 09, 2023 at 04:18:59PM -0400, Kent Overstreet wrote: > > On Tue, May 09, 2023 at 09:31:47PM +0200, Peter Zijlstra wrote: > > > On Tue, May 09, 2023 at 12:56:28PM -0400, Kent Overstreet wrote: > > > > This adds a method to tell lockdep not to check lock ordering within a > > > > lock class - but to still check lock ordering w.r.t. other lock types. > > > > > > > > This is for bcachefs, where for btree node locks we have our own > > > > deadlock avoidance strategy w.r.t. other btree node locks (cycle > > > > detection), but we still want lockdep to check lock ordering w.r.t. > > > > other lock types. > > > > > > > > > > ISTR you had a much nicer version of this where you gave a custom order > > > function -- what happend to that? > > > > Actually, I spoke too soon; this patch and the other series with the > > comparison function solve different problems. > > > > For bcachefs btree node locks, we don't have a defined lock ordering at > > all - we do full runtime cycle detection, so we don't want lockdep > > checking for self deadlock because we're handling that but we _do_ want > > lockdep checking lock ordering of btree node locks w.r.t. other locks in > > the system. > > Have you read the ww_mutex code? If not, please do so, it does similar > things. > > The way it gets around the self-nesting check is by using the nest_lock > annotation, the acquire context itself also has a dep_map for this > purpose. This might work. I was confused for a good bit when reading tho code to figure out how it works - nest_lock seems to be a pretty bad name, it's really not a lock. acquire_ctx?