Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Clement Leger <clement.leger@linux.dev>
To: Zhanpeng Zhang <zhangzhanpeng.jasper@bytedance.com>,
	pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	alex@ghiti.fr, himanshu.chauhan@oss.qualcomm.com,
	conor@kernel.org, anup.patel@oss.qualcomm.com
Cc: cuiyunhui@bytedance.com, atish.patra@linux.dev,
	peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	james.clark@linaro.org, will@kernel.org, tglx@kernel.org,
	corbet@lwn.net, rdunlap@infradead.org, shuah@kernel.org,
	yuanzhu@bytedance.com, yang.susheng@zte.com.cn,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v13 06/11] riscv: enable NMI-safe lockdep irqflags tracking
Date: Thu, 19 Nov 2026 14:46:39 +0100	[thread overview]
Message-ID: <69a099c3-082e-43b8-82f5-122d32df5eff@linux.dev> (raw)
In-Reply-To: <20261119120824.13969-19-zhangzhanpeng.jasper@bytedance.com>



On 11/19/26 13:08, Zhanpeng Zhang wrote:
> An SSE handler runs with interrupts masked, but can interrupt code whose
> lockdep hardirq state is enabled. Bare nmi_enter()/nmi_exit() do not
> update that state. Consequently, lockdep_assert_irqs_disabled() in the
> perf overflow path can report a warning despite interrupts being masked.
> 
> Select TRACE_IRQFLAGS_NMI_SUPPORT so lockdep can update its hardirq state
> inside an NMI. Pair this with irqentry_nmi_enter()/irqentry_nmi_exit() in
> the SSE wrapper: these helpers save the previous tracked state, mark
> interrupts disabled on entry and restore the tracked state on exit.
> Selecting the configuration option alone does not perform those updates.
> This follows the entry helpers used by the other RISC-V NMI-like traps.
> 
> Signed-off-by: Zhanpeng Zhang <zhangzhanpeng.jasper@bytedance.com>
> ---
>   arch/riscv/Kconfig          | 1 +
>   arch/riscv/kernel/sbi_sse.c | 7 ++++---
>   2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index d2db8f40c616..5501c02a07eb 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -225,6 +225,7 @@ config RISCV
>   	select SYSCTL_EXCEPTION_TRACE
>   	select THREAD_INFO_IN_TASK
>   	select TRACE_IRQFLAGS_SUPPORT
> +	select TRACE_IRQFLAGS_NMI_SUPPORT
>   	select UACCESS_MEMCPY if !MMU
>   	select VDSO_DATASTORE if MMU
>   	select VDSO_GETRANDOM if MMU && 64BIT
> diff --git a/arch/riscv/kernel/sbi_sse.c b/arch/riscv/kernel/sbi_sse.c
> index 032fcc07abcf..59e47a39589d 100644
> --- a/arch/riscv/kernel/sbi_sse.c
> +++ b/arch/riscv/kernel/sbi_sse.c
> @@ -2,7 +2,7 @@
>   /*
>    * Copyright (C) 2025 Rivos Inc.
>    */
> -#include <linux/nmi.h>
> +#include <linux/entry-common.h>
>   #include <linux/sched.h>
>   #include <linux/scs.h>
>   #include <linux/bitfield.h>
> @@ -36,9 +36,10 @@ void noinstr do_sse(struct sse_event_arch_data *arch_evt,
>   {
>   	struct riscv_sse_interrupted_context context = { regs, hstatus };
>   	struct riscv_sse_interrupted_context *previous;
> +	irqentry_state_t state;
>   	struct sbiret sret;
>   
> -	nmi_enter();
> +	state = irqentry_nmi_enter(regs);
>   	instrumentation_begin();
>   
>   	/* Retrieve missing GPRs from SBI */
> @@ -84,7 +85,7 @@ void noinstr do_sse(struct sse_event_arch_data *arch_evt,
>   
>   out:
>   	instrumentation_end();
> -	nmi_exit();
> +	irqentry_nmi_exit(regs, state);
>   }
>   
>   static void *alloc_to_stack_pointer(void *alloc)

Hi Zhanpeng,

Not sure if it was already suggested but I would fold that in the commit 
adding SSE itself.

Thanks,

Clément

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2026-11-19 13:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 12:08 [PATCH v13 00/11] riscv: add SBI Supervisor Software Events support Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 01/11] riscv: add SBI SSE extension definitions Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 02/11] riscv: add support for SBI Supervisor Software Events extension Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 03/11] riscv: sse: mask events during shutdown and kexec Zhanpeng Zhang
2026-11-19 13:44   ` Clement Leger
2026-11-19 12:08 ` [PATCH v13 04/11] drivers: firmware: add riscv SSE support Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 05/11] riscv: mm: avoid enabling interrupts for nofault page faults Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 06/11] riscv: enable NMI-safe lockdep irqflags tracking Zhanpeng Zhang
2026-11-19 13:46   ` Clement Leger [this message]
2026-11-19 12:08 ` [PATCH v13 07/11] perf: RISC-V: support callchains with SSE delivery Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 08/11] perf: RISC-V: add support for SSE event Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 09/11] MAINTAINERS: add RISC-V SSE maintainers and file coverage Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 10/11] selftests/riscv: add SSE test module Zhanpeng Zhang
2026-11-19 12:08 ` [PATCH v13 11/11] selftests/riscv: add perf user-stack SSE copy regression test Zhanpeng Zhang

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=69a099c3-082e-43b8-82f5-122d32df5eff@linux.dev \
    --to=clement.leger@linux.dev \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alex@ghiti.fr \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anup.patel@oss.qualcomm.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=atish.patra@linux.dev \
    --cc=conor@kernel.org \
    --cc=corbet@lwn.net \
    --cc=cuiyunhui@bytedance.com \
    --cc=himanshu.chauhan@oss.qualcomm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=peterz@infradead.org \
    --cc=pjw@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=yang.susheng@zte.com.cn \
    --cc=yuanzhu@bytedance.com \
    --cc=zhangzhanpeng.jasper@bytedance.com \
    /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