免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
watchdog(二)

如果CPU可以響應(yīng)中斷,但是在長(zhǎng)時(shí)間內(nèi)不能調(diào)度(比如禁止搶占時(shí)間太長(zhǎng)),此時(shí)就需要一種機(jī)制(softlockup)來(lái)檢測(cè)這種情形。

本文基于3.14.25

記錄下第二種比較嚴(yán)重的“死鎖”:禁止搶占的時(shí)間太長(zhǎng),此時(shí)依舊可以相應(yīng)中斷,但是本CPU上在長(zhǎng)時(shí)間內(nèi)沒(méi)有發(fā)生調(diào)度。                      
檢測(cè)機(jī)制:softlockup

reset_init|-->kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);kernel_init|-->kernel_init_freeable();    |-->lockup_detector_init();        |-->watchdog_enable_all_cpus(false);            |-->smpboot_register_percpu_thread(&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,};smpboot_register_percpu_thread(&watchdog_threads)|-->__smpboot_create_thread(&watchdog_threads, cpu);
165
static int __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu)166 {167 struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu);168 struct smpboot_thread_data *td;169 +-- 4 lines: if (tsk)---173 td = kzalloc_node(sizeof(*td), GFP_KERNEL, cpu_to_node(cpu));174 +--- 2 lines: if (!td)---176 td->cpu = cpu;177 td->ht = ht;178 +-- 8 lines: tsk = kthread_create_on_cpu(smpboot_thread_fn, td, cpu,----186 *per_cpu_ptr(ht->store, cpu) = tsk;187 +-- 12 lines: if (ht->create) {---199 return 0;200 }

 

創(chuàng)建了一個(gè)線程A task,該線程的主函數(shù)為 smpboot_thread_fun,該線程存儲(chǔ)于watchdog_threads.store中過(guò)程(閱讀smpboot_thread_fn):1、調(diào)用setup:watchdog_enable;2、調(diào)用thread_should_run:watchdog_should_run判定是否需要運(yùn)行線程主函數(shù)3、線程主函數(shù)thread_fn:watchdogwatchdog_enable|-->struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer);|-->hrtimer->function = watchdog_timer_fn;|-->hrtimer_start(hrtimer, ns_to_ktime(sample_period), HRTIMER_MODE_REL_PINNED);|-->watchdog_set_prio(SCHED_FIFO, MAX_RT_PRIO - 1);//實(shí)時(shí)優(yōu)先級(jí)這個(gè)函數(shù)比較重要,因?yàn)椋篈 task中主函數(shù)為smpboot_thread_fun,其中將會(huì)檢測(cè)是否運(yùn)行thread_fn:watchdogwatchdog_should_run|-->return __this_cpu_read(hrtimer_interrupts) != __this_cpu_read(soft_lockup_hrtimer_cnt);因此如果hrtimer_interrupts == soft_lockup_hrtimer_cnt成立則運(yùn)行調(diào)度器(放棄CPU使用權(quán)),否則運(yùn)行thread_fn:watchdog我們看下thread_fn的職責(zé):watchdog:|-->__this_cpu_write(soft_lockup_hrtimer_cnt, __this_cpu_read(hrtimer_interrupts));|--> __this_cpu_write(watchdog_touch_ts, get_timestamp());再看下hrtimer定時(shí)的職責(zé):static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)|-->unsigned long touch_ts = __this_cpu_read(watchdog_touch_ts);|-->__this_cpu_inc(hrtimer_interrupts); 記錄hrtimer中斷次數(shù)|-->wake_up_process(__this_cpu_read(softlockup_watchdog));//喚醒創(chuàng)建的 A task,雖然被喚醒,但并不意味著就能得到調(diào)度|-->hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));|-->duration = is_softlockup(touch_ts);//判定當(dāng)前時(shí)間與touch_ts的時(shí)間差是否超過(guò)20s,|   如果超過(guò),說(shuō)明發(fā)生了softlockup,否則說(shuō)明沒(méi)有發(fā)生。

 

總結(jié):更新watchdog_touch_ts的是一個(gè)具有實(shí)時(shí)優(yōu)先級(jí)的線程A task,既然是線程就存在是否得到調(diào)度的問(wèn)題。如果在20s內(nèi),該線程沒(méi)有得到調(diào)度,則說(shuō)
明發(fā)生了softlockup。因?yàn)榘凑赵韥?lái)說(shuō),實(shí)時(shí)優(yōu)先級(jí)線程A task一定比普通優(yōu)先級(jí)線程先得到調(diào)度。如果一個(gè)線程B禁止調(diào)度長(zhǎng)達(dá)20s,則無(wú)論如何
wake_up_process,A task都是不會(huì)被調(diào)度到的,即watchdog_touch_ts是不會(huì)得到更新的。而softlockup的檢測(cè)是放在一個(gè)hrtimer處理函數(shù)中的。關(guān)于該函數(shù)是在中斷上半部運(yùn)行還是下半部運(yùn)行,我還不清楚,但是由于其在中斷上下文運(yùn)行,想必也是具有高”優(yōu)先級(jí)“的。
至于hrtimer的運(yùn)行周期為:watchdog_thresh * 2 / 5 = 4s,我認(rèn)為只是加大了喚醒A task的次數(shù)(wake_up_process),畢竟在20s嘗試4次喚醒A task時(shí),只要A task有一次得到調(diào)度的機(jī)會(huì)就可以更新 wathchdog_touch_ts,也就不會(huì)判定發(fā)生softlockup.

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
softlockup檢測(cè)(watchdog)原理(用于檢測(cè)系統(tǒng)調(diào)度是否正常)
linux 內(nèi)核筆記之watchdog
淺談linux的死鎖檢測(cè)
嵌套OOPS導(dǎo)致系統(tǒng)卡死 每個(gè)CPU都上報(bào)softlockup的問(wèn)題
Linux 進(jìn)程中 Stop, Park, Freeze
delay work and hrtimer
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服