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/[email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 0aa0e52 commit 7122923

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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)