From: Michael Ellerman <mpe@ellerman.id.au>
To: Nicholas Piggin <npiggin@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH v2] spin loop primitives for busy waiting
Date: Wed, 28 Jun 2017 16:33:52 +1000 [thread overview]
Message-ID: <877ezwd3jj.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20170529022223.14793-1-npiggin@gmail.com>
Nicholas Piggin <npiggin@gmail.com> writes:
> Current busy-wait loops are implemented by repeatedly calling cpu_relax()
> to give an arch option for a low-latency option to improve power and/or
> SMT resource contention.
>
> This poses some difficulties for powerpc, which has SMT priority setting
> instructions (priorities determine how ifetch cycles are apportioned).
> powerpc's cpu_relax() is implemented by setting a low priority then
> setting normal priority. This has several problems:
>
> - Changing thread priority can have some execution cost and potential
> impact to other threads in the core. It's inefficient to execute them
> every time around a busy-wait loop.
>
> - Depending on implementation details, a `low ; medium` sequence may
> not have much if any affect. Some software with similar pattern
> actually inserts a lot of nops between, in order to cause a few fetch
> cycles with the low priority.
>
> - The busy-wait loop runs with regular priority. This might only be a few
> fetch cycles, but if there are several threads running such loops, they
> could cause a noticable impact on a non-idle thread.
>
> Implement spin_begin, spin_end primitives that can be used around busy
> wait loops, which default to no-ops. And spin_cpu_relax which defaults to
> cpu_relax.
>
> This will allow architectures to hook the entry and exit of busy-wait
> loops, and will allow powerpc to set low SMT priority at entry, and
> normal priority at exit.
>
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>
> Since last time:
> - Fixed spin_do_cond with initial test as suggested by Linus.
> - Renamed it to spin_until_cond, which reads a little better.
>
> include/linux/processor.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 70 insertions(+)
> create mode 100644 include/linux/processor.h
I'm gonna merge this via the powerpc tree unless anyone objects.
cheers
next prev parent reply other threads:[~2017-06-28 6:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-29 2:22 [PATCH v2] spin loop primitives for busy waiting Nicholas Piggin
2017-06-28 6:33 ` Michael Ellerman [this message]
2017-07-02 11:01 ` [v2] " Michael Ellerman
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=877ezwd3jj.fsf@concordia.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).