Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10845493rwr; Fri, 12 May 2023 14:02:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dFxAoqRgnJ4OSI/sZF5t3rsfDvM39BEDnneaQiw7WxA/Crl3hstHyTv1kPZC/txqWaOcK X-Received: by 2002:a05:6a21:9987:b0:102:1083:b4aa with SMTP id ve7-20020a056a21998700b001021083b4aamr15481173pzb.25.1683925360034; Fri, 12 May 2023 14:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683925360; cv=none; d=google.com; s=arc-20160816; b=LItDsiSUAJe1nPQ4CU6omSSN0xJJYP6osKe06OFVYqYgPvo1X9IhruSecDqH6bPaI5 a90ZoFKrkMgwslFsz2Ve23iFHLweZfbug2cswAVflHdhEMTUB6DodYjwe6ICpYiy034C J6WzUY+fFGsuVHng+gemO9EEQmo5qTWzmS8HqsB69TGJibuJsCkjLWCcZDNv8uDYms1Z u4R52mowORVfw4H3BJcfnulUAVX0gJc2uzoCQHJdmQxKAoXAg1Up4aiAkQTm1YCKXrIw WrmHazhhQ5+UC7n+eQTOhcatc0eWhArrTDpaXsFZukg1cn1KruZjNbt3dxdj8y+Dt+Mn Dv6A== 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=FMT90UCMn0fWFglADEopgULejFhzB6Tyuu4ibJ17nuA=; b=WQ+6BMvjfWjRv6VZJhAvP1kMrBkeS5/pF8o7SPcKrHD0iuRB2RNxJWzbOwRsBYDuoa 9u5fu7LBYSfy7hQu8dBcfLHszFazbz9ZMCKC7HlQIydiuVZz6lvM+bMOS7tO52ZNdLcg 0vt0tNtfvTMDxnWZJtsYLJ8tQxJqb5st8vTHCkrqKKAurQ+VvYm0593EXOjxeTODWSLu YW55QaHmjY7gl5MhbPS+bXGX1ESJs5mXzIgwHRilNvQbfUW+uLzabyP858MrwmNQC5BF 7sxBH+m3Djx2xQOPcgPWu0LPLNQAd3LnC1u5KvtCU3olrOPn7wWH1BEkHG0qQAFraTai ayog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="h2bIEs/Y"; 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 e30-20020a63745e000000b0053075167160si4887667pgn.329.2023.05.12.14.02.27; Fri, 12 May 2023 14:02:40 -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="h2bIEs/Y"; 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 S238509AbjELUuB (ORCPT + 99 others); Fri, 12 May 2023 16:50:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238363AbjELUt7 (ORCPT ); Fri, 12 May 2023 16:49:59 -0400 Received: from out-26.mta0.migadu.com (out-26.mta0.migadu.com [IPv6:2001:41d0:1004:224b::1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A8BE26B9 for ; Fri, 12 May 2023 13:49:58 -0700 (PDT) Date: Fri, 12 May 2023 16:49:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1683924595; 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=FMT90UCMn0fWFglADEopgULejFhzB6Tyuu4ibJ17nuA=; b=h2bIEs/YC7cca86id1A0bf5FA55jjfYAwFBk6uWfgO2um8uM0euOLviTbpIEmTHSEDvdOK 5vWkQiX6uf5Kh9fB4wb/MtyID916vfvV/VfLBFvQGLdgqxsr4F7mONqYab7f+IMRZVzsuL F6ZZg8gYYEqyvQuEpZnGMAJkq+0miEc= 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. So, spent some time plumbing this through the six lock code and seeing how it'd work. I like it in theory, it's got the right semantics and it would allow for lockdep to check that we're not taking locks with more than one btree_trans in the same thread. Unfortunately, we've got code paths that are meant to be called from contexts that may or may not have a btree_trans - and this is fine right now, because they just use trylock(), but having to plumb nest_lock through is going to make a mess of things. (The relevant codepaths include shrinker callbacks, where we definitely can not just init a new btree_trans, and also the btree node write path which can be kicked off from all sorts of places). Can we go with lockdep_set_no_check_recursion() for now? It's a pretty small addition to the lockdep code.