Re: [PATCH 5/7] powerpc, arm64: Mark __switch_to() as __sched

From: Kees Cook
Date: Fri Oct 22 2021 - 12:15:35 EST


On Fri, Oct 22, 2021 at 05:09:38PM +0200, Peter Zijlstra wrote:
> Unlike most of the other architectures, PowerPC and ARM64 have
> __switch_to() as a C function which remains on the stack. Their
> respective __get_wchan() skips one stack frame unconditionally,
> without testing is_sched_functions().
>
> Mark them __sched such that we can forgo that special case.

I wonder if this change will improve any benchmarks? (i.e. this will
move __switch_to into the scheduler section, maybe improving icache?)

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> arch/arm64/kernel/process.c | 4 ++--
> arch/powerpc/kernel/process.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> --- a/arch/arm64/kernel/process.c
> +++ b/arch/arm64/kernel/process.c
> @@ -490,8 +490,8 @@ void update_sctlr_el1(u64 sctlr)
> /*
> * Thread switching.
> */
> -__notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
> - struct task_struct *next)
> +__notrace_funcgraph __sched
> +struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next)
> {
> struct task_struct *last;
>
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -1201,8 +1201,8 @@ static inline void restore_sprs(struct t
>
> }
>
> -struct task_struct *__switch_to(struct task_struct *prev,
> - struct task_struct *new)
> +__sched struct task_struct *__switch_to(struct task_struct *prev,
> + struct task_struct *new)
> {
> struct thread_struct *new_thread, *old_thread;
> struct task_struct *last;
>
>

--
Kees Cook