OSDN Git Service

ring-buffer: Rewrite trace_recursive_(un)lock() to be simpler
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 22 Sep 2017 20:59:02 +0000 (16:59 -0400)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 4 Oct 2017 15:36:58 +0000 (11:36 -0400)
commit1a149d7d3f45d311da1f63473736c05f30ae8a75
treeb561bb443783aa9c5e8671a83a6558bceb77e42d
parent12ecef0cb12102d8c034770173d2d1363cb97d52
ring-buffer: Rewrite trace_recursive_(un)lock() to be simpler

The current method to prevent the ring buffer from entering into a recursize
loop is to use a bitmask and set the bit that maps to the current context
(normal, softirq, irq or NMI), and if that bit was already set, it is
considered a recursive loop.

New code is being added that may require the ring buffer to be entered a
second time in the current context. The recursive locking prevents that from
happening. Instead of mapping a bitmask to the current context, just allow 4
levels of nesting in the ring buffer. This matches the 4 context levels that
it can already nest. It is highly unlikely to have more than two levels,
thus it should be fine when we add the second entry into the ring buffer. If
that proves to be a problem, we can always up the number to 8.

An added benefit is that reading preempt_count() to get the current level
adds a very slight but noticeable overhead. This removes that need.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ring_buffer.c