Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5923759rwb; Tue, 17 Jan 2023 21:43:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXtzM6RNX23f3gaTbD7EMbxYFcKQ8wOZr155H5EsLrx3YYfbB0HvjG973BXiSFp94prR0VJd X-Received: by 2002:a05:6a20:4e26:b0:b8:a148:63b5 with SMTP id gk38-20020a056a204e2600b000b8a14863b5mr5725266pzb.3.1674020638681; Tue, 17 Jan 2023 21:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674020638; cv=none; d=google.com; s=arc-20160816; b=Q6z33IbCnUMU5y4CbV/0E2fRCUPTPznOebpefTlaGigbDSY0yLwuBQMoNS2w5gTHY9 GMQKrdMT5Y/RjAwPCw6GKufZc6Vp9DEBRVaDmPmeuQRYJk3N3+bIXQFf69EfANcKiXzM IDBu4ni7JDADX/m4dK2EhyetqR5QTLK9ZZTJb0Sqbo62CuA+/95XGyE4IggmU4UpXIWw eL0JJS+scqzybnTBdGSxlEfRRrPQCs3VEsNZOBvBukk7PkVFwhjfYDPcKug/vXQFD9LH ewe3c+aziI/io1iG/s7uIu1hcN81XnwFrr7/0fu6dRICykZgavY6Hpj2b+wfF1sa3Ji8 qgyg== 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=d6ny5pRyQ6HqjqdGpfeLlxVJMnfGrtcHO09x3659Iko=; b=Hl6ccDDxLanzAdNbyPkJ0XAaTH/r2ZHHFiCZOZPcF47MNMITs1CA/xVrHIZNdgzjfp 6pGm5lmoYUmplGY6Zljwc10TGUmE4xIi7MGNfF5hv/qKMtFQfUbOKDEVIP0Al0WV0fVO u2kde29cp98vKRlVhewlRl3Y/HczvHimBmt13yoQNZfcdnabOn6GlaWSBSkxoJ9ZJIpO KQZx+4/VpFlUh6w79JfbTnpckiGMIbERfaOU+s7EC9n/x4LLqyY7yvSt850Rnnt7sadT RAhSNcLDglFJ1UloDrsCR6TkcjjxI3q+/fRwJq9lzgylP6Hg6dpR+lJycOIFdxRLCt5A BxdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u7zl4SZ3; 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 r38-20020a63fc66000000b0049d0099742fsi33384823pgk.137.2023.01.17.21.43.52; Tue, 17 Jan 2023 21:43:58 -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=u7zl4SZ3; 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 S229517AbjARFRM (ORCPT + 46 others); Wed, 18 Jan 2023 00:17:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjARFRJ (ORCPT ); Wed, 18 Jan 2023 00:17:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D8C41B71 for ; Tue, 17 Jan 2023 21:17:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6DE32B8164A for ; Wed, 18 Jan 2023 05:17:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A031C433D2; Wed, 18 Jan 2023 05:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674019025; bh=SRbga6RoY7lmVd+U97s+sRx83s4mgT3IwJG8n1ZEg3I=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=u7zl4SZ3zR+DRK9oDs+o1IP1oCIi7LoMRzzWxXepfwzDQXU6UKrHScaxS3qKGSQ/i 6bQdikUqB9mTWzmkSgUOtv2JUoBhmXE1zd5sY2/OknzbORqOh6BFCm5aoKKrxPNEoy GKqn1oWdcuIPIIBVfbX++xyTrGLP90vDjU/dUm5repsRdID8/3LPThbVzNWKiWsBRQ UYSWcxJ96redTak7FPdMrMnhrZvuSiENRy8Ns5SnQRKFWaTx9FaGDK/Jno8cd6mTHn EYGkf6tgErXU8/TO7jEOBRdtjuOXB0SeV/ER8IqAl0/Yb9LFeE5vMWVc4I61+JBk2d on7PwKmqKpYpg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B0A1B5C1052; Tue, 17 Jan 2023 21:17:04 -0800 (PST) Date: Tue, 17 Jan 2023 21:17:04 -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: <20230118051704.GX2948950@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <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> <20230117174308.GK2948950@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 09:15:15PM -0500, Alan Stern wrote: > On Tue, Jan 17, 2023 at 09:43:08AM -0800, Paul E. McKenney wrote: > > On Tue, Jan 17, 2023 at 10:56:34AM -0500, Alan Stern wrote: > > > > 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. > > Maybe we don't. Please test the patch below; I think it will do what > you want -- and it doesn't rule out nesting. It works like a champ on manual/kernel/C-srcu*.litmus in the litmus repository on github, good show and thank you!!! I will make more tests, and am checking this against the rest of the litmus tests in the repo, but in the meantime would you be willing to have me add your Signed-off-by? Thanx, Paul > Alan > > > > Index: usb-devel/tools/memory-model/linux-kernel.bell > =================================================================== > --- usb-devel.orig/tools/memory-model/linux-kernel.bell > +++ usb-devel/tools/memory-model/linux-kernel.bell > @@ -57,20 +57,12 @@ flag ~empty Rcu-lock \ domain(rcu-rscs) > flag ~empty Rcu-unlock \ range(rcu-rscs) as unbalanced-rcu-locking > > (* Compute matching pairs of nested Srcu-lock and Srcu-unlock *) > -let srcu-rscs = let rec > - unmatched-locks = Srcu-lock \ domain(matched) > - and unmatched-unlocks = Srcu-unlock \ range(matched) > - and unmatched = unmatched-locks | unmatched-unlocks > - and unmatched-po = ([unmatched] ; po ; [unmatched]) & loc > - and unmatched-locks-to-unlocks = > - ([unmatched-locks] ; po ; [unmatched-unlocks]) & loc > - and matched = matched | (unmatched-locks-to-unlocks \ > - (unmatched-po ; unmatched-po)) > - in matched > +let srcu-rscs = ([Srcu-lock] ; data ; [Srcu-unlock]) & loc > > (* Validate nesting *) > flag ~empty Srcu-lock \ domain(srcu-rscs) as unbalanced-srcu-locking > -flag ~empty Srcu-unlock \ range(srcu-rscs) as unbalanced-srcu-locking > +flag ~empty Srcu-unlock \ range(srcu-rscs) as unbalanced-srcu-unlocking > +flag ~empty (srcu-rscs^-1 ; srcu-rscs) \ id as multiple-srcu-unlocks > > (* Check for use of synchronize_srcu() inside an RCU critical section *) > flag ~empty rcu-rscs & (po ; [Sync-srcu] ; po) as invalid-sleep > @@ -80,11 +72,11 @@ flag ~empty different-values(srcu-rscs) > > (* Compute marked and plain memory accesses *) > let Marked = (~M) | IW | Once | Release | Acquire | domain(rmw) | range(rmw) | > - LKR | LKW | UL | LF | RL | RU > + LKR | LKW | UL | LF | RL | RU | Srcu-lock | Srcu-unlock > let Plain = M \ Marked > > (* Redefine dependencies to include those carried through plain accesses *) > -let carry-dep = (data ; rfi)* > +let carry-dep = (data ; rfi ; [~Srcu-lock])* > let addr = carry-dep ; addr > let ctrl = carry-dep ; ctrl > let data = carry-dep ; data > Index: usb-devel/tools/memory-model/linux-kernel.def > =================================================================== > --- usb-devel.orig/tools/memory-model/linux-kernel.def > +++ usb-devel/tools/memory-model/linux-kernel.def > @@ -49,8 +49,8 @@ synchronize_rcu() { __fence{sync-rcu}; } > synchronize_rcu_expedited() { __fence{sync-rcu}; } > > // 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); } > synchronize_srcu(X) { __srcu{sync-srcu}(X); } > synchronize_srcu_expedited(X) { __srcu{sync-srcu}(X); } > >