diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-05-18 05:12:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-05-18 12:35:49 -0400 |
commit | 6d1acfd5c6bfd5231c13a8f2858d7f2afbaa1b62 (patch) | |
tree | abcfa95947cafc94c978a255b814472fe67cad22 | |
parent | fa5881514ef9c9bcb29319aad85cf2d8889d91f1 (diff) |
perf: Optimize perf_output_*() by avoiding local_xchg()
Since the x86 XCHG ins implies LOCK, avoid the use by
using a sequence count instead.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | include/linux/perf_event.h | 1 | ||||
-rw-r--r-- | kernel/perf_event.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index ce7667616fcb..fe50347dc645 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -804,6 +804,7 @@ struct perf_output_handle { | |||
804 | struct perf_mmap_data *data; | 804 | struct perf_mmap_data *data; |
805 | unsigned long head; | 805 | unsigned long head; |
806 | unsigned long offset; | 806 | unsigned long offset; |
807 | unsigned long wakeup; | ||
807 | int nmi; | 808 | int nmi; |
808 | int sample; | 809 | int sample; |
809 | }; | 810 | }; |
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 1f98c78c3343..7e3bcf1a29f0 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -2917,6 +2917,7 @@ static void perf_output_get_handle(struct perf_output_handle *handle) | |||
2917 | 2917 | ||
2918 | preempt_disable(); | 2918 | preempt_disable(); |
2919 | local_inc(&data->nest); | 2919 | local_inc(&data->nest); |
2920 | handle->wakeup = local_read(&data->wakeup); | ||
2920 | } | 2921 | } |
2921 | 2922 | ||
2922 | static void perf_output_put_handle(struct perf_output_handle *handle) | 2923 | static void perf_output_put_handle(struct perf_output_handle *handle) |
@@ -2950,7 +2951,7 @@ again: | |||
2950 | goto again; | 2951 | goto again; |
2951 | } | 2952 | } |
2952 | 2953 | ||
2953 | if (local_xchg(&data->wakeup, 0)) | 2954 | if (handle->wakeup != local_read(&data->wakeup)) |
2954 | perf_output_wakeup(handle); | 2955 | perf_output_wakeup(handle); |
2955 | 2956 | ||
2956 | preempt_enable(); | 2957 | preempt_enable(); |