Skip to content

Commit 7122923

Browse files
committed
ring-buffer: Do not record in NMI if the arch does not support cmpxchg in NMI
As the ring buffer recording requires cmpxchg() to work, if the architecture does not support cmpxchg in NMI, then do not do any recording within an NMI. Link: https://lore.kernel.org/linux-trace-kernel/20231213175403.6fc18540@gandalf.local.home Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 0aa0e52 commit 7122923

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

kernel/trace/ring_buffer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,6 +3674,12 @@ rb_reserve_next_event(struct trace_buffer *buffer,
36743674
int nr_loops = 0;
36753675
int add_ts_default;
36763676

3677+
/* ring buffer does cmpxchg, make sure it is safe in NMI context */
3678+
if (!IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) &&
3679+
(unlikely(in_nmi()))) {
3680+
return NULL;
3681+
}
3682+
36773683
rb_start_commit(cpu_buffer);
36783684
/* The commit page can not change after this */
36793685

0 commit comments

Comments
 (0)