All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gabriele Monaco" <gmonaco@redhat.com>
To: "Karl Mehltretter" <kmehltretter@gmail.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Gabriele Monaco" <gmonaco@redhat.com>
Cc: "Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	"Nam Cao" <namcao@linutronix.de>,
	<linux-trace-kernel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rv: Normalize opid IRQ state to a boolean
Date: Wed, 11 Nov 2026 11:07:43 +0100	[thread overview]
Message-ID: <DMSARAAS9QNH.2HFOWZ6ZHCK3O@redhat.com> (raw)
In-Reply-To: <20261020035158.90190-1-kmehltretter@gmail.com>

On Tue Oct 20, 2026 at 5:51 AM CEST, Karl Mehltretter wrote:
> The opid hybrid-automaton guards compare irq_off with 1. However,
> irqs_disabled() only guarantees zero or nonzero. On 32-bit Arm,
> arch_irqs_disabled_flags() returns the CPSR I bit, 0x80. Consequently,
> valid events with interrupts disabled fail the guard and spuriously
> trigger the reactor.
>
> Normalize the value before returning it. Add a KUnit regression test
> that handles a need-resched event with local interrupts disabled.
> Without the normalization, the test triggers a reaction on Arm.
>
> Fixes: 2b406fdb33387 ("rv: Convert the opid monitor to a hybrid automaton")
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> ---

Looks reasonable, thanks!

Acked-by: Gabriele Monaco <gmonaco@redhat.com>

> Tested with an ARMv7 GCC 16 W=1 build and targeted SMP1 QEMU run:
> rv_test_opid and the RV KUnit suite pass.
>
>  kernel/trace/rv/monitors/opid/opid.c       | 2 +-
>  kernel/trace/rv/monitors/opid/opid_kunit.c | 6 ++++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/rv/monitors/opid/opid.c b/kernel/trace/rv/monitors/opid/opid.c
> index 9ae619f176fa1..a14532cc41778 100644
> --- a/kernel/trace/rv/monitors/opid/opid.c
> +++ b/kernel/trace/rv/monitors/opid/opid.c
> @@ -20,7 +20,7 @@
>  static u64 ha_get_env(struct ha_monitor *ha_mon, enum envs_opid env, u64 time_ns)
>  {
>  	if (env == irq_off_opid)
> -		return irqs_disabled();
> +		return !!irqs_disabled();
>  	else if (env == preempt_off_opid) {
>  		if (IS_ENABLED(CONFIG_PREEMPTION))
>  			return (preempt_count() & PREEMPT_MASK) > 0;
> diff --git a/kernel/trace/rv/monitors/opid/opid_kunit.c b/kernel/trace/rv/monitors/opid/opid_kunit.c
> index 3cb087a74241e..8aa1fb9c62344 100644
> --- a/kernel/trace/rv/monitors/opid/opid_kunit.c
> +++ b/kernel/trace/rv/monitors/opid/opid_kunit.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include <linux/kernel.h>
> +#include <linux/irqflags.h>
>  #include <linux/rv.h>
>  #include <rv/kunit.h>
>  #include <trace/events/sched.h>
> @@ -17,6 +18,11 @@ static void rv_test_opid(struct kunit *test)
>  	guard(migrate)();
>  	KUNIT_EXPECT_TRUE(test, preemptible());
>  
> +	/* Need resched with interrupts disabled */
> +	scoped_guard(irq)
> +		rv_opid_ops.handle_sched_need_resched(NULL, NULL, 0, TIF_NEED_RESCHED);
> +	RV_KUNIT_EXPECT_NO_REACTION(test, ctx);
> +
>  	/* Wakeup with preemption and interrupts enabled */
>  	RV_KUNIT_EXPECT_REACTION_HERE(test, ctx)
>  		rv_opid_ops.handle_sched_waking(NULL, NULL);
>
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222



      reply	other threads:[~2026-11-11 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  3:51 [PATCH] rv: Normalize opid IRQ state to a boolean Karl Mehltretter
2026-11-11 10:07 ` Gabriele Monaco [this message]

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=DMSARAAS9QNH.2HFOWZ6ZHCK3O@redhat.com \
    --to=gmonaco@redhat.com \
    --cc=kmehltretter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=namcao@linutronix.de \
    --cc=rostedt@goodmis.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.