From: "Paul E. McKenney" <paulmck@kernel.org>
To: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
Cc: Andrea Parri <parri.andrea@gmail.com>,
Alan Stern <stern@rowland.harvard.edu>,
Jonas Oberhauser <jonas.oberhauser@huawei.com>,
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, urezki@gmail.com,
quic_neeraju@quicinc.com, frederic@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] tools/memory-model: Make ppo a subrelation of po
Date: Wed, 1 Mar 2023 17:42:25 -0800 [thread overview]
Message-ID: <20230302014225.GP2948950@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <90270e25-e272-d3f7-0c1b-04e74d2af6f9@huaweicloud.com>
On Wed, Mar 01, 2023 at 11:52:09AM +0100, Jonas Oberhauser wrote:
>
>
> On 2/28/2023 4:40 PM, Paul E. McKenney wrote:
> > On Tue, Feb 28, 2023 at 09:49:07AM +0100, Jonas Oberhauser wrote:
> > >
> > > On 2/27/2023 11:21 PM, Paul E. McKenney wrote:
> > > > On Mon, Feb 27, 2023 at 09:13:01PM +0100, Jonas Oberhauser wrote:
> > > > > On 2/27/2023 8:40 PM, Andrea Parri wrote:
> > > > > > > The LKMM doesn't believe that a control or data dependency orders a
> > > > > > > plain write after a marked read. Hence in this test it thinks that P1's
> > > > > > > store to u0 can happen before the load of x1. I don't remember why we
> > > > > > > did it this way -- probably we just wanted to minimize the restrictions
> > > > > > > on when plain accesses can execute. (I do remember the reason for
> > > > > > > making address dependencies induce order; it was so RCU would work.)
> > > > > > >
> > > > > > > The patch below will change what the LKMM believes. It eliminates the
> > > > > > > positive outcome of the litmus test and the data race. Should it be
> > > > > > > adopted into the memory model?
> > > > > > (Unpopular opinion I know,) it should drop dependencies ordering, not
> > > > > > add/promote it.
> > > > > >
> > > > > > Andrea
> > > > > Maybe not as unpopular as you think... :)
> > > > > But either way IMHO it should be consistent; either take all the
> > > > > dependencies that are true and add them, or drop them all.
> > > > > In the latter case, RCU should change to an acquire barrier. (also, one
> > > > > would have to deal with OOTA in some yet different way).
> > > > >
> > > > > Generally my position is that unless there's a real-world benchmark with
> > > > > proven performance benefits of relying on dependency ordering, one should
> > > > > use an acquire barrier. I haven't yet met such a case, but maybe one of you
> > > > > has...
> > > > https://www.msully.net/thesis/thesis.pdf page 128 (PDF page 141).
> > > >
> > > > Though this is admittedly for ARMv7 and PowerPC.
> > > >
> > > Thanks for the link.
> > >
> > > It's true that on architectures that don't have an acquire load (and have to
> > > use a fence), the penalty will be bigger.
> > >
> > > But the more obvious discussion would be what constitutes a real-world
> > > benchmark : )
> > > In my experience you can get a lot of performance benefits out of optimizing
> > > barriers in code if all you execute is that code.
> > > But once you embed that into a real-world application, often 90%-99% of time
> > > spent will be in the business logic, not in the data structure.
> > >
> > > And then the benefits suddenly disappear.
> > > Note that a lot of barriers are a lot cheaper as well when there's no
> > > contention.
> > >
> > > Because of that, making optimization decisions based on microbenchmarks can
> > > sometimes lead to a very poor "time invested" vs "total product improvement"
> > > ratio.
> > All true, though that 2x and 4x should be worth something.
>
> I think the most egregious case we had (not barrier related, but cache
> related) was something like ~100x in specific benchmarks and then I think
> somewhere around 1% system-wide. I think the issue was that in the larger
> system, we couldn't keep the cache hot, so our greatly improved data
> locality was being diluted.
> But of course it always depends on how much that component actually
> contributes to the overall system performance.
> Which IMHO should be one of the measurements taken before starting to invest
> heavily into optimizations.
Agreed, it is all too easy for profound local optimizations to have
near-zero global effect.
> Surprisingly, many people don't want to do that. I think it's something
> about the misleading calculus of "2 months implementing the optimization + 2
> weeks building robust benchmarks & profiling infrastructure > 2 months
> implementing the optimization" instead of "2 weeks building robust
> benchmarks & profiling infrastructure + 0 months implementing a useless
> optimization < 2 months implementing the optimization", which seems to be
> the more common case.
Or, for that matter, having the investigation locate a five-minute change
that produces large benefits.
> > The real-world examples I know of involved garbage collectors, and the
> > improvement was said to be a few percent system-wide. But that was a
> > verbal exchange, so I don't have a citation for you.
>
> Thanks for the example, it sounds very reasonable (at least for platforms
> like PowerPC).
> GC has all the hallmarks of a good optimization target: measurable impact on
> system wide throughput and latency, and pointer chasing (=dependency
> ordering) being a hot part inside the algorithm.
I believe that the target was ARM. It was definitely not PowerPC.
But yes, GCs are indeed intense exercise for pointer chasing.
Thanx, Paul
next prev parent reply other threads:[~2023-03-02 1:43 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 13:52 Jonas Oberhauser
2023-02-24 15:32 ` Alan Stern
2023-02-24 18:37 ` Paul E. McKenney
2023-02-26 1:01 ` Paul E. McKenney
2023-02-26 2:29 ` Alan Stern
2023-02-26 3:03 ` Paul E. McKenney
2023-02-26 18:49 ` Paul E. McKenney
2023-02-26 3:09 ` Boqun Feng
2023-02-26 3:30 ` Alan Stern
2023-02-26 11:17 ` Jonas Oberhauser
2023-02-26 16:51 ` Alan Stern
2023-02-26 18:45 ` Paul E. McKenney
2023-02-26 19:32 ` Alan Stern
2023-02-27 14:03 ` Jonas Oberhauser
2023-02-27 16:16 ` Alan Stern
2023-02-27 16:50 ` Jonas Oberhauser
2023-02-27 18:41 ` Alan Stern
2023-02-27 19:40 ` Andrea Parri
2023-02-27 20:13 ` Jonas Oberhauser
2023-02-27 22:21 ` Paul E. McKenney
2023-02-28 8:49 ` Jonas Oberhauser
2023-02-28 15:40 ` Paul E. McKenney
2023-03-01 10:52 ` Jonas Oberhauser
2023-03-02 1:42 ` Paul E. McKenney [this message]
2023-02-26 2:58 ` Paul E. McKenney
2023-02-26 16:23 ` Joel Fernandes
2023-02-27 14:39 ` Jonas Oberhauser
2023-02-27 17:57 ` Joel Fernandes
2023-02-27 20:24 ` Jonas Oberhauser
2023-02-27 19:35 ` Andrea Parri
2023-02-28 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=20230302014225.GP2948950@paulmck-ThinkPad-P17-Gen-1 \
--to=paulmck@kernel.org \
--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=peterz@infradead.org \
--cc=quic_neeraju@quicinc.com \
--cc=stern@rowland.harvard.edu \
--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
all inboxes | Powered by JetHome®