提交 6c7e550f 编写于 作者: F Franck Bui-Huu 提交者: Ingo Molnar

perf: Introduce is_sampling_event()

and use it when appropriate.
Signed-off-by: NFranck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1290525705-6265-1-git-send-email-fbuihuu@gmail.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 35d3778a
...@@ -442,7 +442,7 @@ static int x86_setup_perfctr(struct perf_event *event) ...@@ -442,7 +442,7 @@ static int x86_setup_perfctr(struct perf_event *event)
struct hw_perf_event *hwc = &event->hw; struct hw_perf_event *hwc = &event->hw;
u64 config; u64 config;
if (!hwc->sample_period) { if (!is_sampling_event(event)) {
hwc->sample_period = x86_pmu.max_period; hwc->sample_period = x86_pmu.max_period;
hwc->last_period = hwc->sample_period; hwc->last_period = hwc->sample_period;
local64_set(&hwc->period_left, hwc->sample_period); local64_set(&hwc->period_left, hwc->sample_period);
......
...@@ -969,6 +969,11 @@ extern int perf_event_overflow(struct perf_event *event, int nmi, ...@@ -969,6 +969,11 @@ extern int perf_event_overflow(struct perf_event *event, int nmi,
struct perf_sample_data *data, struct perf_sample_data *data,
struct pt_regs *regs); struct pt_regs *regs);
static inline bool is_sampling_event(struct perf_event *event)
{
return event->attr.sample_period != 0;
}
/* /*
* Return 1 for a software event, 0 for a hardware event * Return 1 for a software event, 0 for a hardware event
*/ */
......
...@@ -2514,7 +2514,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg) ...@@ -2514,7 +2514,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
int ret = 0; int ret = 0;
u64 value; u64 value;
if (!event->attr.sample_period) if (!is_sampling_event(event))
return -EINVAL; return -EINVAL;
if (copy_from_user(&value, arg, sizeof(value))) if (copy_from_user(&value, arg, sizeof(value)))
...@@ -4385,7 +4385,7 @@ static void perf_swevent_event(struct perf_event *event, u64 nr, ...@@ -4385,7 +4385,7 @@ static void perf_swevent_event(struct perf_event *event, u64 nr,
if (!regs) if (!regs)
return; return;
if (!hwc->sample_period) if (!is_sampling_event(event))
return; return;
if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq) if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq)
...@@ -4548,7 +4548,7 @@ static int perf_swevent_add(struct perf_event *event, int flags) ...@@ -4548,7 +4548,7 @@ static int perf_swevent_add(struct perf_event *event, int flags)
struct hw_perf_event *hwc = &event->hw; struct hw_perf_event *hwc = &event->hw;
struct hlist_head *head; struct hlist_head *head;
if (hwc->sample_period) { if (is_sampling_event(event)) {
hwc->last_period = hwc->sample_period; hwc->last_period = hwc->sample_period;
perf_swevent_set_period(event); perf_swevent_set_period(event);
} }
...@@ -4920,7 +4920,7 @@ static void perf_swevent_start_hrtimer(struct perf_event *event) ...@@ -4920,7 +4920,7 @@ static void perf_swevent_start_hrtimer(struct perf_event *event)
hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hwc->hrtimer.function = perf_swevent_hrtimer; hwc->hrtimer.function = perf_swevent_hrtimer;
if (hwc->sample_period) { if (is_sampling_event(event)) {
s64 period = local64_read(&hwc->period_left); s64 period = local64_read(&hwc->period_left);
if (period) { if (period) {
...@@ -4941,7 +4941,7 @@ static void perf_swevent_cancel_hrtimer(struct perf_event *event) ...@@ -4941,7 +4941,7 @@ static void perf_swevent_cancel_hrtimer(struct perf_event *event)
{ {
struct hw_perf_event *hwc = &event->hw; struct hw_perf_event *hwc = &event->hw;
if (hwc->sample_period) { if (is_sampling_event(event)) {
ktime_t remaining = hrtimer_get_remaining(&hwc->hrtimer); ktime_t remaining = hrtimer_get_remaining(&hwc->hrtimer);
local64_set(&hwc->period_left, ktime_to_ns(remaining)); local64_set(&hwc->period_left, ktime_to_ns(remaining));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册