mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Bradley Morgan <brads@mainlining.org>
Cc: Vladimir Murzin <vladimir.murzin@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	leo.bras@arm.com
Subject: Re: [PATCH RESEND] arm64: sleep: factor sleep_save_stash slot lookup into a macro
Date: Fri, 27 Nov 2026 18:42:00 +0000	[thread overview]
Message-ID: <awnO-FqQDd97ydiP@willie-the-truck> (raw)
In-Reply-To: <2442108F-EE55-40AB-A33C-DEFE0364F704@mainlining.org>

On Wed, Oct 07, 2026 at 03:57:35PM +0100, Bradley Morgan wrote:
> On 7 October 2026 07:45:18 BST, Vladimir Murzin <vladimir.murzin@arm.com>
> wrote:
> >On 10/4/26 14:05, Bradley Morgan wrote:
> >> On 19 September 2026 13:10:44 BST, Bradley Morgan <brads@mainlining.org>
> >> wrote:
> >>> Both __cpu_suspend_enter() and _cpu_resume() open code the same
> >>> MPIDR_EL1 hash lookup to find the current CPU's slot in
> >>> sleep_save_stash. Factor it into a get_sleep_stash_slot
> >>> macro.
> >>>
> >>> Since that macro would be the only remaining user of
> >>> compute_mpidr_hash, inline the hash computation into
> >>> get_sleep_stash_slot and just remove compute_mpidr_hash
> >>> altogether.
> >> +CC more people, polite ping on this patch guys! :)
> >> 
> >
> >I'm not sure it makes the code clearer:
> >
> >- I see that Will suggested inlining compute_mpidr_hash, but to
> >  my taste, a dedicated helper is easier to comprehend.
> 
> Hmm... It's a bit 50/50 to me.
> 
> >
> >- The new get_sleep_stash_slot uses a mix of fixed and
> >  parameterised registers, which forces the reader to look at how
> >  the registers are used. Also using fixed registers shifts the
> >  burden of making them available to the user of the macro.
> 
> Well, will, any justification?
> 
> The macro at the moment only has one user, so it's pointless to account
> forusers at the moment..

I tend to agree. This macro is private to sleep.S, which is already
doing unholy things with the CPU registers and I don't think named
register parameters are really a concern. In fact, I think the only
reason we need to do any of this hashing in asm is so that we can
retrieve our stack pointer on the resume path.

I would, however, agree with Vladimir that using a mixture of named
register parameters and fixed registers is confusing. So I'd probably
just make the thing behave like a function and unconditionally return the
slot in x0. In fact, we probably could make it a real function if we
tail-called it on the resume path and rewrote the hashing on the suspend
path in C, but I'm not sure whether that's better or not.

Will

      reply	other threads:[~2026-11-27 18:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 12:10 Bradley Morgan
2026-10-04 13:05 ` Bradley Morgan
2026-10-07  6:45   ` Vladimir Murzin
2026-10-07 14:57     ` Bradley Morgan
2026-11-27 18:42       ` 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=awnO-FqQDd97ydiP@willie-the-truck \
    --to=will@kernel.org \
    --cc=brads@mainlining.org \
    --cc=catalin.marinas@arm.com \
    --cc=leo.bras@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=paulmck@kernel.org \
    --cc=vladimir.murzin@arm.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

all inboxes | Powered by JetHome®