Re: [PATCH RESEND] arm64: sleep: factor sleep_save_stash slot lookup into a macro
From: Will Deacon
Date: Fri Nov 27 2026 - 13:42:10 EST
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@xxxxxxx>
> wrote:
> >On 10/4/26 14:05, Bradley Morgan wrote:
> >> On 19 September 2026 13:10:44 BST, Bradley Morgan <brads@xxxxxxxxxxxxxx>
> >> 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