Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6318905rwr; Tue, 9 May 2023 13:25:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MvwFMAKOl+fDkO+9AR0gLHD74Fr6673OvtAa5XxCdhKgLuvCYhVZLxkfKE0SCZA2P6zlY X-Received: by 2002:a05:6a21:99a9:b0:100:8cf0:f92c with SMTP id ve41-20020a056a2199a900b001008cf0f92cmr10336410pzb.12.1683663947256; Tue, 09 May 2023 13:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683663947; cv=none; d=google.com; s=arc-20160816; b=WCmbZM3jg9GXA1q/N8Ew3oJREYdsTUctR3PJkahICp5UOT/NhluNYVis9kax9j9xxI Kj+u9imUNxSvya/1MKhFuvpUIk2OzoRNAA1Ri6pCEY8PU9By7K13YOcpjaoVIc+ccKLo tEHQYjttaPN/MhKWczBfHBxQa0tVlR13ef+Zw0fZ7uOnJhEJdyFQU4xZ9PIIfLVkmeAw E2cfIsgTDF2qRHtR+MGQwdh/LaXlKFa7KRg+8S8HUN6iBJvlhMO+FaRMS9tjhDAXiiJy 2qKgVN8hc+51/Ugj2Afca3palEy8xyi2vhGhbB1+7n+2x3UcKFOzNG8tYdcMm2222y0Q TTFg== 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=qR8mXUsmyLZCiZdDl00ZNRj2ZwtIGrMAWuqZ870emdI=; b=WMh4pcmVaq/ODHFWqswDqCOFuBMFmD5m10Kie6W/eEaEU6Mq0Hs7Tjg1Xp8ut37yBI 73qJXVbNCTQTnQIqjYGAK3ujEOKMOEl2WkfzdSYdH0Gxubhud7iQqGfUnGwFbibV1AQM TnqlDsGqDaY1AZsdO70yoNuldkM3gFlOZjhctLCtvuh9xbJBEJA+gkCejkacTRtshxtN l9Gjq/2qX56K63Ucgnju3ftduSp9oL/DoAEMvRdDWV9EYOL41NGKCy0CKlnwEasCV1xq mVlen5yakRQ02oliYy2XV2ZfuaNPIv/JIVCcXBWRfI8xAfgwqSclfRZj/c2Qk0GFRZ0G PcNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=tzk89pqs; 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 z185-20020a6333c2000000b0051398688754si2259465pgz.54.2023.05.09.13.25.30; Tue, 09 May 2023 13:25:47 -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=tzk89pqs; 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 S234267AbjEIULb (ORCPT + 99 others); Tue, 9 May 2023 16:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbjEIUL3 (ORCPT ); Tue, 9 May 2023 16:11:29 -0400 Received: from out-9.mta1.migadu.com (out-9.mta1.migadu.com [IPv6:2001:41d0:203:375::9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5444BCF; Tue, 9 May 2023 13:11:24 -0700 (PDT) Date: Tue, 9 May 2023 16:11:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1683663082; 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=qR8mXUsmyLZCiZdDl00ZNRj2ZwtIGrMAWuqZ870emdI=; b=tzk89pqsaQffwTt8Mrhcs6CEIbfrMOrJ+KCOOGcFaeqbS81YDGBEbvOAyDyYl/7Wxby90O rRhD4S5o2bYXAEHoP7iUOxQwnr/lV9H7n9+gmdp4K4rrWHmCzoHnW8i/xHU2ce6idfOB1E fU75mFjBGzdRG+FKE8Xm68w1ghPVKCk= 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, Kent Overstreet , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Subject: Re: [PATCH 02/32] locking/lockdep: lock_class_is_held() Message-ID: References: <20230509165657.1735798-1-kent.overstreet@linux.dev> <20230509165657.1735798-3-kent.overstreet@linux.dev> <20230509193039.GB2148518@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230509193039.GB2148518@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 Tue, May 09, 2023 at 09:30:39PM +0200, Peter Zijlstra wrote: > On Tue, May 09, 2023 at 12:56:27PM -0400, Kent Overstreet wrote: > > From: Kent Overstreet > > > > This patch adds lock_class_is_held(), which can be used to assert that a > > particular type of lock is not held. > > How is lock_is_held_type() not sufficient? Which is what's used to > implement lockdep_assert_held*(). I should've looked at that before - it returns a tristate, so it's closer than I thought, but this is used in contexts where we don't have a lock or lockdep_map to pass and need to pass the lock_class_key instead. e.g, when initializing a btree_trans, or waiting on btree node IO, we need to assert that no btree node locks are held. Looking at the code, __lock_is_held() -> match_held_lock() has to care about a bunch of stuff related to subclasses that doesn't seem relevant to lock_class_is_held() - lock_class_is_held() is practically no code in comparison, so I'm inclined to think they should just be separate. But I'm not the lockdep expert :) Thoughts?