提交 86656703 编写于 作者: W Wei Li 提交者: Xie XiuQi

arm64: perf: add support for cap_user_time_zero

hulk inclusion
category: feature
bugzilla: 18657
CVE: NA

-------------------------------------------

Add support for cap_user_time_zero on arm64 to enable the converting
between perf time and tsc in perf tool.
Signed-off-by: NWei Li <liwei391@huawei.com>
Reviewed-by: NXuefeng Wang <wxf.wang@hisilicon.com>
Reviewed-by: NTan Xiaojun <tanxiaojun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 fcf53a28
......@@ -29,6 +29,7 @@
#include <linux/of.h>
#include <linux/perf/arm_pmu.h>
#include <linux/platform_device.h>
#include <linux/sched/clock.h>
/*
* ARMv8 PMUv3 Performance Events handling code.
......@@ -1417,11 +1418,22 @@ static int __init armv8_pmu_driver_init(void)
}
device_initcall(armv8_pmu_driver_init)
static u64 cyc_to_ns(u64 cyc, u16 time_shift, u32 time_mult)
{
u64 quot, rem;
quot = cyc >> time_shift;
rem = cyc & (((u64)1 << time_shift) - 1);
return quot * time_mult +
((rem * time_mult) >> time_shift);
}
void arch_perf_update_userpage(struct perf_event *event,
struct perf_event_mmap_page *userpg, u64 now)
{
u32 freq;
u32 shift;
u64 offset;
/*
* Internal timekeeping for enabled/running/stopped times
......@@ -1444,4 +1456,16 @@ void arch_perf_update_userpage(struct perf_event *event,
}
userpg->time_shift = (u16)shift;
userpg->time_offset = -now;
offset = local_clock() - cyc_to_ns(arch_timer_read_counter(),
userpg->time_shift, userpg->time_mult);
/*
* cap_user_time_zero doesn't make sense when we're using a different
* time base for the records.
*/
if (!event->attr.use_clockid) {
userpg->cap_user_time_zero = 1;
userpg->time_zero = offset;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册