diff options
-rw-r--r-- | include/linux/perf_event.h | 1 | ||||
-rw-r--r-- | kernel/perf_event.c | 21 |
2 files changed, 11 insertions, 11 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index df4e73e33774..7f87563c8485 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -714,7 +714,6 @@ struct perf_output_handle { | |||
714 | int nmi; | 714 | int nmi; |
715 | int sample; | 715 | int sample; |
716 | int locked; | 716 | int locked; |
717 | unsigned long flags; | ||
718 | }; | 717 | }; |
719 | 718 | ||
720 | #ifdef CONFIG_PERF_EVENTS | 719 | #ifdef CONFIG_PERF_EVENTS |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 6f4ed3b4cd73..3256e36ad251 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -2674,20 +2674,21 @@ static void perf_output_wakeup(struct perf_output_handle *handle) | |||
2674 | static void perf_output_lock(struct perf_output_handle *handle) | 2674 | static void perf_output_lock(struct perf_output_handle *handle) |
2675 | { | 2675 | { |
2676 | struct perf_mmap_data *data = handle->data; | 2676 | struct perf_mmap_data *data = handle->data; |
2677 | int cpu; | 2677 | int cur, cpu = get_cpu(); |
2678 | 2678 | ||
2679 | handle->locked = 0; | 2679 | handle->locked = 0; |
2680 | 2680 | ||
2681 | local_irq_save(handle->flags); | 2681 | for (;;) { |
2682 | cpu = smp_processor_id(); | 2682 | cur = atomic_cmpxchg(&data->lock, -1, cpu); |
2683 | 2683 | if (cur == -1) { | |
2684 | if (in_nmi() && atomic_read(&data->lock) == cpu) | 2684 | handle->locked = 1; |
2685 | return; | 2685 | break; |
2686 | } | ||
2687 | if (cur == cpu) | ||
2688 | break; | ||
2686 | 2689 | ||
2687 | while (atomic_cmpxchg(&data->lock, -1, cpu) != -1) | ||
2688 | cpu_relax(); | 2690 | cpu_relax(); |
2689 | 2691 | } | |
2690 | handle->locked = 1; | ||
2691 | } | 2692 | } |
2692 | 2693 | ||
2693 | static void perf_output_unlock(struct perf_output_handle *handle) | 2694 | static void perf_output_unlock(struct perf_output_handle *handle) |
@@ -2733,7 +2734,7 @@ again: | |||
2733 | if (atomic_xchg(&data->wakeup, 0)) | 2734 | if (atomic_xchg(&data->wakeup, 0)) |
2734 | perf_output_wakeup(handle); | 2735 | perf_output_wakeup(handle); |
2735 | out: | 2736 | out: |
2736 | local_irq_restore(handle->flags); | 2737 | put_cpu(); |
2737 | } | 2738 | } |
2738 | 2739 | ||
2739 | void perf_output_copy(struct perf_output_handle *handle, | 2740 | void perf_output_copy(struct perf_output_handle *handle, |