Re: [PATCH 1/6] arm64: scs: Store absolute SCS stack pointer value in thread_info

Mark Rutland
2020-05-18T11:37:23Z

On Fri, May 15, 2020 at 06:27:51PM +0100, Will Deacon wrote:
> Storing the SCS information in thread_info as a {base,offset} pair
> introduces an additional load instruction on the ret-to-user path,
> since the SCS stack pointer in x18 has to be converted back to an offset
> by subtracting the base.
>
> Replace the offset with the absolute SCS stack pointer value instead
> and avoid the redundant load.
>
> Signed-off-by: Will Deacon <will@kernel.org>

One trivial nit below, but regardless this looks sound to me, and I
certainly prefer having the absolute address rather than an offset, so:

Reviewed-by: Mark Rutland <mark.rutland@arm.com>

> diff --git a/kernel/scs.c b/kernel/scs.c
> index 9389c28f0853..5ff8663e4a67 100644
> --- a/kernel/scs.c
> +++ b/kernel/scs.c
> @@ -60,8 +60,7 @@ int scs_prepare(struct task_struct *tsk, int node)
> if (!s)
> return -ENOMEM;
>
> - task_scs(tsk) = s;
> - task_scs_offset(tsk) = 0;
> + task_scs(tsk) = task_scs_sp(tsk) = s;

I think this would be more legible as two statements:

| task_sys(tsk) = s;
| task_scs_sp(tsk) = s;

... as we usually save `foo = bar = baz` stuff for the start of a
function or within loop conditions.

Thanks,
Mark.

> scs_account(tsk, 1);
> return 0;
> }
> --
> 2.26.2.761.g0e0b3e54be-goog