diff options
| author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-06-11 11:32:03 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2010-09-09 14:46:29 -0400 |
| commit | 24cd7f54a0d47e1d5b3de29e2456bfbd2d8447b7 (patch) | |
| tree | a37d3a4cb101e3f67635a1920f447c9e9e8d8ab2 | |
| parent | 9ed6060d286b1eb55974d09080f442f809408c42 (diff) | |
perf: Reduce perf_disable() usage
Since the current perf_disable() usage is only an optimization,
remove it for now. This eases the removal of the __weak
hw_perf_enable() interface.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: paulus <paulus@samba.org>
Cc: stephane eranian <eranian@googlemail.com>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Lin Ming <ming.m.lin@intel.com>
Cc: Yanmin <yanmin_zhang@linux.intel.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: David Miller <davem@davemloft.net>
Cc: Michael Cree <mcree@orcon.net.nz>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
| -rw-r--r-- | arch/arm/kernel/perf_event.c | 3 | ||||
| -rw-r--r-- | arch/powerpc/kernel/perf_event.c | 3 | ||||
| -rw-r--r-- | arch/powerpc/kernel/perf_event_fsl_emb.c | 8 | ||||
| -rw-r--r-- | arch/sh/kernel/perf_event.c | 11 | ||||
| -rw-r--r-- | arch/sparc/kernel/perf_event.c | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/perf_event.c | 22 | ||||
| -rw-r--r-- | include/linux/perf_event.h | 20 | ||||
| -rw-r--r-- | kernel/perf_event.c | 37 |
8 files changed, 48 insertions, 59 deletions
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index f62f9db35db3..afc92c580d18 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c | |||
| @@ -277,6 +277,8 @@ armpmu_enable(struct perf_event *event) | |||
| 277 | int idx; | 277 | int idx; |
| 278 | int err = 0; | 278 | int err = 0; |
| 279 | 279 | ||
| 280 | perf_disable(); | ||
| 281 | |||
| 280 | /* If we don't have a space for the counter then finish early. */ | 282 | /* If we don't have a space for the counter then finish early. */ |
| 281 | idx = armpmu->get_event_idx(cpuc, hwc); | 283 | idx = armpmu->get_event_idx(cpuc, hwc); |
| 282 | if (idx < 0) { | 284 | if (idx < 0) { |
| @@ -303,6 +305,7 @@ armpmu_enable(struct perf_event *event) | |||
| 303 | perf_event_update_userpage(event); | 305 | perf_event_update_userpage(event); |
| 304 | 306 | ||
| 305 | out: | 307 | out: |
| 308 | perf_enable(); | ||
| 306 | return err; | 309 | return err; |
| 307 | } | 310 | } |
| 308 | 311 | ||
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c index 19131b2614b9..c1408821dbc2 100644 --- a/arch/powerpc/kernel/perf_event.c +++ b/arch/powerpc/kernel/perf_event.c | |||
| @@ -861,6 +861,7 @@ void power_pmu_start_txn(struct pmu *pmu) | |||
| 861 | { | 861 | { |
| 862 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); | 862 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); |
| 863 | 863 | ||
| 864 | perf_disable(); | ||
| 864 | cpuhw->group_flag |= PERF_EVENT_TXN; | 865 | cpuhw->group_flag |= PERF_EVENT_TXN; |
| 865 | cpuhw->n_txn_start = cpuhw->n_events; | 866 | cpuhw->n_txn_start = cpuhw->n_events; |
| 866 | } | 867 | } |
| @@ -875,6 +876,7 @@ void power_pmu_cancel_txn(struct pmu *pmu) | |||
| 875 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); | 876 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); |
| 876 | 877 | ||
| 877 | cpuhw->group_flag &= ~PERF_EVENT_TXN; | 878 | cpuhw->group_flag &= ~PERF_EVENT_TXN; |
| 879 | perf_enable(); | ||
| 878 | } | 880 | } |
| 879 | 881 | ||
| 880 | /* | 882 | /* |
| @@ -901,6 +903,7 @@ int power_pmu_commit_txn(struct pmu *pmu) | |||
| 901 | cpuhw->event[i]->hw.config = cpuhw->events[i]; | 903 | cpuhw->event[i]->hw.config = cpuhw->events[i]; |
| 902 | 904 | ||
| 903 | cpuhw->group_flag &= ~PERF_EVENT_TXN; | 905 | cpuhw->group_flag &= ~PERF_EVENT_TXN; |
| 906 | perf_enable(); | ||
| 904 | return 0; | 907 | return 0; |
| 905 | } | 908 | } |
| 906 | 909 | ||
diff --git a/arch/powerpc/kernel/perf_event_fsl_emb.c b/arch/powerpc/kernel/perf_event_fsl_emb.c index ea6a804e43fd..9bc84a7fd901 100644 --- a/arch/powerpc/kernel/perf_event_fsl_emb.c +++ b/arch/powerpc/kernel/perf_event_fsl_emb.c | |||
| @@ -262,7 +262,7 @@ static int collect_events(struct perf_event *group, int max_count, | |||
| 262 | return n; | 262 | return n; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | /* perf must be disabled, context locked on entry */ | 265 | /* context locked on entry */ |
| 266 | static int fsl_emb_pmu_enable(struct perf_event *event) | 266 | static int fsl_emb_pmu_enable(struct perf_event *event) |
| 267 | { | 267 | { |
| 268 | struct cpu_hw_events *cpuhw; | 268 | struct cpu_hw_events *cpuhw; |
| @@ -271,6 +271,7 @@ static int fsl_emb_pmu_enable(struct perf_event *event) | |||
| 271 | u64 val; | 271 | u64 val; |
| 272 | int i; | 272 | int i; |
| 273 | 273 | ||
| 274 | perf_disable(); | ||
| 274 | cpuhw = &get_cpu_var(cpu_hw_events); | 275 | cpuhw = &get_cpu_var(cpu_hw_events); |
| 275 | 276 | ||
| 276 | if (event->hw.config & FSL_EMB_EVENT_RESTRICTED) | 277 | if (event->hw.config & FSL_EMB_EVENT_RESTRICTED) |
| @@ -310,15 +311,17 @@ static int fsl_emb_pmu_enable(struct perf_event *event) | |||
| 310 | ret = 0; | 311 | ret = 0; |
| 311 | out: | 312 | out: |
| 312 | put_cpu_var(cpu_hw_events); | 313 | put_cpu_var(cpu_hw_events); |
| 314 | perf_enable(); | ||
| 313 | return ret; | 315 | return ret; |
| 314 | } | 316 | } |
| 315 | 317 | ||
| 316 | /* perf must be disabled, context locked on entry */ | 318 | /* context locked on entry */ |
| 317 | static void fsl_emb_pmu_disable(struct perf_event *event) | 319 | static void fsl_emb_pmu_disable(struct perf_event *event) |
| 318 | { | 320 | { |
| 319 | struct cpu_hw_events *cpuhw; | 321 | struct cpu_hw_events *cpuhw; |
| 320 | int i = event->hw.idx; | 322 | int i = event->hw.idx; |
| 321 | 323 | ||
| 324 | perf_disable(); | ||
| 322 | if (i < 0) | 325 | if (i < 0) |
| 323 | goto out; | 326 | goto out; |
| 324 | 327 | ||
| @@ -346,6 +349,7 @@ static void fsl_emb_pmu_disable(struct perf_event *event) | |||
| 346 | cpuhw->n_events--; | 349 | cpuhw->n_events--; |
| 347 | 350 | ||
| 348 | out: | 351 | out: |
| 352 | perf_enable(); | ||
| 349 | put_cpu_var(cpu_hw_events); | 353 | put_cpu_var(cpu_hw_events); |
| 350 | } | 354 | } |
| 351 | 355 | ||
diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c index 8cb206597e0c..d042989ceb45 100644 --- a/arch/sh/kernel/perf_event.c +++ b/arch/sh/kernel/perf_event.c | |||
| @@ -230,11 +230,14 @@ static int sh_pmu_enable(struct perf_event *event) | |||
| 230 | struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); | 230 | struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); |
| 231 | struct hw_perf_event *hwc = &event->hw; | 231 | struct hw_perf_event *hwc = &event->hw; |
| 232 | int idx = hwc->idx; | 232 | int idx = hwc->idx; |
| 233 | int ret = -EAGAIN; | ||
| 234 | |||
| 235 | perf_disable(); | ||
| 233 | 236 | ||
| 234 | if (test_and_set_bit(idx, cpuc->used_mask)) { | 237 | if (test_and_set_bit(idx, cpuc->used_mask)) { |
| 235 | idx = find_first_zero_bit(cpuc->used_mask, sh_pmu->num_events); | 238 | idx = find_first_zero_bit(cpuc->used_mask, sh_pmu->num_events); |
| 236 | if (idx == sh_pmu->num_events) | 239 | if (idx == sh_pmu->num_events) |
| 237 | return -EAGAIN; | 240 | goto out; |
| 238 | 241 | ||
| 239 | set_bit(idx, cpuc->used_mask); | 242 | set_bit(idx, cpuc->used_mask); |
| 240 | hwc->idx = idx; | 243 | hwc->idx = idx; |
| @@ -248,8 +251,10 @@ static int sh_pmu_enable(struct perf_event *event) | |||
| 248 | sh_pmu->enable(hwc, idx); | 251 | sh_pmu->enable(hwc, idx); |
| 249 | 252 | ||
| 250 | perf_event_update_userpage(event); | 253 | perf_event_update_userpage(event); |
| 251 | 254 | ret = 0; | |
| 252 | return 0; | 255 | out: |
| 256 | perf_enable(); | ||
| 257 | return ret; | ||
| 253 | } | 258 | } |
| 254 | 259 | ||
| 255 | static void sh_pmu_read(struct perf_event *event) | 260 | static void sh_pmu_read(struct perf_event *event) |
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c index bed4327f5a7a..d0131deeeaf6 100644 --- a/arch/sparc/kernel/perf_event.c +++ b/arch/sparc/kernel/perf_event.c | |||
| @@ -1113,6 +1113,7 @@ static void sparc_pmu_start_txn(struct pmu *pmu) | |||
| 1113 | { | 1113 | { |
| 1114 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); | 1114 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); |
| 1115 | 1115 | ||
| 1116 | perf_disable(); | ||
| 1116 | cpuhw->group_flag |= PERF_EVENT_TXN; | 1117 | cpuhw->group_flag |= PERF_EVENT_TXN; |
| 1117 | } | 1118 | } |
| 1118 | 1119 | ||
| @@ -1126,6 +1127,7 @@ static void sparc_pmu_cancel_txn(struct pmu *pmu) | |||
| 1126 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); | 1127 | struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); |
| 1127 | 1128 | ||
| 1128 | cpuhw->group_flag &= ~PERF_EVENT_TXN; | 1129 | cpuhw->group_flag &= ~PERF_EVENT_TXN; |
| 1130 | perf_enable(); | ||
| 1129 | } | 1131 | } |
| 1130 | 1132 | ||
| 1131 | /* | 1133 | /* |
| @@ -1149,6 +1151,7 @@ static int sparc_pmu_commit_txn(struct pmu *pmu) | |||
