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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDA66C05027 for ; Thu, 26 Jan 2023 11:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236758AbjAZLa6 (ORCPT ); Thu, 26 Jan 2023 06:30:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236407AbjAZLaz (ORCPT ); Thu, 26 Jan 2023 06:30:55 -0500 Received: from frasgout13.his.huawei.com (frasgout13.his.huawei.com [14.137.139.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48BA95A808 for ; Thu, 26 Jan 2023 03:30:52 -0800 (PST) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4P2dbt2wSFz9xFHR for ; Thu, 26 Jan 2023 19:22:50 +0800 (CST) Received: from [10.48.129.37] (unknown [10.48.129.37]) by APP1 (Coremail) with SMTP id LxC2BwDXXAhJZNJjRC7LAA--.322S2; Thu, 26 Jan 2023 12:30:28 +0100 (CET) Message-ID: Date: Thu, 26 Jan 2023 12:30:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [Patch 2/2] tools/memory-model: Provide exact SRCU semantics To: Alan Stern Cc: "Paul E. McKenney" , Andrea Parri , Jonas Oberhauser , Peter Zijlstra , will , "boqun.feng" , npiggin , dhowells , "j.alglave" , "luc.maranget" , akiyks , dlustig , joel , urezki , quic_neeraju , frederic , Kernel development list References: From: Jonas Oberhauser In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM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UI43ZEXa 7IU13rcDUUUUU== X-CM-SenderInfo: 5mrqt2oorev25kdx2v3u6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/25/2023 11:52 PM, Alan Stern wrote: > On Wed, Jan 25, 2023 at 10:04:29PM +0100, Jonas Oberhauser wrote: >> >> On 1/25/2023 9:21 PM, Alan Stern wrote: >>> (* Validate nesting *) >>> flag ~empty Srcu-lock \ domain(srcu-rscs) as unmatched-srcu-lock >>> flag ~empty Srcu-unlock \ range(srcu-rscs) as unmatched-srcu-unlock >>> +flag ~empty (srcu-rscs^-1 ; srcu-rscs) \ id as multiple-srcu-matches >> [...] >>> // SRCU >>> -srcu_read_lock(X) __srcu{srcu-lock}(X) >>> -srcu_read_unlock(X,Y) { __srcu{srcu-unlock}(X,Y); } >>> +srcu_read_lock(X) __load{srcu-lock}(*X) >>> +srcu_read_unlock(X,Y) { __store{srcu-unlock}(*X,Y); } >>> +srcu_down_read(X) __load{srcu-lock}(*X) >>> +srcu_up_read(X,Y) { __store{srcu-unlock}(*X,Y); } >> How do you feel about introducing Srcu-up and Srcu-down with this patch? > Why invent new classes for them? They are literally the same operation > as Srcu-lock and Srcu-unlock; the only difference is how the kernel's > lockdep checker treats them. I don't think they're necessarily implemented in a compatible way, so r = srcu_lock(s); srcu_up(s,r); might not actually work, but would currently be ok'ed by LKMM. With different classes you could state   flag ~empty [Srcu-lock];srcu-rscs;[Srcu-up] as srcu-mismatch-lock-to-up   flag ~empty [Srcu-down];srcu-rscs;[Srcu-unlock] as srcu-mismatch-down-to-unlock I think with the current implementation this code might work, but I don't feel like this is inherently true. You could then also go ahead and define the "same CPU" requirement as a flag for lock and unlock specifically, like   flag ~empty [Srcu-lock];srcu-rscs & ext as srcu-lock-unlock-mismatch-CPU or so. Best wishes, jonas