On Mon, 20 Jan 2025 18:56:56 -0500
Steven Rostedt <rost...@goodmis.org> wrote:

> From: Steven Rostedt <rost...@goodmis.org>
> 
> Some architectures can not safely do atomic64 operations in NMI context.
> Since the ring buffer relies on atomic64 operations to do its time
> keeping, if an event is requested in NMI context, reject it for these
> architectures.
> 

Looks good to me.

Reviewed-by: Masami Hiramatsu (Google) <mhira...@kernel.org>

> Cc: sta...@vger.kernel.org
> Fixes: c84897c0ff592 ("ring-buffer: Remove 32bit timestamp logic")
> Closes: 
> https://lore.kernel.org/all/86fb4f86-a0e4-45a2-a2df-3154acc4f...@gaisler.com/
> Reported-by: Ludwig Rydberg <ludwig.rydb...@gaisler.com>
> Signed-off-by: Steven Rostedt (Google) <rost...@goodmis.org>
> ---
>  kernel/trace/ring_buffer.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 6d61ff78926b..b8e0ae15ca5b 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -4398,8 +4398,13 @@ rb_reserve_next_event(struct trace_buffer *buffer,
>       int nr_loops = 0;
>       int add_ts_default;
>  
> -     /* ring buffer does cmpxchg, make sure it is safe in NMI context */
> -     if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) &&
> +     /*
> +      * ring buffer does cmpxchg as well as atomic64 operations
> +      * (which some archs use locking for atomic64), make sure this
> +      * is safe in NMI context
> +      */
> +     if ((!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) ||
> +          IS_ENABLED(CONFIG_GENERIC_ATOMIC64)) &&
>           (unlikely(in_nmi()))) {
>               return NULL;
>       }
> -- 
> 2.45.2
> 
> 


-- 
Masami Hiramatsu (Google) <mhira...@kernel.org>

Reply via email to