Re: [patch V2 10/28] sched/smt: Expose sched_smt_present static key

From: Konrad Rzeszutek Wilk
Date: Thu Nov 29 2018 - 09:45:13 EST


On Sun, Nov 25, 2018 at 07:33:38PM +0100, Thomas Gleixner wrote:
> Make the scheduler's 'sched_smt_present' static key globaly available, so
> it can be used in the x86 speculation control code.
>
> Provide a query function and a stub for the CONFIG_SMP=n case.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>

> ---
>
> v1 -> v2: Move SMT stuff to separate header. Unbreaks ia64 build
>
> ---
> include/linux/sched/smt.h | 18 ++++++++++++++++++
> kernel/sched/sched.h | 4 +---
> 2 files changed, 19 insertions(+), 3 deletions(-)
>
> --- /dev/null
> +++ b/include/linux/sched/smt.h
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _LINUX_SCHED_SMT_H
> +#define _LINUX_SCHED_SMT_H
> +
> +#include <linux/static_key.h>
> +
> +#ifdef CONFIG_SCHED_SMT
> +extern struct static_key_false sched_smt_present;
> +
> +static __always_inline bool sched_smt_active(void)
> +{
> + return static_branch_likely(&sched_smt_present);
> +}
> +#else
> +static inline bool sched_smt_active(void) { return false; }
> +#endif
> +
> +#endif
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -23,6 +23,7 @@
> #include <linux/sched/prio.h>
> #include <linux/sched/rt.h>
> #include <linux/sched/signal.h>
> +#include <linux/sched/smt.h>
> #include <linux/sched/stat.h>
> #include <linux/sched/sysctl.h>
> #include <linux/sched/task.h>
> @@ -936,9 +937,6 @@ static inline int cpu_of(struct rq *rq)
>
>
> #ifdef CONFIG_SCHED_SMT
> -
> -extern struct static_key_false sched_smt_present;
> -
> extern void __update_idle_core(struct rq *rq);
>
> static inline void update_idle_core(struct rq *rq)
>
>