mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
perf: Optimize some swcounter attr.sample_period==1 paths
Avoid the rather expensive perf_swevent_set_period() if we know we have to sample every single event anyway. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <20091120212508.299508332@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
453f19eea7
commit
0cff784ae4
1 changed files with 13 additions and 8 deletions
|
@ -3759,16 +3759,16 @@ again:
|
||||||
return nr;
|
return nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void perf_swevent_overflow(struct perf_event *event,
|
static void perf_swevent_overflow(struct perf_event *event, u64 overflow,
|
||||||
int nmi, struct perf_sample_data *data,
|
int nmi, struct perf_sample_data *data,
|
||||||
struct pt_regs *regs)
|
struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
struct hw_perf_event *hwc = &event->hw;
|
struct hw_perf_event *hwc = &event->hw;
|
||||||
int throttle = 0;
|
int throttle = 0;
|
||||||
u64 overflow;
|
|
||||||
|
|
||||||
data->period = event->hw.last_period;
|
data->period = event->hw.last_period;
|
||||||
overflow = perf_swevent_set_period(event);
|
if (!overflow)
|
||||||
|
overflow = perf_swevent_set_period(event);
|
||||||
|
|
||||||
if (hwc->interrupts == MAX_INTERRUPTS)
|
if (hwc->interrupts == MAX_INTERRUPTS)
|
||||||
return;
|
return;
|
||||||
|
@ -3801,14 +3801,19 @@ static void perf_swevent_add(struct perf_event *event, u64 nr,
|
||||||
|
|
||||||
atomic64_add(nr, &event->count);
|
atomic64_add(nr, &event->count);
|
||||||
|
|
||||||
if (!hwc->sample_period)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!regs)
|
if (!regs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!atomic64_add_negative(nr, &hwc->period_left))
|
if (!hwc->sample_period)
|
||||||
perf_swevent_overflow(event, nmi, data, regs);
|
return;
|
||||||
|
|
||||||
|
if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq)
|
||||||
|
return perf_swevent_overflow(event, 1, nmi, data, regs);
|
||||||
|
|
||||||
|
if (atomic64_add_negative(nr, &hwc->period_left))
|
||||||
|
return;
|
||||||
|
|
||||||
|
perf_swevent_overflow(event, 0, nmi, data, regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int perf_swevent_is_counting(struct perf_event *event)
|
static int perf_swevent_is_counting(struct perf_event *event)
|
||||||
|
|
Loading…
Reference in a new issue