From: Alan Stern <stern@rowland.harvard.edu>
To: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Andrea Parri <parri.andrea@gmail.com>,
Jonas Oberhauser <jonas.oberhauser@huawei.com>,
Peter Zijlstra <peterz@infradead.org>, will <will@kernel.org>,
"boqun.feng" <boqun.feng@gmail.com>, npiggin <npiggin@gmail.com>,
dhowells <dhowells@redhat.com>, "j.alglave" <j.alglave@ucl.ac.uk>,
"luc.maranget" <luc.maranget@inria.fr>, akiyks <akiyks@gmail.com>,
dlustig <dlustig@nvidia.com>, joel <joel@joelfernandes.org>,
urezki <urezki@gmail.com>,
quic_neeraju <quic_neeraju@quicinc.com>,
frederic <frederic@kernel.org>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [Patch 2/2] tools/memory-model: Provide exact SRCU semantics
Date: Wed, 25 Jan 2023 17:52:42 -0500 [thread overview]
Message-ID: <Y9Gyuj+2UFefUdJS@rowland.harvard.edu> (raw)
In-Reply-To: <c44183e7-44ae-4be3-bb47-517067a112b5@huaweicloud.com>
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
>
> Have you considered adding
> flag ~empty (srcu-rscs ; srcu-rscs^-1) \ id as mixed-srcu-cookie
I had not considered it. You'd have to do something pretty bizarre if
you wanted to trigger this warning, though. Like:
r1 = srcu_read_lock(s);
r2 = srcu_read_lock(s);
srcu_read_unlock(s, r1 + r2);
> Although I think one has to be intentionally trying to trick herd
> to be violating this. If herd could produce different cookies, this would be
> easy to detect just by the different-values flag you already have.
Unless you did: srcu_read_unlock(s, r1 + r2 * 0). :-)
> > (* Check for use of synchronize_srcu() inside an RCU critical section *)
> > flag ~empty rcu-rscs & (po ; [Sync-srcu] ; po) as invalid-sleep
> > @@ -80,11 +73,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
>
> Good catch! But why wasn't this necessary before? Is it only necessary now
> because the accesses became loads and stores (maybe to avoid data races?)
Exactly. Before this those events weren't memory accesses at all.
> > // 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.
> > +(* There should be no ordinary R or W accesses to spinlocks or SRCU structs *)
> > +let ALL-LOCKS = LKR | LKW | UL | LF | RU | Srcu-lock | Srcu-unlock | Sync-srcu
> > +flag ~empty [M \ IW \ ALL-LOCKS] ; loc ; [ALL-LOCKS] as mixed-lock-accesses
>
> Since this was pointed out by Boqun, would it be appropriate to mention him
> in the patch somehow?
True. After we settle everything else, I'll add something to that
effect.
Alan
next prev parent reply other threads:[~2023-01-25 22:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 20:19 [PATCH 0/2] SRCU changes for the Linux Kernel Memory Model Alan Stern
2023-01-25 20:20 ` [Patch 1/2] tools/memory-model: Update some warning labels Alan Stern
2023-01-25 20:21 ` [Patch 2/2] tools/memory-model: Provide exact SRCU semantics Alan Stern
2023-01-25 21:04 ` Jonas Oberhauser
2023-01-25 21:58 ` Paul E. McKenney
2023-01-25 22:52 ` Alan Stern [this message]
2023-01-26 11:30 ` Jonas Oberhauser
2023-01-26 16:02 ` Alan Stern
2023-01-26 16:31 ` Jonas Oberhauser
2023-01-26 17:35 ` Paul E. McKenney
2023-01-26 19:10 ` Alan Stern
2023-01-26 19:31 ` Paul E. McKenney
2023-02-01 10:31 ` Jonas Oberhauser
2023-01-25 20:35 ` [Patch 1/2] tools/memory-model: Update some warning labels Jonas Oberhauser
2023-01-25 22:01 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9Gyuj+2UFefUdJS@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=akiyks@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=dhowells@redhat.com \
--cc=dlustig@nvidia.com \
--cc=frederic@kernel.org \
--cc=j.alglave@ucl.ac.uk \
--cc=joel@joelfernandes.org \
--cc=jonas.oberhauser@huawei.com \
--cc=jonas.oberhauser@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=quic_neeraju@quicinc.com \
--cc=urezki@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox