linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] arm64: lse: use register variables instead of -ffixed, -fcall flags
Date: Mon, 13 Aug 2018 18:28:21 +0100	[thread overview]
Message-ID: <20180813172820.GA25548@arm.com> (raw)
In-Reply-To: <CANA+-vDPp=tSBq_2U7T1RD8BpDs6DWm=pkVp73HGdehbhcc-tQ@mail.gmail.com>

On Fri, Aug 10, 2018 at 03:04:55PM -0700, Tri Vo wrote:
> On Fri, Aug 10, 2018 at 2:46 AM, Will Deacon <will.deacon@arm.com> wrote:
> > On Thu, Aug 09, 2018 at 07:07:51PM -0700, Tri Vo wrote:
> >> -ffixed, -fcall-used, -fcall-saved flags are used to build LL/SC
> >> fallback atomic implementations in such a way that:
> >> 1. LSE implementations only assume x16, x17, x30 to be clobbered by a
> >> function call to LL/SC fallbacks.
> >> 2. LL/SC fallbacks are responsible for saving/restoring the rest of the
> >> GPRs.
> >> 3. LL/SC fallbacks always prefer to allocate in x16, x17 since there is
> >> no need to save/restore them.
> >>
> >> Same result can be achieved without -ffixed, -fcall-used, -fcall-saved
> >> flags by explicitly telling the compiler where to allocate each variable
> >> in LL/SC atomic implementations. This patch makes all functions use x16,
> >> x17 registers. 'fetch' variants of the functions need one more scratch
> >> register, so we allocate one from the PCS's set of callee-saved
> >> registers (in this case x19).
> >>
> >> With this patch:
> >> 1. the desired register allocation is reflected in the code rather than
> >> in compiler flags.
> >> 2. LSE atomic support can be built with both clang and gcc.
> >> 3. Number of preserved registers in LL/SC fallbacks is unchanged.
> >>
> >> The tradeoff is that the compiler loses flexibility in allocating
> >> registers for inline LL/SC atomic implementations.
> >
> > This impacts the atomics code when !CONFIG_LSE, and causes the fetch*
> > variants to spill x19 in most cases.
> 
> Is it OK if I wrap that x19 register variable in an #ifdef so it's
> only allocated to x19 when CONFIG_LSE and is allocated normally for
> !CONFIG_LSE? That should keep the number of spills unchanged for both
> inline and out-of-line implementations.

I would much prefer you to:

> > Please just fix clang, or augment the lseinstr check in our Makefile to
> > check for ffixed support as well.

Will

      reply	other threads:[~2018-08-13 17:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-10  2:07 [RFC PATCH] arm64: lse: use register variables instead of -ffixed, -fcall flags Tri Vo
2018-08-10  9:46 ` Will Deacon
2018-08-10 22:04   ` Tri Vo
2018-08-13 17:28     ` Will Deacon [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=20180813172820.GA25548@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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).