[PATCH 2/3] arm64: Always inline preempt count and reschedule checks

Hongyan Xia hongyan.xia at transsion.com
Wed Nov 25 04:00:29 PST 2026


On 11/16/2026 3:54 PM, Karl Mehltretter wrote:
> The preempt count and reschedule checks are plain inline functions,
> which permits out-of-line copies in instrumentable text. The checked
> notrace helpers added by the following patch use preempt_count(), while
> preempt_enable_notrace() uses should_resched() with
> CONFIG_DEBUG_PREEMPT and __preempt_count_dec_and_test() without it.
> 
> Force all three operations inline so noinstr callers keep them in their
> own section.
> 
> Signed-off-by: Karl Mehltretter <kmehltretter at gmail.com>
> ---
>   arch/arm64/include/asm/preempt.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h
> index f3a5c2cd1936d..805f7b33baf09 100644
> --- a/arch/arm64/include/asm/preempt.h
> +++ b/arch/arm64/include/asm/preempt.h
> @@ -7,7 +7,7 @@
>   #define PREEMPT_NEED_RESCHED	BIT(32)
>   #define PREEMPT_ENABLED	(PREEMPT_NEED_RESCHED)
>   
> -static inline int preempt_count(void)
> +static __always_inline int preempt_count(void)
>   {
>   	return READ_ONCE(current_thread_info()->preempt.count);
>   }
> @@ -75,13 +75,13 @@ static inline int __preempt_count_sub_return(int val)
>   	return pc;
>   }
>   
> -static inline bool should_resched(int preempt_offset)
> +static __always_inline bool should_resched(int preempt_offset)
>   {
>   	u64 pc = READ_ONCE(current_thread_info()->preempt_count);
>   	return unlikely(pc == preempt_offset);
>   }
>   
> -static inline bool __preempt_count_dec_and_test(void)
> +static __always_inline bool __preempt_count_dec_and_test(void)
>   {
>   	/*
>   	 * We must load the combined 'preempt_count' after decrementing

Reviewed-by: Hongyan Xia <hongyan.xia at transsion.com>


More information about the linux-arm-kernel mailing list