From: John Kacur <jkacur@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
lkml <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Clark Williams <williams@redhat.com>
Subject: Re: [PATCH 14/26] trace: Convert various locks to raw_spinlock
Date: Wed, 13 Jan 2010 19:09:22 +0100 (CET) [thread overview]
Message-ID: <alpine.LFD.2.00.1001131907560.5665@localhost.localdomain> (raw)
In-Reply-To: <1263397315.28171.3827.camel@gandalf.stny.rr.com>
On Wed, 13 Jan 2010, Steven Rostedt wrote:
> On Wed, 2010-01-13 at 16:36 +0100, John Kacur wrote:
> >
> > On Wed, 13 Jan 2010, Steven Rostedt wrote:
>
> > >
> > Thanks for the review Steve and Frederic - I'll spin a new patch that
> > doesn't convert tracing_start_lock.
> >
> > However, let's give it some good testing in preempt-rt, because we may
> > have forgotten over time, why we converted these locks.
>
> Well, I think we just never unconverted them :-) I think we took the
> paranoid approach and converted all locks in the trace directory to raw.
> In fact, I think I even had a script to do it.
>
> -- Steve
Okay, here is the new version of the patch.
Frederic and Steve, can I have Acked-bys before I push to git?
Thanks
>From ee03cc607493e58f34bf93afa2b8a23da5510927 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Sun, 10 Jan 2010 03:09:48 +0100
Subject: [PATCH] trace: Convert reader_lock and max_trace_lock to raw_spinlocks
Convert reader_lock and max_trace_lock to raw_spinlock.
These locks cannot sleep in preempt-rt because they are called with
interrupts disabled. This should have zero-impact on mainline.
See also: 87654a70523a8c5baadcbbc07d80cbae8f912837
Signed-off-by: John Kacur <jkacur@redhat.com>
---
kernel/trace/ring_buffer.c | 53 +++++++++++++++++++++--------------------
kernel/trace/trace_irqsoff.c | 10 +++++--
2 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2326b04..56b073c 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -422,7 +422,8 @@ int ring_buffer_print_page_header(struct trace_seq *s)
struct ring_buffer_per_cpu {
int cpu;
struct ring_buffer *buffer;
- spinlock_t reader_lock; /* serialize readers */
+ /* Can be called with interrupts disabled via ftrace_dump */
+ raw_spinlock_t reader_lock; /* serialize readers */
arch_spinlock_t lock;
struct lock_class_key lock_key;
struct list_head *pages;
@@ -996,7 +997,7 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int cpu)
cpu_buffer->cpu = cpu;
cpu_buffer->buffer = buffer;
- spin_lock_init(&cpu_buffer->reader_lock);
+ raw_spin_lock_init(&cpu_buffer->reader_lock);
lockdep_set_class(&cpu_buffer->reader_lock, buffer->reader_lock_key);
cpu_buffer->lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
@@ -1193,7 +1194,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
struct list_head *p;
unsigned i;
- spin_lock_irq(&cpu_buffer->reader_lock);
+ raw_spin_lock_irq(&cpu_buffer->reader_lock);
rb_head_page_deactivate(cpu_buffer);
for (i = 0; i < nr_pages; i++) {
@@ -1210,7 +1211,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
rb_reset_cpu(cpu_buffer);
rb_check_pages(cpu_buffer);
- spin_unlock_irq(&cpu_buffer->reader_lock);
+ raw_spin_unlock_irq(&cpu_buffer->reader_lock);
}
static void
@@ -1221,7 +1222,7 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
struct list_head *p;
unsigned i;
- spin_lock_irq(&cpu_buffer->reader_lock);
+ raw_spin_lock_irq(&cpu_buffer->reader_lock);
rb_head_page_deactivate(cpu_buffer);
for (i = 0; i < nr_pages; i++) {
@@ -1235,7 +1236,7 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
rb_reset_cpu(cpu_buffer);
rb_check_pages(cpu_buffer);
- spin_unlock_irq(&cpu_buffer->reader_lock);
+ raw_spin_unlock_irq(&cpu_buffer->reader_lock);
}
/**
@@ -2735,9 +2736,9 @@ void ring_buffer_iter_reset(struct ring_buffer_iter *iter)
cpu_buffer = iter->cpu_buffer;
- spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
rb_iter_reset(iter);
- spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
+ raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
}
EXPORT_SYMBOL_GPL(ring_buffer_iter_reset);
@@ -3157,12 +3158,12 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
again:
local_irq_save(flags);
if (dolock)
- spin_lock(&cpu_buffer->reader_lock);
+ raw_spin_lock(&cpu_buffer->reader_lock);
event = rb_buffer_peek(cpu_buffer, ts);
if (event && event->type_len == RINGBUF_TYPE_PADDING)
rb_advance_reader(cpu_buffer);
if (dolock)
- spin_unlock(&cpu_buffer->reader_lock);
+ raw_spin_unlock(&cpu_buffer->reader_lock);
local_irq_restore(flags);
if (event && event->type_len == RINGBUF_TYPE_PADDING)
@@ -3187,9 +3188,9 @@ ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
unsigned long flags;
again:
- spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
event = rb_iter_peek(iter, ts);
- spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
+ raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
if (event && event->type_len == RINGBUF_TYPE_PADDING)
goto again;
@@ -3225,14 +3226,14 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)
cpu_buffer = buffer->buffers[cpu];
local_irq_save(flags);
if (dolock)
- spin_lock(&cpu_buffer->reader_lock);
+ raw_spin_lock(&cpu_buffer->reader_lock);
event = rb_buffer_peek(cpu_buffer, ts);
if (event)
rb_advance_reader(cpu_buffer);
if (dolock)
- spin_unlock(&cpu_buffer->reader_lock);
+ raw_spin_unlock(&cpu_buffer->reader_lock);
local_irq_restore(flags);
out:
@@ -3278,11 +3279,11 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)
atomic_inc(&cpu_buffer->record_disabled);
synchronize_sched();
- spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
arch_spin_lock(&cpu_buffer->lock);
rb_iter_reset(iter);
arch_spin_unlock(&cpu_buffer->lock);
- spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
+ raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
return iter;
}
@@ -3319,7 +3320,7 @@ ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts)
struct ring_buffer_per_cpu *cpu_buffer = iter->cpu_buffer;
unsigned long flags;
- spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
again:
event = rb_iter_peek(iter, ts);
if (!event)
@@ -3330,7 +3331,7 @@ ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts)
rb_advance_iter(iter);
out:
- spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
+ raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
return event;
}
@@ -3396,7 +3397,7 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
atomic_inc(&cpu_buffer->record_disabled);
- spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing)))
goto out;
@@ -3408,7 +3409,7 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
arch_spin_unlock(&cpu_buffer->lock);
out:
- spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
+ raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
atomic_dec(&cpu_buffer->record_disabled);
}
@@ -3446,10 +3447,10 @@ int ring_buffer_empty(struct ring_buffer *buffer)
cpu_buffer = buffer->buffers[cpu];
local_irq_save(flags);
if (dolock)
- spin_lock(&cpu_buffer->reader_lock);
+ raw_spin_lock(&cpu_buffer->reader_lock);
ret = rb_per_cpu_empty(cpu_buffer);
if (dolock)
- spin_unlock(&cpu_buffer->reader_lock);
+ raw_spin_unlock(&cpu_buffer->reader_lock);
local_irq_restore(flags);
if (!ret)
@@ -3480,10 +3481,10 @@ int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu)
cpu_buffer = buffer->buffers[cpu];
local_irq_save(flags);
if (dolock)
- spin_lock(&cpu_buffer->reader_lock);
+ raw_spin_lock(&cpu_buffer->reader_lock);
ret = rb_per_cpu_empty(cpu_buffer);
if (dolock)
- spin_unlock(&cpu_buffer->reader_lock);
+ raw_spin_unlock(&cpu_buffer->reader_lock);
local_irq_restore(flags);
return ret;
@@ -3678,7 +3679,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
if (!bpage)
goto out;
- spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
+ raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
reader = rb_get_reader_page(cpu_buffer);
if (!reader)
@@ -3753,7 +3754,7 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
ret = read;
out_unlock:
- spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
+ raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
out:
return ret;
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 2974bc7..7125f71 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -23,7 +23,11 @@ static int tracer_enabled __read_mostly;
static DEFINE_PER_CPU(int, tracing_cpu);
-static DEFINE_SPINLOCK(max_trace_lock);
+/*
+ * This lock is always taken with interrupts disabled,
+ * and therefore cannot sleep in preempt-rt.
+ */
+static DEFINE_RAW_SPINLOCK(max_trace_lock);
enum {
TRACER_IRQS_OFF = (1 << 1),
@@ -144,7 +148,7 @@ check_critical_timing(struct trace_array *tr,
if (!report_latency(delta))
goto out;
- spin_lock_irqsave(&max_trace_lock, flags);
+ raw_spin_lock_irqsave(&max_trace_lock, flags);
/* check if we are still the max latency */
if (!report_latency(delta))
@@ -167,7 +171,7 @@ check_critical_timing(struct trace_array *tr,
max_sequence++;
out_unlock:
- spin_unlock_irqrestore(&max_trace_lock, flags);
+ raw_spin_unlock_irqrestore(&max_trace_lock, flags);
out:
data->critical_sequence = max_sequence;
--
1.6.5.2
next prev parent reply other threads:[~2010-01-13 18:09 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-11 21:26 [PATCH 00/26] Convert locks that can't sleep in -rt " John Kacur
2010-01-11 21:26 ` [PATCH 01/26] xtime_lock: Convert atomic_seqlock to raw_seqlock, fix up all users John Kacur
2010-01-11 21:26 ` [PATCH 02/26] seqlock: Create raw_seqlock John Kacur
2010-01-11 21:26 ` [PATCH 03/26] x86: Convert tlbstate_lock to raw_spinlock John Kacur
2010-01-11 21:26 ` [PATCH 04/26] sched: Convert thread_group_cputimer lock " John Kacur
2010-01-11 21:26 ` [PATCH 05/26] x86: Convert ioapic_lock and vector_lock to raw_spinlocks John Kacur
2010-01-11 21:26 ` [PATCH 06/26] x86: Convert i8259A_lock to raw_spinlock John Kacur
2010-01-11 21:26 ` [PATCH 07/26] x86: Convert pci_config_lock " John Kacur
2010-01-11 21:26 ` [PATCH 08/26] i8253: Convert i8253_lock " John Kacur
2010-01-11 21:26 ` [PATCH 09/26] x86: Convert set_atomicity_lock " John Kacur
2010-01-11 21:26 ` [PATCH 10/26] ACPI: Convert c3_lock " John Kacur
2010-01-11 21:26 ` [PATCH 11/26] rtmutex: Convert wait_lock and pi_lock " John Kacur
2010-01-11 21:26 ` [PATCH 12/26] printk: Convert lock " John Kacur
2010-01-11 21:26 ` [PATCH 13/26] genirq: Convert locks to raw_spinlocks John Kacur
2010-01-11 21:26 ` [PATCH 14/26] trace: Convert various locks to raw_spinlock John Kacur
2010-01-11 21:26 ` [PATCH 15/26] clocksource: Convert watchdog_lock " John Kacur
2010-01-11 21:26 ` [PATCH 16/26] timer_stats: Convert to raw_spinlocks John Kacur
2010-01-11 21:26 ` [PATCH 17/26] x86: kvm: Convert i8254/i8259 locks to raw_spinlock John Kacur
2010-01-11 21:26 ` [PATCH 18/26] x86 - nmi: Convert nmi_lock " John Kacur
2010-01-11 21:26 ` [PATCH 19/26] cgroups: Convert cgroups release_list_lock " John Kacur
2010-01-11 21:26 ` [PATCH 20/26] proportions: Convert spinlocks to raw_spinlocks John Kacur
2010-01-11 21:26 ` [PATCH 21/26] percpu_counter: Convert to raw_spinlock John Kacur
2010-01-11 21:26 ` [PATCH 22/26] oprofile: " John Kacur
2010-01-11 21:26 ` [PATCH 23/26] vgacon: Convert vga console lock " John Kacur
2010-01-11 21:26 ` [PATCH 24/26] pci-access: Convert pci_lock " John Kacur
2010-01-11 21:26 ` [PATCH 25/26] kprobes: Convert to raw_spinlocks John Kacur
2010-01-11 21:26 ` [PATCH 26/26] softlockup: " John Kacur
2010-01-12 3:54 ` [PATCH 25/26] kprobes: " Frederic Weisbecker
2010-01-11 21:50 ` [PATCH 19/26] cgroups: Convert cgroups release_list_lock to raw_spinlock Paul Menage
2010-01-11 22:11 ` John Kacur
2010-01-12 3:39 ` [PATCH 14/26] trace: Convert various locks " Frederic Weisbecker
2010-01-13 15:28 ` Steven Rostedt
2010-01-13 15:36 ` John Kacur
2010-01-13 15:41 ` Steven Rostedt
2010-01-13 18:09 ` John Kacur [this message]
2010-01-17 13:00 ` Frederic Weisbecker
2010-01-12 3:24 ` [PATCH 00/26] Convert locks that can't sleep in -rt " Frederic Weisbecker
2010-01-12 3:49 ` Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.00.1001131907560.5665@localhost.localdomain \
--to=jkacur@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome