linux 内核 微秒,linux – 如何将ftrace精度提高到微秒?

我正在尝试在Android环境中生成FTrace文件,使用:

root@adroid:# echo 1 > /sys/kernel/debug/tracing/events/sched/sched_switch/enable

root@adroid:# echo 1 > /sys/kernel/debug/tracing/tracing_on

root@adroid:# cat /sys/kernel/debug/tracing/trace > mytracefile.txt

root@adroid:# echo 0 > /sys/kernel/debug/tracing/tracing_on

root@adroid:# echo 0 > /sys/kernel/debug/tracing/events/sched/sched_switch/enable

问题是在mytracefile.txt中,时间戳的精度以毫秒为单位:

-0 [000] d.h7 14186.690000: sched_wakeup: comm=tfm_b6bcf800 pid=1714 prio=35 success=1 target_cpu=000

-0 [000] d..3 14186.690000: sched_switch: prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=tfm_b6bcf800 next_pid=1714 next_prio=35

tfm_b6bcf800-1714 [000] d..3 14186.690000: sched_switch: prev_comm=tfm_b6bcf800 prev_pid=1714 prev_prio=35 prev_state=D|W ==> next_comm=swapper/0 next_pid=0 next_prio=120

-0 [001] d.h3 14186.690000: sched_wakeup: comm=Player Aud Mixe pid=146 prio=35 success=1 target_cpu=001

-0 [001] d..3 14186.690000: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Player Aud Mixe next_pid=146 next_prio=35

Player Aud Mixe-146 [001] d..3 14186.690000: sched_switch: prev_comm=Player Aud Mixe prev_pid=146 prev_prio=35 prev_state=D ==> next_comm=swapper/1 next_pid=0 next_prio=120

-0 [001] d.h3 14186.690000: sched_wakeup: comm=Player Aud Mixe pid=146 prio=35 success=1 target_cpu=001

-0 [001] d..3 14186.690000: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Player Aud Mixe next_pid=146 next_prio=35

Player Aud Mixe-146 [001] d..3 14186.690000: sched_switch: prev_comm=Player Aud Mixe prev_pid=146 prev_prio=35 prev_state=S ==> next_comm=swapper/1 next_pid=0 next_prio=120

-0 [001] d.h3 14186.700000: sched_wakeup: comm=Player Aud Mixe pid=146 prio=35 success=1 target_cpu=001

-0 [001] d..3 14186.700000: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Player Aud Mixe next_pid=146 next_prio=35

通常,它应该是微秒级,如14186.691234而不是14186.690000.

我已经测试了我拥有的所有其他trace_clock选项(本地,全局和计数器)但结果总是相同的.更改该参数不会更改输出文件中的任何内容.

我小心翼翼地遵循FTrace documentation,但我不知道配置中还有什么可以改变.

有什么建议?

我必须在内核中安装其他模块吗?

> Android版本:4.2.2

>内核Linux版本:3.4.7

dmesg输出也显示毫秒精度:

<4>[ 38.130000] oom_adj 0 => oom_score_adj 0

<4>[ 38.130000] oom_adj 1 => oom_score_adj 58

<4>[ 38.140000] oom_adj 2 => oom_score_adj 117

<4>[ 38.140000] oom_adj 4 => oom_score_adj 235

<4>[ 38.150000] oom_adj 9 => oom_score_adj 529

<4>[ 38.150000] oom_adj 15 => oom_score_adj 1000

更新:

我们正在为android ftrace文件构建一个图形解析器(包括atrace痕迹).这就是为什么尽可能多地保持精度是非常重要的.

使用相同的设备和其他软件工具,我们可以成功地获得微秒精度.

所以,现在我们计划编辑ftrace.c源代码来修改生成时间戳的方式:

static inline uint64_t my_custom_jiffies(void)

{

struct timeval tv;

gettimeofday(&tv, NULL);

return tv.tv_sec*1000000 + tv.tv_usec;

}

我个人认为这不是一个非常好的解决方案/架构/实现,因为这可以在不修改源代码的情况下实现……但它是我们此时唯一的想法.

你怎么看 ?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值