Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Karl Mehltretter" <kmehltretter@gmail.com>
Cc: linux-trace-kernel@vger.kernel.org,
	linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 06/13] entry: Skip inactive IRQ-return reschedule calls
Date: Wed, 28 Oct 2026 03:51:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-187447@kernel.org> (raw)
In-Reply-To: <20261028033127.82193-7-kmehltretter@gmail.com>

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@gmail.com>

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@gmail.com?part=6

  reply	other threads:[~2026-10-28  3:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  3:31 [RFC PATCH v2 00/13] entry: Classify very early hardirq entry and return-tail callbacks Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 01/13] arm64: Always inline raw preempt count updates Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 02/13] arm64: percpu: Annotate __kern_my_cpu_offset() as '__always_inline' Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 03/13] sched: Split preempt-count bookkeeping from raw updates Karl Mehltretter
2026-10-29  9:32   ` Peter Zijlstra
2026-10-28  3:31 ` [RFC PATCH v2 04/13] lockdep: Use raw access for pinned hardirq state Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 05/13] entry: Add the pre-counted ordinary-hardirq entry/exit contract Karl Mehltretter
2026-10-28  3:54   ` sashiko-bot
2026-10-28  3:31 ` [RFC PATCH v2 06/13] entry: Skip inactive IRQ-return reschedule calls Karl Mehltretter
2026-10-28  3:51   ` sashiko-bot [this message]
2026-10-28  3:31 ` [RFC PATCH v2 07/13] context_tracking: Split IRQ-exit preparation from the EQS transition Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 08/13] lockdep: Prepare IRQ-on state from a hardirq return tail Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 09/13] entry: Carry ordinary-hardirq provenance through kernel return Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 10/13] entry: Classify ordinary hardirq return-tail work as hardirq context Karl Mehltretter
2026-10-28  3:57   ` sashiko-bot
2026-10-28  3:31 ` [RFC PATCH v2 11/13] arm64: Use the pre-counted hardirq lifecycle Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 12/13] Documentation: entry: Describe " Karl Mehltretter
2026-10-28  3:31 ` [RFC PATCH v2 13/13] locking/selftest: Exercise hardirq return-tail preparation Karl Mehltretter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-187447@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kmehltretter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox