From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CDA4C197A0 for ; Fri, 17 Nov 2023 01:50:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8C5E6B04BC; Thu, 16 Nov 2023 20:50:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E3C366B04BD; Thu, 16 Nov 2023 20:50:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D044B6B04BE; Thu, 16 Nov 2023 20:50:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C23C86B04BC for ; Thu, 16 Nov 2023 20:50:53 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 930D9B54B5 for ; Fri, 17 Nov 2023 01:50:52 +0000 (UTC) X-FDA: 81465767544.11.2A8A41C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id A45A3100004 for ; Fri, 17 Nov 2023 01:50:50 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JMNQInFt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700185850; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lGSuWJO7S6MXiDolxtjA6VeW24nPdThcsXKHEAmIP+w=; b=dXq8zIPD0hHgTDBZSQN3pEC9jbmIXKlXKvR+nm57eU9p5smAOcRdQ8QlnVBGXfp6DWXQro aantfNmKO8Rg30Dr1LAjFRSXXTDyfBb+0TYnCC6wigbyWUTU3F6ppasZs3QYwX2vlhEFFS tboGERdZwlUXtt+RZkXSR/Cf2/NJs+s= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JMNQInFt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700185850; a=rsa-sha256; cv=none; b=ew2SXK+dsQMCG5PsmnYX94tWfUXgHsfFs7im+wcojRav0EN9QXbAJceWqfHYzaekj7Umwg DvzvazfAle9xsAwdYmp5elPgaBGPnr2VvlSbwLhHeN+qHTdc9MmHyVU7Hk1kuUpoEeFPS8 2ANOcMWJ64mKWqpaFVpdv/J68FdEWd4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700185850; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lGSuWJO7S6MXiDolxtjA6VeW24nPdThcsXKHEAmIP+w=; b=JMNQInFt2vVa9e5+lMsr6pDRCwhTsOLMGzwGOyCUncfOMqCr9r6n80X5oPV7XAQAfhgQRn cA+ZCV3pcseDeRsYjrEe+QJNS9GLHPGWw8NkN0FeBgMq07LDEFHBXT3m4dLkcHFQk9JfgE PycJSaTp3xumRRtbNfx2bE4VkNcjp5k= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-ui6YRq4tMsWqkVFVbd65CQ-1; Thu, 16 Nov 2023 20:50:46 -0500 X-MC-Unique: ui6YRq4tMsWqkVFVbd65CQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 225753803503; Fri, 17 Nov 2023 01:50:46 +0000 (UTC) Received: from [10.22.8.82] (unknown [10.22.8.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 976A21C060AE; Fri, 17 Nov 2023 01:50:45 +0000 (UTC) Message-ID: <767ce2df-6f9b-40a3-b40b-e9e7a593e3b2@redhat.com> Date: Thu, 16 Nov 2023 20:50:45 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] locking: Add rwsem_assert_held() and rwsem_assert_held_write() Content-Language: en-US To: Matthew Wilcox 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 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> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspam-User: X-Stat-Signature: z3rjgdr4jbjuzdtp68dqfk4iswqunqai X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id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GeWqf/Tww+rm09YMO1TUsWqBxDlPWFoEJIJTfxcAcXGVPc6684tejvkg0MC00/eYBERn61tZZahm6jUNvVEhfjd+2HVA3i5IulOpDlPXuksavFg1S3Ptq9OqvaE7kMZ1jWafiUeJW+aj2AUEETSmaCO+yGhoLKVNcf9WfWFKjKPEQzJYaamMka2JsNUPgrw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 11/16/23 11:12, Matthew Wilcox wrote: > 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. It means there may be no active lock owner even though the count isn't zero. If there is one or more owners, the count will always be non-zero. > > 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. The second case shouldn't happen. So the assert should be OK. Cheers, Longman