Re: [RFC PATCH v2 06/13] entry: Skip inactive IRQ-return reschedule calls

From: sashiko-bot

Date: Tue Oct 27 2026 - 23:51:29 EST


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] entry: missing __always_inline on irqentry_exit_to_kernel_mode_preempt()
--

commit b2284e95ad33bdfe152568730c196eaa50875e40
Author: Karl Mehltretter <kmehltretter@xxxxxxxxx>

entry: Skip inactive IRQ-return reschedule calls

This commit checks preempt_count() in irqentry_exit_to_kernel_mode_preempt()
to avoid calling irqentry_exit_cond_resched() when preemption is disabled, and
marks arm64's preempt_count() as __always_inline for noinstr callers.

> diff --git a/include/linux/irq-entry-common.h b/include/linux/irq-entry-common.h
> index 289e308d2d46c..e1fd9155410c1 100644
> --- a/include/linux/irq-entry-common.h
> +++ b/include/linux/irq-entry-common.h
> @@ -503,7 +503,7 @@ static inline void irqentry_exit_to_kernel_mode_preempt(struct pt_regs *regs,
> if (regs_irqs_disabled(regs) || state.exit_rcu)
> return;
>
> - if (IS_ENABLED(CONFIG_PREEMPTION))
> + if (IS_ENABLED(CONFIG_PREEMPTION) && !preempt_count())
> irqentry_exit_cond_resched();
> }

[Severity: Medium]
Should irqentry_exit_to_kernel_mode_preempt() in
include/linux/irq-entry-common.h also be marked __always_inline (like its
companions irqentry_enter_from_kernel_mode(),
irqentry_exit_to_kernel_mode_after_preempt(), and
irqentry_exit_to_kernel_mode())?

On arm64, __el1_irq() and arm64_exit_to_kernel_mode() call noinstr function
arm64_exit_to_kernel_mode_preempt() in arch/arm64/kernel/entry-common.c, which
invokes irqentry_exit_to_kernel_mode_preempt() directly without
instrumentation_begin():

static void noinstr arm64_exit_to_kernel_mode_preempt(struct pt_regs *regs,
irqentry_state_t state)
{
irqentry_exit_to_kernel_mode_preempt(regs, state);
__arm64_exit_to_kernel_mode(regs, state);
}

While preempt_count() in arch/arm64/include/asm/preempt.h is changed to
__always_inline so Clang does not outline the new check into instrumentable
text, irqentry_exit_to_kernel_mode_preempt() itself remains static inline:

static inline void irqentry_exit_to_kernel_mode_preempt(struct pt_regs *regs,
irqentry_state_t state)

Because noinstr in include/linux/compiler_types.h strips sanitizer and
profiling attributes (__no_kcsan, __no_sanitize_address, __no_profile,
__no_sanitize_coverage, __no_sanitize_memory) whereas inline only adds
notrace, building with Clang and CONFIG_KASAN=y, CONFIG_KCSAN=y, or
CONFIG_GCOV_KERNEL=y can cause LLVM to refuse to inline a non-__always_inline
callee due to mismatched attributes.

If that happens, couldn't Clang inline preempt_count() into
irqentry_exit_to_kernel_mode_preempt() and then outline
irqentry_exit_to_kernel_mode_preempt() itself into instrumentable .text,
allowing sanitizer instrumentation or kprobes to run on the noinstr return
path even when state.exit_rcu or regs_irqs_disabled(regs) is true?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20261028033127.82193-1-kmehltretter@xxxxxxxxx?part=6