提交 6accb9cf 编写于 作者: R Robert Richter 提交者: Ingo Molnar

perf/x86-ibs: Fix frequency profiling

Fixing profiling at a fixed frequency, in this case the freq value and
sample period was setup incorrectly. Since sampling periods are
adjusted we also allow periods that have lower 4 bits set.

Another fix is the setup of the hw counter: If we modify
hwc->sample_period, we also need to update hwc->last_period and
hwc->period_left.
Signed-off-by: NRobert Richter <robert.richter@amd.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1333390758-10893-5-git-send-email-robert.richter@amd.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 7bf35238
...@@ -162,9 +162,16 @@ static int perf_ibs_init(struct perf_event *event) ...@@ -162,9 +162,16 @@ static int perf_ibs_init(struct perf_event *event)
if (config & perf_ibs->cnt_mask) if (config & perf_ibs->cnt_mask)
/* raw max_cnt may not be set */ /* raw max_cnt may not be set */
return -EINVAL; return -EINVAL;
if (hwc->sample_period & 0x0f) if (!event->attr.sample_freq && hwc->sample_period & 0x0f)
/* lower 4 bits can not be set in ibs max cnt */ /*
* lower 4 bits can not be set in ibs max cnt,
* but allowing it in case we adjust the
* sample period to set a frequency.
*/
return -EINVAL; return -EINVAL;
hwc->sample_period &= ~0x0FULL;
if (!hwc->sample_period)
hwc->sample_period = 0x10;
} else { } else {
max_cnt = config & perf_ibs->cnt_mask; max_cnt = config & perf_ibs->cnt_mask;
config &= ~perf_ibs->cnt_mask; config &= ~perf_ibs->cnt_mask;
...@@ -175,6 +182,13 @@ static int perf_ibs_init(struct perf_event *event) ...@@ -175,6 +182,13 @@ static int perf_ibs_init(struct perf_event *event)
if (!hwc->sample_period) if (!hwc->sample_period)
return -EINVAL; return -EINVAL;
/*
* If we modify hwc->sample_period, we also need to update
* hwc->last_period and hwc->period_left.
*/
hwc->last_period = hwc->sample_period;
local64_set(&hwc->period_left, hwc->sample_period);
hwc->config_base = perf_ibs->msr; hwc->config_base = perf_ibs->msr;
hwc->config = config; hwc->config = config;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册