Skip to the content.

struct tick_device

切换模式

切换之前 : 系统启动之后,立刻 br update_process_times

之后的调用路线 : hrtimer + dynamic tick 的模式

[ ] broadcast 模式

kernel/time/tick-broadcast.c 可以先看看 https://lwn.net/Articles/574962/

一时间都不知道怎么测试这个问题,似乎需要先搞一个 deep C-state 模拟出来才可以

Tick Devices

struct tick_device 只是 struct clock_event_device 的封装:

enum tick_device_mode {
	TICKDEV_MODE_PERIODIC,
	TICKDEV_MODE_ONESHOT,
};

struct tick_device {
	struct clock_event_device *evtdev;
	enum tick_device_mode mode;
};

Again, the kernel distinguishes global and local (per-CPU) tick devices. The local devices are collected in tick_cpu_device (defined in kernel/time/tick-internal.h). Note that the kernel automatically creates a tick device when a new clock event device is registered.

Several global variables are additionally defined in include/time/tick-internal.h:

To set up a tick device, the kernel provides the function tick_setup_device. The prototype is as follows, and the code flow diagram is depicted in Figure 15-8

先看看代码

broadcast 还是和 idle 机制联系到一起的 : cpuidle_enter_state

感觉还是需要使用 n100 的机器来调试测试一下。

分析一下 tick_nohz_idle_exit

tick_freeze -- 这个是系统 suspend 的时候处理的
tick_suspend -- 最终被 tick_freeze 调用
tick_handle_periodic / tick_nohz_handler -- 模式不对

amd_e400_idle 和 broadcast tick 的关系

之前在某一个虚拟机中观察到了:

#14 [ffffffff819e7e90] default_idle at ffffffff816ab33e
#15 [ffffffff819e7eb0] amd_e400_idle at ffffffff810347be
#16 [ffffffff819e7ed8] arch_cpu_idle at ffffffff81035006
#17 [ffffffff819e7ee8] cpu_startup_entry at ffffffff810e7bca
#18 [ffffffff819e7f30] rest_init at ffffffff81692c57
#19 [ffffffff819e7f40] start_kernel at ffffffff81b45060
#20 [ffffffff819e7f88] x86_64_start_reservations at ffffffff81b445ef
#21 [ffffffff819e7f98] x86_64_start_kernel at ffffffff81b44740
commit cb81deefb59de01325ab822f900c13941bfaf67f
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Feb 28 23:13:00 2024 +0100

    x86/idle: Sanitize X86_BUG_AMD_E400 handling

    amd_e400_idle(), the idle routine for AMD CPUs which are affected by
    erratum 400 violates the RCU constraints by invoking tick_broadcast_enter()
    and tick_broadcast_exit() after the core code has marked RCU non-idle.  The
    functions can end up in lockdep or tracing, which rightfully triggers a
    RCU warning.

    The core code provides now a static branch conditional invocation of the
    broadcast functions.

    Remove amd_e400_idle(), enforce default_idle() and enable the static branch
    on affected CPUs to cure this.

      [ bp: Fold in a fix for a IS_ENABLED() check fail missing a "CONFIG_"
        prefix which tglx spotted. ]

    Reported-by: Borislav Petkov <bp@alien8.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/877cim6sis.ffs@tglx

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。