Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp528739lqt; Thu, 6 Jun 2024 10:14:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYvYrAPU572ydqIUrForcVQ6QDZDk4oN9ZOt4G6P0v2sD+XP5ZPdd6O2M/EGlky7sgqdQm8r431fNrIKDBnJiP5dqxLHTpJCWTd7BTxA== X-Google-Smtp-Source: AGHT+IGNjC+dgHaxA7R21XwTh5/5L/Qtr5KP44X6orO6SoawFNFrDKcUSLVXkJn+ux1lAHr5PyCX X-Received: by 2002:a17:90a:d581:b0:2c0:238c:4ee6 with SMTP id 98e67ed59e1d1-2c2bc9ba465mr168255a91.2.1717694084989; Thu, 06 Jun 2024 10:14:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717694084; cv=pass; d=google.com; s=arc-20160816; b=iwo+nbZOWsyT9we0qwbWwFoZGw2zUzqMkiSqwO0tl75moScnPMuW5Tdaqh1cuFQ4Hn KJF/byJwGwC+C+x6t/5Eo0CUIgzUCa/RTTEqJI6NIKuxmSvfSw7yHM+w4hnBaIDf+lqF APV9jXLTYUbc54L54309OzbLS3CfEzufwuVIqkNpKFJzfheEhTl6EHnUxPXaGpdOioVt 7eKbnAI5UA5eR5HWQeKtRuwPwGt0ykrI2MIKc5DaphfZiutxA6KyOAVaHe0xmiUD5oKF SUx2YTTAavTRR2JmPkSGf6uOPAyHPQPyokew0rvazJuLoJzJclfmyNzpPV+pIfEHNi2q AH+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Xk+GqkPmmGDD8DRYEbgQF1Rv/76R4+59MrHnkQM4680=; fh=QLH454h22Mwkg2VINqOwRlAZNmVQ+x6WDFIUHixW9QI=; b=F45hbbQslC4WNNSWrKzVM6ihOL4q3X7wrXn4KZwK21wDwp7P5CA3aG+fcPb71BBJDf 14UvJmUCLh9fbtpyvzK2D5ovZedciMSMyNFIpafxhea46qkLC5Rb1oVJE5y8VQVRKUOo kBw0hWGOrko7eAgNObWwbf3WBPACZx52zXnmlcLGdUFFhD8ZDE5L66zgEq+4z95SrDjA IwI7zBWuw+WMBkVXmyPV6BPgc/BxCeHPJFlq9yLrTcABMmLRGEdDEVTdIyHBzKi7aFrk 2NHl7+aTRzjAWRGfeiaRZHqsSPiNRo0SvlAIU2qp+4v5LX1iOHiw2xuOhFxUl3CXlpBI TyeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LAeVzddM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-204769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c29c203590si1509151a91.28.2024.06.06.10.14.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:14:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LAeVzddM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-204769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DF2D028C104 for ; Thu, 6 Jun 2024 17:07:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01F1E198E8B; Thu, 6 Jun 2024 17:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LAeVzddM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1001B197A65 for ; Thu, 6 Jun 2024 17:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717693656; cv=none; b=HF5KVdYyIDdaa8vZ2Aw+Kgz9jMKdsouwzywMk3GJlDaa0ZmzdUbzSpLxykrRlss+9a4GyKr24rhK99XMkZJSBqAvq2SAzAG+hkwurcDk0/AkmjRlxNT9jT8Pe1+7ebUKAUOjMGyjPeojIBO5ub/W7JrwsipZXOvvA9XeRvqk99Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717693656; c=relaxed/simple; bh=rnxZ0Vr8B1WHr2j8vKiyhdo52e1nn+9bFC48qwBjGHY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S76b/8nLiR/8rVESOlCK1Uq/Itw52drNppVFp3sZS+ESM+0bVag4IU2+6adOTAG6UECy6qx+6xtsumTq7RKEwL8ltgN7vLV0qtv2KTODr9gysvy03zN3xQtFUjuJI4JGIUj4eEwaU0HnDFIPMM7KfZc4/Qu64ngQUk4WAf+XoQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LAeVzddM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7925CC2BD10; Thu, 6 Jun 2024 17:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717693655; bh=rnxZ0Vr8B1WHr2j8vKiyhdo52e1nn+9bFC48qwBjGHY=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=LAeVzddMwEr6BhZRSGxQn6Ivb/mVmHpO08XeXSYMykqhYmO4ceIejY7urgvEzqdUG oJn7y8S76JARjbHCgjLrj0AcoCH+605KtDPSQfnlHqpwZsVOQewSqq+IGEWP7rb2sY A3olXglV+rfctm72BmpWMeL4o1axETDGX8QKICzezJEoJBjjPd1nbVlvyZqRlpN1As E8K+2D6j23z3c6qpS9XoeVbAOK2wjnNnEzRU6Q4M0eAfuolqH8z92zkhHPc9LO1Aih eiZRrNEY9fb1ZxYBdKofOmSHimAu8Qp3whvUW4rpdygxfD8lpAj5owHsZc0bupQXYd 4FJUF+xRyUM9g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1E783CE3F34; Thu, 6 Jun 2024 10:07:35 -0700 (PDT) Date: Thu, 6 Jun 2024 10:07:35 -0700 From: "Paul E. McKenney" To: Alan Stern Cc: Andrea Parri , will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, dlustig@nvidia.com, joel@joelfernandes.org, linux-kernel@vger.kernel.org, hernan.poncedeleon@huaweicloud.com, jonas.oberhauser@huaweicloud.com Subject: Re: New locking test for the paulmckrcu/litmus github archive Message-ID: <64d944ff-b609-4977-a491-91ffc199a4cd@paulmck-laptop> Reply-To: paulmck@kernel.org References: <1d175b42-84b4-4a48-b1fb-ab6fd3566f75@rowland.harvard.edu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1d175b42-84b4-4a48-b1fb-ab6fd3566f75@rowland.harvard.edu> On Wed, Jun 05, 2024 at 02:40:05PM -0400, Alan Stern wrote: > On Wed, Jun 05, 2024 at 11:25:11AM -0700, Paul E. McKenney wrote: > > Thank you both! > > > > I queued and pushed the following commit, please let me know if it > > needs adjustment. > > > > Thanx, Paul > > > > ------------------------------------------------------------------------ > > > > commit fb65813a7a181cd86c50bb03f9df1f6a398fa22b > > Author: Alan Stern > > Date: Wed Jun 5 11:20:47 2024 -0700 > > > > manual/locked: Add single-threaded spin_is_locked() test > > > > This new litmus test demonstrates a bug in the current LKMM lock.cat file. > > This bug results in the following output: > > > > Test CoWWW+sil-lock-sil-unlock-sil Allowed > > States 0 > > No > > Witnesses > > Positive: 0 Negative: 0 > > Condition exists (0:r0=0 /\ 0:r1=1 /\ 0:r2=0) > > Observation CoWWW+sil-lock-sil-unlock-sil Never 0 0 > > Time CoWWW+sil-lock-sil-unlock-sil 0.01 > > Hash=cf12d53b4d1afec2e46bf9886af219c8 > > > > This is consistent with a deadlock. After the fix, there should be one > > execution that matches the "exists" clause, hence an "Always" result. > > The part about being consistent with a deadlock is not very important; > I'd omit it. Also, the second sentence is ambiguous; change it to: Good point, the deadlock is irrelevant. If I want to make that point, I can add a test that really does deadlock. ;-) > After the fix, there should be one execution that matches the > "exists" clause and no executions that don't match, hence an > "Always" result. I ended up with the following: This has no executions. After the fix, there is one execution that matches the "exists" clause and no executions that do not match, hence an "Always" result. The reason for explicitly stating "This has no executions" is that a lot of people never have seen such a thing. > > diff --git a/manual/locked/CoWWW+sil-lock-sil-unlock-sil.litmus b/manual/locked/CoWWW+sil-lock-sil-unlock-sil.litmus > > new file mode 100644 > > index 00000000..cee5abf4 > > --- /dev/null > > +++ b/manual/locked/CoWWW+sil-lock-sil-unlock-sil.litmus > > @@ -0,0 +1,24 @@ > > +C CoWWW+sil-lock-sil-unlock-sil.litmus > > Where does the "CoWWW" part of the name come from? If it refers to > coherence order and three writes, I'll point out that the litmus test > contains only two writes -- which would better be described as a lock > and an unlock. (Or are you counting the "write" that sets the lock's > initial value?) The CoWWW comes from me having been confused. The new filename is CoWW+sil-lock-sil-unlock-sil.litmus. Thank you for spotting this! > > + > > +(* > > + * Result: Always > > + * > > + * This tests the memory model's implementation of spin_is_locked(). > > + *) > > + > > +{} > > + > > +P0(spinlock_t *x) > > +{ > > + int r0; > > Oops! Apparently I managed not to convert the spaces on that line to a > tab. Can you take care of that? Done! Please see below for the updated commit. Thanx, Paul ------------------------------------------------------------------------ commit d4d216a08b4bedb8cdb0f57a224a4e331b35b931 Author: Alan Stern Date: Wed Jun 5 11:20:47 2024 -0700 manual/locked: Add single-threaded spin_is_locked() test This new litmus test demonstrates a bug in the current LKMM lock.cat file. This bug results in the following output: Test CoWW+sil-lock-sil-unlock-sil Allowed States 0 No Witnesses Positive: 0 Negative: 0 Condition exists (0:r0=0 /\ 0:r1=1 /\ 0:r2=0) Observation CoWWW+sil-lock-sil-unlock-sil Never 0 0 Time CoWWW+sil-lock-sil-unlock-sil 0.01 Hash=cf12d53b4d1afec2e46bf9886af219c8 This has no executions. After the fix, there is one execution that matches the "exists" clause and no executions that do not match, hence an "Always" result. Suggested-by: Andrea Parri Signed-off-by: Alan Stern Signed-off-by: Paul E. McKenney diff --git a/manual/locked/CoWW+sil-lock-sil-unlock-sil.litmus b/manual/locked/CoWW+sil-lock-sil-unlock-sil.litmus new file mode 100644 index 00000000..aadc4ceb --- /dev/null +++ b/manual/locked/CoWW+sil-lock-sil-unlock-sil.litmus @@ -0,0 +1,24 @@ +C CoWWW+sil-lock-sil-unlock-sil.litmus + +(* + * Result: Always + * + * This tests the memory model's implementation of spin_is_locked(). + *) + +{} + +P0(spinlock_t *x) +{ + int r0; + int r1; + int r2; + + r0 = spin_is_locked(x); + spin_lock(x); + r1 = spin_is_locked(x); + spin_unlock(x); + r2 = spin_is_locked(x); +} + +exists (0:r0=0 /\ 0:r1=1 /\ 0:r2=0)