Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5165922rwb; Tue, 17 Jan 2023 10:00:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXtiHSvGAChi4TdH/tAiHVWrRu7FZa2L3WIkjwjSCtgGk9djEH3LXYgIy7M1Pe9S2ti+SE/d X-Received: by 2002:a17:907:971c:b0:86f:d154:ef4f with SMTP id jg28-20020a170907971c00b0086fd154ef4fmr3747005ejc.28.1673978431273; Tue, 17 Jan 2023 10:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673978431; cv=none; d=google.com; s=arc-20160816; b=05qNBCgYbu6wAJD8ezTLEu5nIMpGgVDSS36C0VjzOBiLG3A6U6TkeFm1+fZSdC0rvA WtVnHO9E7kg0BsI/AhZr6l7uxm4g8cJQEii77NQJQZD7fzkN4l9QfOl5UsiVLP6L1Hbx W3DxYhVUjghR7O5goj6EZ9EBmaSrvEinAdx0B3REfhK2GvdgTdXQLPFLXhdJ343Cn8TU kCVCJLAcoHmpBBXoCovlolllaPnrNuJRJbHFepTAzBVOQluX+dAkA+t0CmNZFRpkJg6c 1T7ZFfxTBEtTqtG12ER+Z9aWtOdoEWEgTsZw7JJZXmPDV0Ea1BgzJQtLL2erSRC7t1O9 m/Ng== 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:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ctiDWeUS5OKjXO3f9psAlc/eWf97STkOPHYD1pisor4=; b=mp7UHi2yXu8NTpvXvIEeV+pkTUcD4ILTr9vg1d524zz/Qmu6QUgqxOTxcDgBNlQaTm 2DTXm2t100x1mQ0lcb2QaLagxcNzKAvQFMc/tsqP5sIfCxm6GVwYmYUekKtaFaYu4erE uuBntScgtUBNc/2QbwbUHg4mZPI0CrMck+V6hutt68hUHf7awJtYy+pLWgkn39U+YpX1 yXRES61psYihAOaK5IKt3FgeGO39IPjOW8om6tzC3bLf4CGkS3A7eoQRvydjlRtJ4mkl pJUZQUs/zCcRgy3vFxVoU07B8KOycxDJPRQ1w2V3CpbGaRORfCLCD7GNPO+NFDQNNPAW hXPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="J4shsH/h"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz35-20020a1709077da300b0086c92fed1edsi13501585ejc.949.2023.01.17.10.00.15; Tue, 17 Jan 2023 10:00:31 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b="J4shsH/h"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbjAQR4W (ORCPT + 47 others); Tue, 17 Jan 2023 12:56:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbjAQRxp (ORCPT ); Tue, 17 Jan 2023 12:53:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 035B04F851 for ; Tue, 17 Jan 2023 09:43:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A929614F3 for ; Tue, 17 Jan 2023 17:43:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9AF1C433F1; Tue, 17 Jan 2023 17:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673977388; bh=eLHA1ULJgwnmzHeOYX5jr3rraRvGyW95xIRtTdxFUj8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=J4shsH/h560VVMk0TfCwUK6KhwCUvrQwXsvSZl6e+Sb6FNjTF5GACDuknfCN1PZ5F FpgqX80JSwn1HtGl8ATxBT1+fGS9nuCPCXR6nK2bPscSyx2uXnHma9+U6wn2UFIA+u rzQD3Lz/Yzl32mKp2IIxV3NyHvqw2C/BqA4pN5o5klPux1UIP8Nle1yBIhcK3HqSiI FW39GElv8f92bIi5Ab+rociYbk0AcCbZPHSH1UT5FK07FH9SQrNAXOWfIgp2xoq9LE hxP8AYj6SK0ZrNDGcCuR5lDv2OjGr0f5zFGQK6Xr4c0zYJSkgQlgSzlHBBtlmbA+fR 3ACDRUz77/iNg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 68D1C5C0543; Tue, 17 Jan 2023 09:43:08 -0800 (PST) Date: Tue, 17 Jan 2023 09:43:08 -0800 From: "Paul E. McKenney" To: Alan Stern Cc: 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 Subject: Re: Internal vs. external barriers (was: Re: Interesting LKMM litmus test) Message-ID: <20230117174308.GK2948950@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20230115181052.GJ2948950@paulmck-ThinkPad-P17-Gen-1> <20230116042329.GN2948950@paulmck-ThinkPad-P17-Gen-1> <20230116190652.GZ2948950@paulmck-ThinkPad-P17-Gen-1> <20230116221357.GA2948950@paulmck-ThinkPad-P17-Gen-1> <20230117151416.GI2948950@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Tue, Jan 17, 2023 at 10:56:34AM -0500, Alan Stern wrote: > On Tue, Jan 17, 2023 at 07:14:16AM -0800, Paul E. McKenney wrote: > > On Tue, Jan 17, 2023 at 12:46:28PM +0100, Andrea Parri wrote: > > > This was reminiscent of old discussions, in fact, we do have: > > > > > > [tools/memory-model/Documentation/litmus-tests.txt] > > > > > > e. Although sleepable RCU (SRCU) is now modeled, there > > > are some subtle differences between its semantics and > > > those in the Linux kernel. For example, the kernel > > > might interpret the following sequence as two partially > > > overlapping SRCU read-side critical sections: > > > > > > 1 r1 = srcu_read_lock(&my_srcu); > > > 2 do_something_1(); > > > 3 r2 = srcu_read_lock(&my_srcu); > > > 4 do_something_2(); > > > 5 srcu_read_unlock(&my_srcu, r1); > > > 6 do_something_3(); > > > 7 srcu_read_unlock(&my_srcu, r2); > > > > > > In contrast, LKMM will interpret this as a nested pair of > > > SRCU read-side critical sections, with the outer critical > > > section spanning lines 1-7 and the inner critical section > > > spanning lines 3-5. > > > > > > This difference would be more of a concern had anyone > > > identified a reasonable use case for partially overlapping > > > SRCU read-side critical sections. For more information > > > on the trickiness of such overlapping, please see: > > > https://paulmck.livejournal.com/40593.html > > > > Good point, if we do change the definition, we also need to update > > this documentation. > > > > > More recently/related, > > > > > > https://lore.kernel.org/lkml/20220421230848.GA194034@paulmck-ThinkPad-P17-Gen-1/T/#m2a8701c7c377ccb27190a6679e58b0929b0b0ad9 > > > > It would not be a bad thing for LKMM to be able to show people the > > error of their ways when they try non-nested partially overlapping SRCU > > read-side critical sections. Or, should they find some valid use case, > > to help them prove their point. ;-) > > Isn't it true that the current code will flag srcu-bad-nesting if a > litmus test has non-nested overlapping SRCU read-side critical sections? Now that you mention it, it does indeed, flagging srcu-bad-nesting. Just to see if I understand, different-values yields true if the set contains multiple elements with the same value mapping to different values. Or, to put it another way, if the relation does not correspond to a function. Or am I still missing something? > And if it is true, is there any need to change the memory model at this > point? > > (And if it's not true, that's most likely due to a bug in herd7.) Agreed, changes must wait for SRCU support in herd7. At which point something roughly similar to this might work? let srcu-rscs = return_value(Srcu-lock) ; (dep | rfi)* ; parameter(Srcu-unlock, 2) Given an Srcu-down and an Srcu-up: let srcu-rscs = ( return_value(Srcu-lock) ; (dep | rfi)* ; parameter(Srcu-unlock, 2) ) | ( return_value(Srcu-down) ; (dep | rf)* ; parameter(Srcu-up, 2) ) Seem reasonable, or am I missing yet something else? Thanx, Paul