From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: mingo@elte.hu, David Miller <davem@davemloft.net>,
acme@redhat.com, paulus@samba.org, Mike Galbraith <efault@gmx.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@l>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
linux-arch@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [patch 2/3] perf: Use local_irq_save_nmi()
Date: Tue, 06 Apr 2010 15:28:09 +0200 [thread overview]
Message-ID: <20100406133140.972113669@chello.nl> (raw)
In-Reply-To: 20100406132807.698467930@chello.nl
[-- Attachment #1: perf-fix-perf_output_lock.patch --]
[-- Type: text/plain, Size: 2527 bytes --]
Patch 8bb39f9 (perf: Fix 'perf sched record' deadlock) introduced a
local_irq_save() in NMI context, convert that to local_irq_save_nmi()
and move the IRQ disable into perf_output_lock/unlock().
The former is needed because we now disallow local_irq_disable() from
NMI context due to some arch limitations.
The second is because its really about IRQ lock inversion with that
funny output lock, and perf_event_task_output() is only one site that
could trigger it.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
---
include/linux/perf_event.h | 1 +
kernel/perf_event.c | 17 ++++++-----------
2 files changed, 7 insertions(+), 11 deletions(-)
Index: linux-2.6/include/linux/perf_event.h
===================================================================
--- linux-2.6.orig/include/linux/perf_event.h
+++ linux-2.6/include/linux/perf_event.h
@@ -758,6 +758,7 @@ struct perf_output_handle {
struct perf_mmap_data *data;
unsigned long head;
unsigned long offset;
+ unsigned long flags;
int nmi;
int sample;
int locked;
Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -2848,6 +2848,10 @@ static void perf_output_lock(struct perf
struct perf_mmap_data *data = handle->data;
int cur, cpu = get_cpu();
+ /*
+ * Since this is a lock we need to be IRQ-safe
+ */
+ local_irq_save_nmi(handle->flags);
handle->locked = 0;
for (;;) {
@@ -2906,6 +2910,7 @@ again:
if (atomic_xchg(&data->wakeup, 0))
perf_output_wakeup(handle);
out:
+ local_irq_restore_nmi(handle->flags);
put_cpu();
}
@@ -3385,19 +3390,10 @@ static void perf_event_task_output(struc
unsigned long flags;
int size, ret;
- /*
- * If this CPU attempts to acquire an rq lock held by a CPU spinning
- * in perf_output_lock() from interrupt context, it's game over.
- */
- local_irq_save(flags);
-
size = task_event->event_id.header.size;
ret = perf_output_begin(&handle, event, size, 0, 0);
-
- if (ret) {
- local_irq_restore(flags);
+ if (ret)
return;
- }
task_event->event_id.pid = perf_event_pid(event, task);
task_event->event_id.ppid = perf_event_pid(event, current);
@@ -3408,7 +3404,6 @@ static void perf_event_task_output(struc
perf_output_put(&handle, task_event->event_id);
perf_output_end(&handle);
- local_irq_restore(flags);
}
static int perf_event_task_match(struct perf_event *event)
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: mingo@elte.hu, David Miller <davem@davemloft.net>,
acme@redhat.com, paulus@samba.org, Mike Galbraith <efault@gmx.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
linux-arch@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [patch 2/3] perf: Use local_irq_save_nmi()
Date: Tue, 06 Apr 2010 15:28:09 +0200 [thread overview]
Message-ID: <20100406133140.972113669@chello.nl> (raw)
Message-ID: <20100406132809.Kv4xHR1kTM8snYgk4l0X7mG9qQFQkqE1_NXrCYk0FeQ@z> (raw)
In-Reply-To: 20100406132807.698467930@chello.nl
[-- Attachment #1: perf-fix-perf_output_lock.patch --]
[-- Type: text/plain, Size: 2529 bytes --]
Patch 8bb39f9 (perf: Fix 'perf sched record' deadlock) introduced a
local_irq_save() in NMI context, convert that to local_irq_save_nmi()
and move the IRQ disable into perf_output_lock/unlock().
The former is needed because we now disallow local_irq_disable() from
NMI context due to some arch limitations.
The second is because its really about IRQ lock inversion with that
funny output lock, and perf_event_task_output() is only one site that
could trigger it.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
---
include/linux/perf_event.h | 1 +
kernel/perf_event.c | 17 ++++++-----------
2 files changed, 7 insertions(+), 11 deletions(-)
Index: linux-2.6/include/linux/perf_event.h
===================================================================
--- linux-2.6.orig/include/linux/perf_event.h
+++ linux-2.6/include/linux/perf_event.h
@@ -758,6 +758,7 @@ struct perf_output_handle {
struct perf_mmap_data *data;
unsigned long head;
unsigned long offset;
+ unsigned long flags;
int nmi;
int sample;
int locked;
Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -2848,6 +2848,10 @@ static void perf_output_lock(struct perf
struct perf_mmap_data *data = handle->data;
int cur, cpu = get_cpu();
+ /*
+ * Since this is a lock we need to be IRQ-safe
+ */
+ local_irq_save_nmi(handle->flags);
handle->locked = 0;
for (;;) {
@@ -2906,6 +2910,7 @@ again:
if (atomic_xchg(&data->wakeup, 0))
perf_output_wakeup(handle);
out:
+ local_irq_restore_nmi(handle->flags);
put_cpu();
}
@@ -3385,19 +3390,10 @@ static void perf_event_task_output(struc
unsigned long flags;
int size, ret;
- /*
- * If this CPU attempts to acquire an rq lock held by a CPU spinning
- * in perf_output_lock() from interrupt context, it's game over.
- */
- local_irq_save(flags);
-
size = task_event->event_id.header.size;
ret = perf_output_begin(&handle, event, size, 0, 0);
-
- if (ret) {
- local_irq_restore(flags);
+ if (ret)
return;
- }
task_event->event_id.pid = perf_event_pid(event, task);
task_event->event_id.ppid = perf_event_pid(event, current);
@@ -3408,7 +3404,6 @@ static void perf_event_task_output(struc
perf_output_put(&handle, task_event->event_id);
perf_output_end(&handle);
- local_irq_restore(flags);
}
static int perf_event_task_match(struct perf_event *event)
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: mingo@elte.hu, David Miller <davem@davemloft.net>,
acme@redhat.com, paulus@samba.org, Mike Galbraith <efault@gmx.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@l>
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
linux-arch@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [patch 2/3] perf: Use local_irq_save_nmi()
Date: Tue, 06 Apr 2010 13:28:09 +0000 [thread overview]
Message-ID: <20100406133140.972113669@chello.nl> (raw)
In-Reply-To: 20100406132807.698467930@chello.nl
Patch 8bb39f9 (perf: Fix 'perf sched record' deadlock) introduced a
local_irq_save() in NMI context, convert that to local_irq_save_nmi()
and move the IRQ disable into perf_output_lock/unlock().
The former is needed because we now disallow local_irq_disable() from
NMI context due to some arch limitations.
The second is because its really about IRQ lock inversion with that
funny output lock, and perf_event_task_output() is only one site that
could trigger it.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
---
include/linux/perf_event.h | 1 +
kernel/perf_event.c | 17 ++++++-----------
2 files changed, 7 insertions(+), 11 deletions(-)
Index: linux-2.6/include/linux/perf_event.h
=================================--- linux-2.6.orig/include/linux/perf_event.h
+++ linux-2.6/include/linux/perf_event.h
@@ -758,6 +758,7 @@ struct perf_output_handle {
struct perf_mmap_data *data;
unsigned long head;
unsigned long offset;
+ unsigned long flags;
int nmi;
int sample;
int locked;
Index: linux-2.6/kernel/perf_event.c
=================================--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -2848,6 +2848,10 @@ static void perf_output_lock(struct perf
struct perf_mmap_data *data = handle->data;
int cur, cpu = get_cpu();
+ /*
+ * Since this is a lock we need to be IRQ-safe
+ */
+ local_irq_save_nmi(handle->flags);
handle->locked = 0;
for (;;) {
@@ -2906,6 +2910,7 @@ again:
if (atomic_xchg(&data->wakeup, 0))
perf_output_wakeup(handle);
out:
+ local_irq_restore_nmi(handle->flags);
put_cpu();
}
@@ -3385,19 +3390,10 @@ static void perf_event_task_output(struc
unsigned long flags;
int size, ret;
- /*
- * If this CPU attempts to acquire an rq lock held by a CPU spinning
- * in perf_output_lock() from interrupt context, it's game over.
- */
- local_irq_save(flags);
-
size = task_event->event_id.header.size;
ret = perf_output_begin(&handle, event, size, 0, 0);
-
- if (ret) {
- local_irq_restore(flags);
+ if (ret)
return;
- }
task_event->event_id.pid = perf_event_pid(event, task);
task_event->event_id.ppid = perf_event_pid(event, current);
@@ -3408,7 +3404,6 @@ static void perf_event_task_output(struc
perf_output_put(&handle, task_event->event_id);
perf_output_end(&handle);
- local_irq_restore(flags);
}
static int perf_event_task_match(struct perf_event *event)
next prev parent reply other threads:[~2010-04-06 13:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-06 13:28 [patch 0/3] IRQ disable vs NMI Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-06 13:28 ` [patch 1/3] kernel: local_irq_{save,restore}_nmi() Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-07 1:13 ` Steven Rostedt
2010-04-07 1:13 ` Steven Rostedt
2010-04-07 1:19 ` David Miller
2010-04-07 1:19 ` David Miller
2010-04-07 1:23 ` Steven Rostedt
2010-04-07 1:23 ` Steven Rostedt
2010-04-06 13:28 ` Peter Zijlstra [this message]
2010-04-06 13:28 ` [patch 2/3] perf: Use local_irq_save_nmi() Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-06 13:28 ` [patch 3/3] sched: Use local_irq_save_nmi() in cpu_clock() Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-06 13:28 ` Peter Zijlstra
2010-04-07 11:27 ` Frederic Weisbecker
2010-04-07 11:27 ` Frederic Weisbecker
2010-04-07 11:31 ` Peter Zijlstra
2010-04-07 11:31 ` Peter Zijlstra
2010-04-07 11:44 ` Frederic Weisbecker
2010-04-07 11:44 ` Frederic Weisbecker
2010-04-06 17:54 ` [patch 0/3] IRQ disable vs NMI David Miller
2010-04-06 17:54 ` David Miller
2010-04-06 23:39 ` David Miller
2010-04-06 23:39 ` David Miller
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=20100406133140.972113669@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=davem@davemloft.net \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@l \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.