From: Paul Mackerras <paulus@ozlabs.org>
To: Ram Pai <linuxram@us.ibm.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [RFC PATCH] powerpc/powernv: Provide a way to force a core into SMT4 mode
Date: Sat, 27 Jan 2018 13:34:11 +1100 [thread overview]
Message-ID: <20180127023411.GA5360@fergus.ozlabs.ibm.com> (raw)
In-Reply-To: <20180127010610.GA5428@ram.oc3035372033.ibm.com>
On Fri, Jan 26, 2018 at 05:06:10PM -0800, Ram Pai wrote:
> On Thu, Jan 25, 2018 at 04:05:12PM +1100, Paul Mackerras wrote:
> > POWER9 processors up to and including "Nimbus" v2.2 have hardware
> > bugs relating to transactional memory and thread reconfiguration.
> > One of these bugs has a workaround which is to get the core into
> > SMT4 state temporarily. This workaround is only needed when
> > running bare-metal.
>
> ..snip..
> > */
> > _GLOBAL(power9_idle_stop)
> > std r3, PACA_REQ_PSSCR(r13)
>
> this instruction can go a little later and save a few cycles, in the
> case it need not have to stop ?
>
> > + sync
> > + lwz r5, PACA_DONT_STOP(r13)
> > + cmpwi r5, 0
> > + bne 1f
>
> I mean 'std r3, ...' can move here.
That would introduce a race condition, where this thread would miss
seeing the other thread's store to paca->dont_stop, and the other
thread would miss seeing this thread's store to paca->requested_psscr.
> > + /* order setting dont_stop vs testing requested_psscr */
> > + mb();
> > + for (thr = 0; thr < threads_per_core; ++thr) {
> > + if (!tpaca[thr].requested_psscr)
> > + ++awake_threads;
> > + else
> > + poke_threads |= (1 << thr);
>
> ppc_msgsnd(...) can be called here in the else part?
It could, but I wanted to avoid disturbing the other threads with the
msgsnd if it was not necessary. Hence the second loop to do the
msgsnds once we have determined that we really need to do them.
>
> > + }
> > +
> > + /* If at least 3 threads are awake, the core is in SMT4 already */
>
> small nitpick -- this comment mentions SMT4 and 3 threads. But the code
> is generically applicable to SMTn and (n-1) threads.
Sure - it's easier to understand a concrete example than something
more general, that's why the comment is about the specific use case
not the general capability of the code.
> > + if (awake_threads < threads_per_core - 1) {
>
>
> > + /* We have to wake some threads; we'll use msgsnd */
> > + for (thr = 0; thr < threads_per_core; ++thr) {
> > + if (poke_threads & (1 << thr))
> > + ppc_msgsnd(PPC_DBELL_MSGTYPE, 0,
> > + tpaca[thr].hw_cpu_id);
> > + }
>
> and this loop can be deleted, which inturn can leads to further optimizations.
... at the cost of other threads taking doorbell interrupts
unnecessarily. I thought it better to put more burden on the thread
needing this synchronization and less on the other threads (on
average).
Paul.
prev parent reply other threads:[~2018-01-27 2:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 5:05 [RFC PATCH] powerpc/powernv: Provide a way to force a core into SMT4 mode Paul Mackerras
2018-01-27 0:27 ` Nicholas Piggin
2018-01-27 2:45 ` Paul Mackerras
2018-01-27 4:47 ` Nicholas Piggin
2018-01-27 1:06 ` Ram Pai
2018-01-27 2:34 ` Paul Mackerras [this message]
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=20180127023411.GA5360@fergus.ozlabs.ibm.com \
--to=paulus@ozlabs.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=linuxram@us.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).