ring-buffer updates for tip
Subsystems (2)
Steven Rostedt
maintainercover ring-buffer updates for tip
Ingo,
The following patches are in:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
branch: tip/devel
Steven Rostedt (2):
ring-buffer: fix deadlock from reader_lock in read_start
ring-buffer: no preempt for sched_clock
----
kernel/trace/ring_buffer.c | 37 ++++++++++++++++++++++++------------- 1 files changed, 24 insertions(+), 13 deletions(-)
Steven Rostedt
maintainerPATCH 1/2 ring-buffer: fix deadlock from reader_lock in read_start
Impact: deadlock fix in ring_buffer_read_start
The ring_buffer_iter_reset was called from ring_buffer_read_start where both grabbed the reader_lock.
This patch separates out the internals of ring_buffer_iter_reset to its own function so that both APIs may grab the reader_lock.
--- kernel/trace/ring_buffer.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-)
kernel/trace/ring_buffer.c +17 -12
@@ -1475,19 +1475,9 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)return overruns; } -/** -* ring_buffer_iter_reset - reset an iterator -* @iter: The iterator to reset -* -* Resets the iterator, so that it will start from the beginning -* again. -*/ -void ring_buffer_iter_reset (struct ring_buffer_iter *iter) +static void rb_iter_reset (struct ring_buffer_iter *iter) {struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; -unsigned long flags; - -spin_lock_irqsave (&cpu_buffer->reader_lock, flags);/* Iterator usage is expected to have record disabled */ if (list_empty (&cpu_buffer->reader_page->list)) {
@@ -1501,7 +1491,22 @@ void ring_buffer_iter_reset(struct ring_buffer_iter *iter) iter->read_stamp = cpu_buffer->read_stamp; else iter->read_stamp = iter->head_page->time_stamp; +} +/** +* ring_buffer_iter_reset - reset an iterator +* @iter: The iterator to reset +* +* Resets the iterator, so that it will start from the beginning +* again. +*/ +void ring_buffer_iter_reset (struct ring_buffer_iter *iter) +{ +struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer; +unsigned long flags; + +spin_lock_irqsave (&cpu_buffer->reader_lock, flags); +rb_iter_reset (iter);spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); }
@@ -1957,7 +1962,7 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)spin_lock_irqsave (&cpu_buffer->reader_lock, flags);__raw_spin_lock (&cpu_buffer->lock); -ring_buffer_iter_reset (iter); +rb_iter_reset (iter);__raw_spin_unlock (&cpu_buffer->lock);spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags);
Signature · 3 lines
1.5.6.5 --
Ingo Molnar
AppliedRe: [PATCH 1/2] ring-buffer: fix deadlock from reader_lock in read_start
Quoted 5 lines · Steven Rostedt
Impact: deadlock fix in
ring_buffer_read_startThe
ring_buffer_iter_resetwas called fromring_buffer_read_startwhere both grabbed thereader_lock.
Quoted 7 lines
This patch separates out the internals of
ring_buffer_iter_resetto its own function so that both APIs may grab thereader_lock.Signed-off-by Steven Rostedt <[email protected]>--- kernel/trace/ring_buffer.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-)
applied to tip/tracing/ring-buffer, thanks Steve!
Ingo
Steven Rostedt
maintainerPATCH 2/2 ring-buffer: no preempt for sched_clock
In reply to Steven RostedtImpact: disable preemption no calling sched_clock
The ring_buffer_time_stamp still uses sched_clock as its counter. But it is a bug to call it with preemption enabled. This requirement should not be pushed to the ring_buffer_time_stamp callers, so the ring_buffer_time_stamp needs to disable preemption when calling sched_clock.
--- kernel/trace/ring_buffer.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
kernel/trace/ring_buffer.c +7 -1
@@ -53,8 +53,14 @@ void tracing_off(void)/* FIXME!!! */ u64 ring_buffer_time_stamp (int cpu) { +u64 time; + +preempt_disable_notrace ();/* shift to debug/test normalization and TIME_EXTENTS */ -return sched_clock () <<DEBUG_SHIFT ; + time =sched_clock () <<DEBUG_SHIFT ; +preempt_enable_notrace (); + +return time; }void ring_buffer_normalize_time_stamp (int cpu,u64 *ts)
Signature · 3 lines
1.5.6.5 --
Ingo Molnar
AppliedRe: [PATCH 2/2] ring-buffer: no preempt for sched_clock
Quoted 8 lines · Steven Rostedt
Impact: disable preemption no calling
sched_clockThe
ring_buffer_time_stampstill usessched_clockas its counter. But it is a bug to call it with preemption enabled. This requirement should not be pushed to thering_buffer_time_stampcallers, so thering_buffer_time_stampneeds to disable preemption when callingsched_clock.
Quoted 4 lines
Signed-off-by Steven Rostedt <[email protected]>--- kernel/trace/ring_buffer.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
applied to tip/tracing/urgent, thanks Steve!
Ingo