Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3386121rdb; Thu, 16 Nov 2023 08:13:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtGdhfJ55Eh35fdomSnG90U07+w7proexGQ1z8mPiEq/gM3Ul8Qda1n1GTSMSNNozIXcb9 X-Received: by 2002:a17:902:ea07:b0:1ce:8af:4595 with SMTP id s7-20020a170902ea0700b001ce08af4595mr9481435plg.53.1700151181620; Thu, 16 Nov 2023 08:13:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700151181; cv=none; d=google.com; s=arc-20160816; b=iqJKy1uSLCoLEZo8nHfA/QOWk0mUU2ho0s+X2ZSxNug2GwPIutXZBjr2QrgCArQtRj Uyx47pEw5xnJw4PHzHwAgqDK+yOh73+QbM2O8N2h1J0CklcrKlqszR/i76Hgv7HE1cS9 ffCWzF6FbiKPE17lBBaxfwQjOvw6TABKGrwGflQgnZPPA12eMowtTRdi+73mE9qg5NAt V+gmzWfnI2l6ojzvjMqFng6ZbT66xIlnjJGs20AONiA1dt0wz0+doG47aup5kz6mEFbr Vy9vwfefCvf4nkLIIn0umdAL7NTBVT4KoonCSNOgwDdmkrtHQ+F1cVIxLu+AESPXYMlb AMuA== 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:date:dkim-signature; bh=Lz9jtIq5mDaKC570N2BIf9wLXeeJJC+HK/9/2AmFe2Y=; fh=ps/A7SKZD6tqCZCDsZLypuTfvG8Iop1qTaAbkcBYGyo=; b=ih7ZAnE5nHBa7UJXoQinMGVDy5dgvbna2WXHWMXOP2PtOPYSL26VpDWX5ZEudEgCxZ doCPuhCxLzai8iGA1JAo2+hEVfKfMu38vhGhI7BmVmRcaaYRaeqxTIcXRdo1DFPL8epl LhW97w20vPA1A3xKlwhBign/mOLAnRa0h+NqW7MWrv7PZHD+Z3MQhvbKDub47533pmMS OWXwKhBoUZmNktarzmjg/dyy4ep/WEVq/C6VU8AySRzuZifyoOKP74uW6pH/nZo690xw K3Dleriv2Hu68SrVUf9QgkWwLD6JdVLZ/DoJXWzhSI0gJlMrNaNKx7JZH464KsbC7nQ3 cNkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=G2Z0gmyd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b8-20020a631b48000000b005be3c0443e7si12662584pgm.643.2023.11.16.08.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 08:13:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=G2Z0gmyd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4C07081D7A7F; Thu, 16 Nov 2023 08:12:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231126AbjKPQMs (ORCPT + 99 others); Thu, 16 Nov 2023 11:12:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbjKPQMr (ORCPT ); Thu, 16 Nov 2023 11:12:47 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E8B193; Thu, 16 Nov 2023 08:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Lz9jtIq5mDaKC570N2BIf9wLXeeJJC+HK/9/2AmFe2Y=; b=G2Z0gmydhvRGXv3j/EgJ5/r98/ JRxc7e8AgM7fcqr96CRTx3YKpfFGomG45ImrBNZ4AcVV1FfGosSfbRC8yoKwzUj6ZZbW1dwZEF7S4 q9qEE0dqulvK+qgxAnWkD5ylAReeUZnnN9FJBEvgMiegE5we3Dt2xxNSrAgFUeDvC8ZYpcHZSfaAY QpEkCz2mMV0vk0HaibcjqwOhi2V/t85uf+djkOoj0Tdn4x4xy9hoYGPpfpvCoXh3JKgS3kKiDjS1H PTtt0rwS2L56Vez7EpKXi63vls+6/KPkNwFRKl+Plp3DJPStTfQ0XtXhIVmG1mC7+M+g4rxhvVT4R 2sHkY/FQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r3eym-003xSV-RC; Thu, 16 Nov 2023 16:12:32 +0000 Date: Thu, 16 Nov 2023 16:12:32 +0000 From: Matthew Wilcox To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chandan Babu R , "Darrick J . Wong" , linux-xfs@vger.kernel.org, Mateusz Guzik Subject: Re: [PATCH v3 1/4] locking: Add rwsem_assert_held() and rwsem_assert_held_write() Message-ID: References: <20231110204119.3692023-1-willy@infradead.org> <20231110204119.3692023-2-willy@infradead.org> <52f481a3-bf4f-85ae-9ae6-10a23b48c7c5@redhat.com> <72dced0f-6d49-4522-beeb-1a398d8f2557@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <72dced0f-6d49-4522-beeb-1a398d8f2557@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 16 Nov 2023 08:12:58 -0800 (PST) On Tue, Nov 14, 2023 at 08:17:32PM -0500, Waiman Long wrote: > > > There are some inconsistency in the use of WARN_ON() and BUG_ON() in the > > > assertions. For PREEMPT_RT, held_write is a BUG_ON. For non-PREEMPT_RT, held > > > is a BUG_ON. It is not clear why one is BUG_ON and other one is WARN_ON. Is > > > there a rationale for that? > > I'll fix that up. > The check for write lock ownership is accurate. OTOH, the locked check can > have false positive and so is less reliable. When you say 'false positive', do you mean it might report the lock as being held, when it actually isn't, or report the lock as not being held when it actually is? The differing polarities of assert and BUG_ON make this confusing as usual. Obviously, for an assert, we're OK with it reporting that the lock is held when actually it's not. The caller is expected to hold the lock, so failing to trip the assert when the caller doesn't hold the lock isn't great, but we can live with it. OTOH, if the assert fires when the caller does hold the lock, that is not tolerable.