[PATCH v4 5/7] sched/preempt: add PREEMPT_DYNAMIC using static keys

Sven Schnelle svens at linux.ibm.com
Fri Mar 18 01:49:25 PDT 2022


Hi Mark,

Mark Rutland <mark.rutland at arm.com> writes:

> diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> index 1739ca79613b..b145249ad91a 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -3,6 +3,7 @@
>  #include <linux/context_tracking.h>
>  #include <linux/entry-common.h>
>  #include <linux/highmem.h>
> +#include <linux/jump_label.h>
>  #include <linux/livepatch.h>
>  #include <linux/audit.h>
>  #include <linux/tick.h>
> @@ -392,7 +393,17 @@ void raw_irqentry_exit_cond_resched(void)
>  	}
>  }
>  #ifdef CONFIG_PREEMPT_DYNAMIC
> +#if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
>  DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
> +#elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> +DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> +void dynamic_irqentry_exit_cond_resched(void)
> +{
> +	if (!static_key_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> +		return;

I think that should be static_branch_unlikely()?

Also can we make dynamic_irqentry_exit_cond_resched static so that the
compiler will inline it? I played a bit with your changes on s390 and
noticed the the compiler will generate an empty function. Declaring it
static inlines it and saves one unnecessary function call.

Thanks!
Sven



More information about the linux-arm-kernel mailing list