在 Linux 内核中 jiffies 在哪里计算?

Dav*_*ole 3 linux-kernel

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

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

校准延迟收敛()-init/calibrate.c

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

jiffies 没有更新。jiffies 在哪里更新?我正在寻找类似 jiffies++ 或更新 jiffies 的 .S 文件的吸烟枪代码。

我进入了 Linux 中计时器和中断系统的兔子洞。定时器中断未启用(在 PL190 硬件中)。我希望如果我可以自下而上跟踪(应该调用 jiffies 的地方),我就能找到为什么没有启用中断。

cod*_*eim 6

看看 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); 
} 
Run Code Online (Sandbox Code Playgroud)

在 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
Run Code Online (Sandbox Code Playgroud)