个人备案网站能做什么建网站 西安
- 作者: 五速梦信息网
- 时间: 2026年03月21日 11:12
当前位置: 首页 > news >正文
个人备案网站能做什么,建网站 西安,都有哪些电商平台,佛山企业网站建设公司推荐问题描述
某 4.x 内核使用 lkdtm 测试异常注入功能时#xff0c;在触发 softlockup 后#xff0c;内核一直检测不到不能触发 panic 自动重启。
排查过程
排查 softlockup 相关内核配置参数是否开启–已经开启排查 sysctl kernel.softlockup_panic 配置是否开启–已经开启排…问题描述
某 4.x 内核使用 lkdtm 测试异常注入功能时在触发 softlockup 后内核一直检测不到不能触发 panic 自动重启。
排查过程
排查 softlockup 相关内核配置参数是否开启–已经开启排查 sysctl kernel.softlockup_panic 配置是否开启–已经开启排查 sysctl kernel.panic 配置是否设置 – 正常设置排查每个核上的 watchdog_timer_fn hrtimer 定时器事件是否开启
在第四步中查看 /proc/timer_list 发现只有 0 核上开启了 watchdog_timer_fn其它核上未开启故而无法检测到 softlockup 与 hardlockup。
为什么其它核上未开启用于 softlockup 检测的 hrtimer 定时器事件
在定位这个问题前笔者对于 softlockup 的检测原理有个概要的认识知道它会在每个 cpu 核上创建一个 hrtimer 定时器来进行检测既然这个定时器都没有创建那检测不到异常也是正常的。
另外一个问题就是为什么 0 核上开启了 watchdog_timer_fn 但是也检测不到呢
在回答这个问题前笔者先分析下第一个问题粗略扫描代码发现 softlockup 检测功能的开启与 watchdog_cpumask 掩码有关此掩码配置又会受 housekeeping_mask 掩码内容影响下面基于 4.x 内核对这一过程进行分析。
watchdog_cpumask 相关代码分析
内核会在 lockup 检测器初始化时在 NO_HZ_FULL开启及 nohz_full功能运行时将未开启 nohz_full 的 cpu 核掩码写入 housekeeping_mask此后 housekeeping_mask被拷贝到 watchdog_cpumask 中否则拷贝 cpu_possible_mask 表示所有的 cpu 核掩码。
此后初始化 softlockup detector在每个 cpu 核上创建 watchdog_thread 线程仅在 watchdog_cpumask 使能的每个 cpu 核中唤醒 watchdog_thread 运行未使能的 cpu 核上创建的 watchdog_thread 不会运行。watchdog_thread 线程模拟看门狗周期性更新 softlockup watchdog实现类似于“喂狗”的操作。
系统中的 watchdog/x 线程
[rootlocalhost]# ps aux |grep watchdog
root 12 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/0]
root 13 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/1]
root 20 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/2]
root 27 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/3]
root 34 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/4]
root 41 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/5]
root 48 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/6]
root 55 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/7]
root 62 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/8]
root 69 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/9]
root 76 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/10]
root 83 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/11]
root 90 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/12]
root 97 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/13]
root 104 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/14]
root 111 0.0 0.0 0 0 ? S 02:52 0:00 [watchdog/15] watchdog_threads 定义如下
static struct smp_hotplug_thread watchdog_threads {.store softlockup_watchdog,.thread_should_run watchdog_should_run,.thread_fn watchdog,.thread_comm watchdog/%u,.setup watchdog_enable,.cleanup watchdog_cleanup,.park watchdog_disable,.unpark watchdog_enable,
};相关字段的含义如下
回调触发时机作用store在 thread_fn() 内部访问存储 watchdog 的全局变量thread_should_run()线程调度时检查决定 watchdog 线程是否需要运行thread_fn()thread_should_run() 返回 true 时执行执行 watchdog 逻辑检测软锁setup()线程创建时CPU 上线启用 watchdog初始化数据cleanup()CPU 下线线程销毁释放资源关闭 watchdogpark()CPU 下线时线程进入暂停状态不再运行unpark()CPU 重新上线重新启用 watchdog 线程thread_comm线程创建时设定 watchdog 线程的名称
这里主要描述 setup 函数与 thread_should_run 及 thread_fn 函数。setup 函数在线程执行时做初始化的操作这里对应的 watchdog_enable 函数其代码如下
static void watchdog_set_prio(unsigned int policy, unsigned int prio)
{struct sched_param param { .sched_priority prio };sched_setscheduler(current, policy, param);
}static void watchdog_enable(unsigned int cpu)
{struct hrtimer hrtimer raw_cpu_ptr(watchdog_hrtimer);/ kick off the timer for the hardlockup detector /hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);hrtimer-function watchdog_timer_fn;/ Enable the perf event /watchdog_nmi_enable(cpu);/ done here because hrtimer_start can only pin to smp_processor_id() /hrtimer_start(hrtimer, ns_to_ktime(sample_period),HRTIMER_MODE_REL_PINNED);/ initialize timestamp */watchdog_set_prio(SCHED_FIFO, MAX_RT_PRIO - 1);__touch_watchdog();
}它会初始化用于检测 softlockup 的 hrtimer此 hrtimer 周期性运行检测是否发生了 softlockup当检测到有 softlockup 发生时根据配置触发 panic、打印信息。
同时这里还做了 hardlockup 初始化老版本内核 hardlockup 使用 perf 注册一个周期性的 nmi 中断在中断中执行 hardlockup 检测。注意它还将线程的调度策略设置为 SCHED_FIFO 并将优先级设置为最大以优先调度最后立刻出发了一次喂狗操作避免错误检测。
thread_should_run 函数的触发时机
调度器决定是否唤醒 watchdog 线程 时调用。每次 CPU 进入/退出空闲状态、上下文切换 时都会检查该函数
当返回 true 时调度器会执行 watchdog 线程返回 false 则不需要执行。
经过上述分析确定开启了 nohz_full 功能的核上不会使能 softlockup 检测cat /proc/cmdline 发现我们并未设置 nohz_full 相关内核引导参数继续阅读内核源码发现它由 NO_HZ_FULL_ALL 配置使能继续对此配置进行分析。
NO_HZ_FULL_ALL 配置功能分析
内核原文
config NO_HZ_FULL_ALLbool Full dynticks system on all CPUs by default (except CPU 0)depends on NO_HZ_FULLhelpIf the user doesnt pass the nohz_full boot option todefine the range of full dynticks CPUs, consider that allCPUs in the system are full dynticks by default.Note the boot CPU will still be kept outside the range tohandle the timekeeping duty.如果用户没有传递 nohz_full 启动参数来定义完整的 dynticks cpu 的范围则默认所有 cpu 都开启此模式。请注意启动 cpucpu 0仍将保持在范围之外以处理定时任务。
测试记录如下 [rootlocalhost]# dmesg | grep NO_HZ
[ 0.000000] NO_HZ: Clearing 0 from nohz_full range for timekeeping
[ 0.000000] NO_HZ: Full dynticks CPUs: 1-127. 除引导核外所有使能了 nohz_full 功能的 cpu 核会从 housekeeping 掩码中去掉这样在 softlockup 初始化的时候就不会在这些核上启动检测 softlockup 的 hrtimer 定时器事件这就是内核没有检测到软锁并触发 panic 的根本原因。
同时 softlockup 检测的作用范围是单个核一个核上的定时器事件只能检测该核上的 softlockup这样即便 0 核上开启了 softlokcup 检测但是触发 softlockup 的核非 0 核时在问题场景也无法正常工作。
内核主线移除 NO_HZ_FULL_ALL 配置的修改
commit a7c8655b073d89303911c89d0fd9fc4be7631fbe
Author: Paul E. McKenney paulmckkernel.org
Date: Thu Nov 30 15:36:35 2017 -0800sched/isolation: Eliminate NO_HZ_FULL_ALLCommit 6f1982fedd59 (sched/isolation: Handle the nohz_full parameter)broke CONFIG_NO_HZ_FULL_ALLy kernels. This breakage is due to the codeunder CONFIG_NO_HZ_FULL_ALL failing to invoke the shiny new housekeepingfunctions. This means that rcutorture scenario TREE04 now emits RCU CPUstall warnings due to the RCU grace-period kthreads not being awakenedat a time of their choosing, or perhaps even not at all:[ 27.731422] rcu_bh kthread starved for 21001 jiffies! g18446744073709551369 c18446744073709551368 f0x0 RCU_GP_WAIT_FQS(3) -state0x402 -cpu3[ 27.731423] rcu_bh I14936 9 2 0x80080000[ 27.731435] Call Trace:[ 27.731440] __schedule0x31a/0x6d0[ 27.731442] schedule0x31/0x80[ 27.731446] schedule_timeout0x15a/0x320[ 27.731453] ? call_timer_fn0x130/0x130[ 27.731457] rcu_gp_kthread0x66c/0xea0[ 27.731458] ? rcu_gp_kthread0x66c/0xea0Because no one has complained about CONFIG_NO_HZ_FULL_ALLy being broken,I hypothesize that no one is in fact using it, other than rcutorture.This commit therefore eliminates CONFIG_NO_HZ_FULL_ALL and updatesrcutortures config files to instead use the nohz_full kernel parameterto put the desired CPUs into nohz_full mode.Fixes: 6f1982fedd59 (sched/isolation: Handle the nohz_full parameter)Reported-by: kernel test robot xiaolong.yeintel.comSigned-off-by: Paul E. McKenney paulmcklinux.vnet.ibm.comCc: Frederic Weisbecker frederickernel.orgCc: Thomas Gleixner tglxlinutronix.deCc: Chris Metcalf cmetcalfmellanox.comCc: Christoph Lameter cllinux.comCc: Linus Torvalds torvaldslinux-foundation.orgCc: Luiz Capitulino lcapitulinoredhat.comCc: Mike Galbraith efaultgmx.deCc: Peter Zijlstra peterzinfradead.orgCc: Rik van Riel rielredhat.comCc: Wanpeng Li kernellwpgmail.comCc: Ingo Molnar mingokernel.orgCc: John Stultz john.stultzlinaro.orgCc: Jonathan Corbet corbetlwn.netlinux 内核 v4.15 版本移除了 NO_HZ_FULL_ALL 选项后续内核版本不存在此问题。
问题延伸watchdog_cpumask 配置
通过写入 watchdog_cpumask文件能够动态配置 watchdog 线程进入暂停、运行状态以此来使能指定核上的 softlockup 检测。 它保存了掩码的值不支持特殊的格式当写入后内核会通过 park、unpark 机制来暂停、运行指定核上的 watchdog_thread 线程来达到动态配置的效果。
如何解决此问题
根据分析情况高版本内核也已经不具备此配置关闭 CONFIG_NOHZ_FULL_ALL 配置能够解决此问题这里隐含着一个问题就是对于开启了 nohz_full 的 cpu 核软硬锁检测功能将会失效。
总结
nohz_full 功能是针对 cpu 性能的一个优化通过减少 cpu 核上运行的时钟中断来提高程序性能。需要注意的是开启了此功能对现有内核检测机制的影响例如这里的 softlockup 检测失效的问题。
softlockup 检测作为一种可靠性的功能此问题的存在表明产品在追求高性能的同时设计中也需要兼顾可靠性能力有时候这两者可能还存在一些冲突需要权衡。
- 上一篇: 个人备案网站可以做产品推广怎么做公众号小程序
- 下一篇: 个人备案域名可以做哪些网站吗建设云网站
相关文章
-
个人备案网站可以做产品推广怎么做公众号小程序
个人备案网站可以做产品推广怎么做公众号小程序
- 技术栈
- 2026年03月21日
-
个人备案能做什么网站织梦网站调用工具
个人备案能做什么网站织梦网站调用工具
- 技术栈
- 2026年03月21日
-
个人备案能做什么网站建设门户网站费用
个人备案能做什么网站建设门户网站费用
- 技术栈
- 2026年03月21日
-
个人备案域名可以做哪些网站吗建设云网站
个人备案域名可以做哪些网站吗建设云网站
- 技术栈
- 2026年03月21日
-
个人博客网站搭建模板工商注册查询官网
个人博客网站搭建模板工商注册查询官网
- 技术栈
- 2026年03月21日
-
个人博客网站建设方案资质升级业绩备案在哪个网站做
个人博客网站建设方案资质升级业绩备案在哪个网站做
- 技术栈
- 2026年03月21日






