gpt4 book ai didi

linux-kernel - Linux 内核中的 jiffies 在哪里计算?

转载 作者:行者123 更新时间:2023-12-04 02:06:24 36 4
gpt4 key购买 nike

我正在将 3.14 移植到成功运行 3.2 内核的基于 ARM 的 SOC。

我陷入了校准 jiffies 的代码中。

calibrate_delay_converge()-init/calibrate.c

    /* wait for "start of" clock tick */
ticks = jiffies;
while (ticks == jiffies) <---- infinite loop waiting for jiffies to change
; /* nothing */
/* Go .. */

jiffies 没有被更新。 jiffies 在哪里更新?我正在寻找确凿的证据代码,如 jiffies++ 或更新 jiffies 的 .S 文件。

我钻进了 Linux 中定时器和中断系统的陷阱。定时器中断未启用(在 PL190 HW 中)。我希望如果我可以自下而上地跟踪(应该调用 jiffies 的地方),我可以找到为什么没有启用中断。

最佳答案

看看 do_timer()。它在过去几年的某个时候被移动到 kernel/time/timekeeping.c。

jiffies 不直接递增,它被赋值为 jiffies_64 的低 32 位

/* 
* The 64-bit jiffies value is not atomic - you MUST NOT read it
* without sampling the sequence number in xtime_lock.
* jiffies is defined in the linker script...
*/
void do_timer(unsigned long ticks)
{
jiffies_64 += ticks;
update_wall_time();
calc_global_load(ticks);
}

在 3.2 中是 http://lxr.free-electrons.com/source/kernel/time/timekeeping.c?v=3.2#L1192

jiffies 从机器特定文件中的 jiffies_64 获取值:

http://lxr.free-electrons.com/source/arch/arm/kernel/vmlinux.lds.S?v=3.2

 36 #ifndef __ARMEB__
37 jiffies = jiffies_64;
38 #else
39 jiffies = jiffies_64 + 4;
40 #endif

关于linux-kernel - Linux 内核中的 jiffies 在哪里计算?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24915634/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com