diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-05-21 08:43:08 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-06-09 05:12:37 -0400 |
commit | e78505958cf123048fb48cb56b79cebb8edd15fb (patch) | |
tree | 3688d124cdc906cbe9f6587c8671ba0a14c95262 /kernel/perf_event.c | |
parent | a6e6dea68c18f705957573ee5596097c7e82d0e5 (diff) |
perf: Convert perf_event to local_t
Since now all modification to event->count (and ->prev_count
and ->period_left) are local to a cpu, change then to local64_t so we
avoid the LOCK'ed ops.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r-- | kernel/perf_event.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index a395fda2d94c..97c73018592e 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -1148,9 +1148,9 @@ static void __perf_event_sync_stat(struct perf_event *event, | |||
1148 | * In order to keep per-task stats reliable we need to flip the event | 1148 | * In order to keep per-task stats reliable we need to flip the event |
1149 | * values when we flip the contexts. | 1149 | * values when we flip the contexts. |
1150 | */ | 1150 | */ |
1151 | value = atomic64_read(&next_event->count); | 1151 | value = local64_read(&next_event->count); |
1152 | value = atomic64_xchg(&event->count, value); | 1152 | value = local64_xchg(&event->count, value); |
1153 | atomic64_set(&next_event->count, value); | 1153 | local64_set(&next_event->count, value); |
1154 | 1154 | ||
1155 | swap(event->total_time_enabled, next_event->total_time_enabled); | 1155 | swap(event->total_time_enabled, next_event->total_time_enabled); |
1156 | swap(event->total_time_running, next_event->total_time_running); | 1156 | swap(event->total_time_running, next_event->total_time_running); |
@@ -1540,10 +1540,10 @@ static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count) | |||
1540 | 1540 | ||
1541 | hwc->sample_period = sample_period; | 1541 | hwc->sample_period = sample_period; |
1542 | 1542 | ||
1543 | if (atomic64_read(&hwc->period_left) > 8*sample_period) { | 1543 | if (local64_read(&hwc->period_left) > 8*sample_period) { |
1544 | perf_disable(); | 1544 | perf_disable(); |
1545 | perf_event_stop(event); | 1545 | perf_event_stop(event); |
1546 | atomic64_set(&hwc->period_left, 0); | 1546 | local64_set(&hwc->period_left, 0); |
1547 | perf_event_start(event); | 1547 | perf_event_start(event); |
1548 | perf_enable(); | 1548 | perf_enable(); |
1549 | } | 1549 | } |
@@ -1584,7 +1584,7 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx) | |||
1584 | 1584 | ||
1585 | perf_disable(); | 1585 | perf_disable(); |
1586 | event->pmu->read(event); | 1586 | event->pmu->read(event); |
1587 | now = atomic64_read(&event->count); | 1587 | now = local64_read(&event->count); |
1588 | delta = now - hwc->freq_count_stamp; | 1588 | delta = now - hwc->freq_count_stamp; |
1589 | hwc->freq_count_stamp = now; | 1589 | hwc->freq_count_stamp = now; |
1590 | 1590 | ||
@@ -1738,7 +1738,7 @@ static void __perf_event_read(void *info) | |||
1738 | 1738 | ||
1739 | static inline u64 perf_event_count(struct perf_event *event) | 1739 | static inline u64 perf_event_count(struct perf_event *event) |
1740 | { | 1740 | { |
1741 | return atomic64_read(&event->count) + atomic64_read(&event->child_count); | 1741 | return local64_read(&event->count) + atomic64_read(&event->child_count); |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | static u64 perf_event_read(struct perf_event *event) | 1744 | static u64 perf_event_read(struct perf_event *event) |
@@ -2141,7 +2141,7 @@ static unsigned int perf_poll(struct file *file, poll_table *wait) | |||
2141 | static void perf_event_reset(struct perf_event *event) | 2141 | static void perf_event_reset(struct perf_event *event) |
2142 | { | 2142 | { |
2143 | (void)perf_event_read(event); | 2143 | (void)perf_event_read(event); |
2144 | atomic64_set(&event->count, 0); | 2144 | local64_set(&event->count, 0); |
2145 | perf_event_update_userpage(event); | 2145 | perf_event_update_userpage(event); |
2146 | } | 2146 | } |
2147 | 2147 | ||
@@ -2359,7 +2359,7 @@ void perf_event_update_userpage(struct perf_event *event) | |||
2359 | userpg->index = perf_event_index(event); | 2359 | userpg->index = perf_event_index(event); |
2360 | userpg->offset = perf_event_count(event); | 2360 | userpg->offset = perf_event_count(event); |
2361 | if (event->state == PERF_EVENT_STATE_ACTIVE) | 2361 | if (event->state == PERF_EVENT_STATE_ACTIVE) |
2362 | userpg->offset -= atomic64_read(&event->hw.prev_count); | 2362 | userpg->offset -= local64_read(&event->hw.prev_count); |
2363 | 2363 | ||
2364 | userpg->time_enabled = event->total_time_enabled + | 2364 | userpg->time_enabled = event->total_time_enabled + |
2365 | atomic64_read(&event->child_total_time_enabled); | 2365 | atomic64_read(&event->child_total_time_enabled); |
@@ -4035,14 +4035,14 @@ static u64 perf_swevent_set_period(struct perf_event *event) | |||
4035 | hwc->last_period = hwc->sample_period; | 4035 | hwc->last_period = hwc->sample_period; |
4036 | 4036 | ||
4037 | again: | 4037 | again: |
4038 | old = val = atomic64_read(&hwc->period_left); | 4038 | old = val = local64_read(&hwc->period_left); |
4039 | if (val < 0) | 4039 | if (val < 0) |
4040 | return 0; | 4040 | return 0; |
4041 | 4041 | ||
4042 | nr = div64_u64(period + val, period); | 4042 | nr = div64_u64(period + val, period); |
4043 | offset = nr * period; | 4043 | offset = nr * period; |
4044 | val -= offset; | 4044 | val -= offset; |
4045 | if (atomic64_cmpxchg(&hwc->period_left, old, val) != old) | 4045 | if (local64_cmpxchg(&hwc->period_left, old, val) != old) |
4046 | goto again; | 4046 | goto again; |
4047 | 4047 | ||
4048 | return nr; | 4048 | return nr; |
@@ -4081,7 +4081,7 @@ static void perf_swevent_add(struct perf_event *event, u64 nr, | |||
4081 | { | 4081 | { |
4082 | struct hw_perf_event *hwc = &event->hw; | 4082 | struct hw_perf_event *hwc = &event->hw; |
4083 | 4083 | ||
4084 | atomic64_add(nr, &event->count); | 4084 | local64_add(nr, &event->count); |
4085 | 4085 | ||
4086 | if (!regs) | 4086 | if (!regs) |
4087 | return; | 4087 | return; |
@@ -4092,7 +4092,7 @@ static void perf_swevent_add(struct perf_event *event, u64 nr, | |||
4092 | if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq) | 4092 | if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq) |
4093 | return perf_swevent_overflow(event, 1, nmi, data, regs); | 4093 | return perf_swevent_overflow(event, 1, nmi, data, regs); |
4094 | 4094 | ||
4095 | if (atomic64_add_negative(nr, &hwc->period_left)) | 4095 | if (local64_add_negative(nr, &hwc->period_left)) |
4096 | return; | 4096 | return; |
4097 | 4097 | ||
4098 | perf_swevent_overflow(event, 0, nmi, data, regs); | 4098 | perf_swevent_overflow(event, 0, nmi, data, regs); |
@@ -4383,8 +4383,8 @@ static void cpu_clock_perf_event_update(struct perf_event *event) | |||
4383 | u64 now; | 4383 | u64 now; |
4384 | 4384 | ||
4385 | now = cpu_clock(cpu); | 4385 | now = cpu_clock(cpu); |
4386 | prev = atomic64_xchg(&event->hw.prev_count, now); | 4386 | prev = local64_xchg(&event->hw.prev_count, now); |
4387 | atomic64_add(now - prev, &event->count); | 4387 | local64_add(now - prev, &event->count); |
4388 | } | 4388 | } |
4389 | 4389 | ||
4390 | static int cpu_clock_perf_event_enable(struct perf_event *event) | 4390 | static int cpu_clock_perf_event_enable(struct perf_event *event) |
@@ -4392,7 +4392,7 @@ static int cpu_clock_perf_event_enable(struct perf_event *event) | |||
4392 | struct hw_perf_event *hwc = &event->hw; | 4392 | struct hw_perf_event *hwc = &event->hw; |
4393 | int cpu = raw_smp_processor_id(); | 4393 | int cpu = raw_smp_processor_id(); |
4394 | 4394 | ||
4395 | atomic64_set(&hwc->prev_count, cpu_clock(cpu)); | 4395 | local64_set(&hwc->prev_count, cpu_clock(cpu)); |
4396 | perf_swevent_start_hrtimer(event); | 4396 | perf_swevent_start_hrtimer(event); |
4397 | 4397 | ||
4398 | return 0; | 4398 | return 0; |
@@ -4424,9 +4424,9 @@ static void task_clock_perf_event_update(struct perf_event *event, u64 now) | |||
4424 | u64 prev; | 4424 | u64 prev; |
4425 | s64 delta; | 4425 | s64 delta; |
4426 | 4426 | ||
4427 | prev = atomic64_xchg(&event->hw.prev_count, now); | 4427 | prev = local64_xchg(&event->hw.prev_count, now); |
4428 | delta = now - prev; | 4428 | delta = now - prev; |
4429 | atomic64_add(delta, &event->count); | 4429 | local64_add(delta, &event->count); |
4430 | } | 4430 | } |
4431 | 4431 | ||
4432 | static int task_clock_perf_event_enable(struct perf_event *event) | 4432 | static int task_clock_perf_event_enable(struct perf_event *event) |
@@ -4436,7 +4436,7 @@ static int task_clock_perf_event_enable(struct perf_event *event) | |||
4436 | 4436 | ||
4437 | now = event->ctx->time; | 4437 | now = event->ctx->time; |
4438 | 4438 | ||
4439 | atomic64_set(&hwc->prev_count, now); | 4439 | local64_set(&hwc->prev_count, now); |
4440 | 4440 | ||
4441 | perf_swevent_start_hrtimer(event); | 4441 | perf_swevent_start_hrtimer(event); |
4442 | 4442 | ||
@@ -4879,7 +4879,7 @@ perf_event_alloc(struct perf_event_attr *attr, | |||
4879 | hwc->sample_period = 1; | 4879 | hwc->sample_period = 1; |
4880 | hwc->last_period = hwc->sample_period; | 4880 | hwc->last_period = hwc->sample_period; |
4881 | 4881 | ||
4882 | atomic64_set(&hwc->period_left, hwc->sample_period); | 4882 | local64_set(&hwc->period_left, hwc->sample_period); |
4883 | 4883 | ||
4884 | /* | 4884 | /* |
4885 | * we currently do not support PERF_FORMAT_GROUP on inherited events | 4885 | * we currently do not support PERF_FORMAT_GROUP on inherited events |
@@ -5313,7 +5313,7 @@ inherit_event(struct perf_event *parent_event, | |||
5313 | hwc->sample_period = sample_period; | 5313 | hwc->sample_period = sample_period; |
5314 | hwc->last_period = sample_period; | 5314 | hwc->last_period = sample_period; |
5315 | 5315 | ||
5316 | atomic64_set(&hwc->period_left, sample_period); | 5316 | local64_set(&hwc->period_left, sample_period); |
5317 | } | 5317 | } |
5318 | 5318 | ||
5319 | child_event->overflow_handler = parent_event->overflow_handler; | 5319 | child_event->overflow_handler = parent_event->overflow_handler; |