Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp225030rdb; Thu, 16 Nov 2023 17:51:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhlT53575B54OhcIzdUSHg2TArnF3cn8kxWLL9zx80YvFCXHmRj29ZNq0V4U98DAsoRT3g X-Received: by 2002:aa7:8b0b:0:b0:6b1:c1c4:ae98 with SMTP id f11-20020aa78b0b000000b006b1c1c4ae98mr17080045pfd.18.1700185876518; Thu, 16 Nov 2023 17:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700185876; cv=none; d=google.com; s=arc-20160816; b=fgqJj5depqazWvz3Ric5kvD/Hdon76Sycva5wTgZpAoxKmDSV+Pb/UPJC14pZUREkI MwfVDuResIgZ3pRwr4T5SytsX/+tSZzFk6OTTXPuJAV+1fpQujRyXF5Jk0qMcqOhMBpD B1GbgeZNhWEX2342xhfHHc2tmlcTUPTCAXgAez2ozelezznUEKq/7mAHeN6OzCGYnfqX HTGkbhz6ccqEzqLKZ2P2XkU87x8Mk9//N8hvr6C+DztBtLw16jt6drsT+qAp/zeCmZZ3 AneffjJ4rEeYguMa7UD90lkCRHNlniDHULPv0pFEQ7eG4nEmiR/O356Fz0/D16Qa0Ev1 hfQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=lGSuWJO7S6MXiDolxtjA6VeW24nPdThcsXKHEAmIP+w=; fh=ktxNGdZT7zXsb1gltjhb42w1Dq5CrXJvJYRap19jx1c=; b=weqhWidAtvcWHgdeiFGuVKDxmzKeJinyz4u1tSEdf+jRtbDRyeTdFc2oAj79axJpFm pXNWfXFe9Noo7W7GDkRUkzsjcjoYUiJUdTz5ltXq4xkbG7RCPCfBgZoxcbvThiQ7GbEV WebpnNehsmZV8C735IJ6Ht3tCU2v+7T6xtzSZeDrKoGI3nuWbAV9y4rXHtfaLiUKMVVC N/ZE8Q0FFPMmCS7YDp4BDFFwZPIcQ2C/4YG+ivG82P2c29BmAiKLtATGA3HWSQtK4f15 o8DNLbC8UdQjViQ5CHXrh5uOSGOO8yy8E4ynL5RyWbE8rqSfyj45kQHhe65QOKuEkxVz s+xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jRMRkbVB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id g17-20020aa796b1000000b0068a590d803csi754177pfk.361.2023.11.16.17.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 17:51:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jRMRkbVB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DA91980B1228; Thu, 16 Nov 2023 17:51:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345642AbjKQBuz (ORCPT + 99 others); Thu, 16 Nov 2023 20:50:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345630AbjKQBuy (ORCPT ); Thu, 16 Nov 2023 20:50:54 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF1CC195 for ; Thu, 16 Nov 2023 17:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700185849; 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=jRMRkbVBL5jW4XSgH+6T93b1MR71BuXPizuQ55UbvjKN7b9F1Fh3bwR2w/PAWyPZ3xq4t8 Ua96ng8/DTSb1fYNE9I8KKk1nMGRaU71AWufRifHv+C1oRy+abt76n5v0z0pcHZwwhLOaL wc0YDM6fMTx9SBwR65NSVgcFrjYd4MM= 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-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 17:51:04 -0800 (PST) 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