亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 10310 | 回復: 9
打印 上一主題 下一主題

[內(nèi)核入門] 求教育,關(guān)于NMI watchdog [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2013-01-22 19:29 |只看該作者 |倒序瀏覽
6可用積分
NMI watchdog到底是稱為硬狗還是軟狗?

如果是軟狗,那么什么時候喂狗呢? 即touch_nmi_watchdog()被調(diào)用的時機是怎樣的?

如果是硬狗,可是喂硬狗通常都是給一個一定長度的脈沖,不涉及nmi_touch這個percpu變量啊。

請了解的同學不吝賜教,謝謝

論壇徽章:
0
2 [報告]
發(fā)表于 2013-01-23 00:49 |只看該作者
nmi watchdog應該是軟狗,應該是每次nmi中斷的時候喂狗

論壇徽章:
0
3 [報告]
發(fā)表于 2013-01-23 08:48 |只看該作者
每次NMI中斷來的時候調(diào)用nmi_watchdog_tick()是去檢測是否喂狗吧,而不是去喂狗,檢測到?jīng)]喂狗就die_nmi()了。回復 2# luoyan_xy


   

論壇徽章:
4
酉雞
日期:2014-03-21 23:19:50獅子座
日期:2014-08-01 22:11:40酉雞
日期:2015-01-10 21:31:442015年辭舊歲徽章
日期:2015-03-03 16:54:15
4 [報告]
發(fā)表于 2013-01-23 09:24 |只看該作者
有2種:
I/O APIC watchdog開銷大
Local APIC watchdog開銷小
通過nmi_watchdog變量控制.

原理都是do_nmi()中遞增計數(shù)器.而在被監(jiān)控的地方重置計數(shù)器.

我的理解,如果不正,請指點,謝謝!

論壇徽章:
0
5 [報告]
發(fā)表于 2013-01-24 18:06 |只看該作者
來個大俠回答一下哇

論壇徽章:
0
6 [報告]
發(fā)表于 2013-04-13 20:46 |只看該作者
回復 1# nevastill
1. 在hung_task模塊初始化時會啟動一個內(nèi)核線程khungtaskd執(zhí)行watchdog函數(shù)
  1. static int __init hung_task_init(void)
  2. {
  3.         atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
  4.         watchdog_task = kthread_run(watchdog, NULL, "khungtaskd");

  5.         return 0;
  6. }

  7. module_init(hung_task_init);
復制代碼
2. 在線程khungtaskd中執(zhí)行check_hung_uninterruptible_tasks
  1. static int watchdog(void *dummy)
  2. {
  3.         set_user_nice(current, 0);

  4.         for ( ; ; ) {
  5.                 unsigned long timeout = sysctl_hung_task_timeout_secs;

  6.                 while (schedule_timeout_interruptible(timeout_jiffies(timeout)))
  7.                         timeout = sysctl_hung_task_timeout_secs;

  8.                 check_hung_uninterruptible_tasks(timeout);
  9.         }

  10.         return 0;
  11. }
復制代碼
3. check_hung_uninterruptible_tasks->check_hung_task->touch_nmi_watchdog

  1. static void check_hung_task(struct task_struct *t, unsigned long timeout)
  2. {
  3.         ... ...
  4.         touch_nmi_watchdog();

  5.         if (sysctl_hung_task_panic)
  6.                 panic("hung_task: blocked tasks");
  7. }
復制代碼
4. 在touch_nmi_watchdog設(shè)置pcpu變量nmi_touch
  1. void touch_nmi_watchdog(void)
  2. {
  3.         if (nmi_watchdog_active()) {
  4.                 unsigned cpu;

  5.                 /*
  6.                  * Tell other CPUs to reset their alert counters. We cannot
  7.                  * do it ourselves because the alert count increase is not
  8.                  * atomic.
  9.                  */
  10.                 for_each_present_cpu(cpu) {
  11.                         if (per_cpu(nmi_touch, cpu) != 1)
  12.                                 per_cpu(nmi_touch, cpu) = 1;
  13.                 }
  14.         }

  15.         /*
  16.          * Tickle the softlockup detector too:
  17.          */
  18.         touch_softlockup_watchdog();
  19. }
復制代碼
5. 在nmi中斷處理do_nmi進行nmi_touch變量的檢查,如果不為1,則計數(shù)加1,計數(shù)超過預設(shè)值,則調(diào)用die_nmi
代碼流程:entry_32.s->call do_nmi->default_do_nmi->nmi_watchdog_tick

  1. notrace __kprobes int
  2. nmi_watchdog_tick(struct pt_regs *regs, unsigned reason)
  3. {
  4.         ... ...
  5.         if (__get_cpu_var(nmi_touch)) { /*進行pcpu變量touched的檢查,如果為1,則置touched標志*/
  6.                 __get_cpu_var(nmi_touch) = 0;
  7.                 touched = 1;
  8.         }

  9.         ... ...
  10.         /* 下面對touch標志進行判斷,如果為0且nmi中斷處理沒有多次進入,則將altert_counter加1 */

  11.         /* if the none of the timers isn't firing, this cpu isn't doing much */
  12.         if (!touched && __get_cpu_var(last_irq_sum) == sum) {
  13.                 /*
  14.                  * Ayiee, looks like this CPU is stuck ...
  15.                  * wait a few IRQs (5 seconds) before doing the oops ...
  16.                  */
  17.                 __this_cpu_inc(alert_counter);
  18.                 if (__this_cpu_read(alert_counter) == 5 * nmi_hz)
  19.                         /*
  20.                          * die_nmi will return ONLY if NOTIFY_STOP happens..
  21.                          */
  22.                         die_nmi("BUG: NMI Watchdog detected LOCKUP",
  23.                                 regs, panic_on_timeout);
  24.         } else {
  25.                 /* 不然就更新中斷計數(shù),對alert_counter進行清零操作 */
  26.                 __get_cpu_var(last_irq_sum) = sum;
  27.                 __this_cpu_write(alert_counter, 0);
  28.         }

  29.         /* see if the nmi watchdog went off */
  30.         if (!__get_cpu_var(wd_enabled))
  31.                 return rc;
  32.         switch (nmi_watchdog) {
  33.         case NMI_LOCAL_APIC:
  34.                 /* 如果是APIC類型的watch_dog,調(diào)如下函數(shù)進行喂狗 */
  35.                 rc |= lapic_wd_event(nmi_hz);
  36.                 break;
  37.         case NMI_IO_APIC:
  38.                 /*
  39.                  * don't know how to accurately check for this.
  40.                  * just assume it was a watchdog timer interrupt
  41.                  * This matches the old behaviour.
  42.                  */
  43.                 rc = 1;
  44.                 break;
  45.         }
  46.         return rc;
  47. }
復制代碼
6. APIC類型的watch_dog喂狗函數(shù)
  1. int __kprobes lapic_wd_event(unsigned nmi_hz)
  2. {
  3.         struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
  4.         u64 ctr;

  5.         rdmsrl(wd->perfctr_msr, ctr);
  6.         if (ctr & wd_ops->checkbit) /* perfctr still running? */
  7.                 return 0;

  8.         wd_ops->rearm(wd, nmi_hz);
  9.         return 1;
  10. }
  11. static struct wd_ops intel_arch_wd_ops __read_mostly = {
  12.         .reserve        = single_msr_reserve,
  13.         .unreserve        = single_msr_unreserve,
  14.         .setup                = setup_intel_arch_watchdog,
  15.         .rearm                = p6_rearm,
  16.         .stop                = single_msr_stop_watchdog,
  17.         .perfctr        = MSR_ARCH_PERFMON_PERFCTR1,
  18.         .evntsel        = MSR_ARCH_PERFMON_EVENTSEL1,
  19. };
  20. static void __kprobes p6_rearm(struct nmi_watchdog_ctlblk *wd, unsigned nmi_hz)
  21. {
  22.         /*
  23.          * P6 based Pentium M need to re-unmask
  24.          * the apic vector but it doesn't hurt
  25.          * other P6 variant.
  26.          * ArchPerfom/Core Duo also needs this
  27.          */
  28.         apic_write(APIC_LVTPC, APIC_DM_NMI);

  29.         /* P6/ARCH_PERFMON has 32 bit counter write */
  30.         write_watchdog_counter32(wd->perfctr_msr, NULL, nmi_hz);
  31. }
復制代碼

論壇徽章:
0
7 [報告]
發(fā)表于 2013-08-22 18:55 |只看該作者

RE: 求教育,關(guān)于NMI watchdog

junnyg 發(fā)表于 2013-04-13 20:46
回復 1# nevastill
1. 在hung_task模塊初始化時會啟動一個內(nèi)核線程khungtaskd執(zhí)行watchdog函數(shù)2. 在線程k ...

ls講的很好很詳細,我有一些疑問,想進一步問一下:
1,ls的前5步,我試概括為內(nèi)核線程軟喂狗部分與do_nmi中對喂狗結(jié)果的檢查;(因我的內(nèi)核版本為3.6.11,很多函數(shù)已經(jīng)變化,可能理解有誤)
——能否請ls將第6步apic詳細再講一下?
2,ULK3中對nmi_watchdog的講解我有兩處想請教:
a,每個cpu上周期性的nmi中斷,是固定會產(chǎn)生?還是與nmi_watchdog配置相關(guān)呢?若固定產(chǎn)生又與中斷一章中對于nmi的描述相沖突:用于危機事件時才引起非屏蔽中斷。
b,do_nmi中是對cpu的apic_timer_irqs字段進行檢查用以判斷cpu是否被鎖死;我理解的話,也就是將在特定cpu時鐘周期內(nèi)此數(shù)值的是否增加,作為是否已喂狗的判斷。這樣,是否與ls所說的線程喂狗依據(jù)重合了呢?
3,另,查看內(nèi)核文檔,lockup_watchdog.txt中的描述,提到了“The soft and hard lockup detectors are built on top of the hrtimer and perf subsystems”,此處提到nmi狗是基于高精度和性能子系統(tǒng)的,不太明白。。

論壇徽章:
0
8 [報告]
發(fā)表于 2013-08-23 15:02 |只看該作者
nmi_watchdog與nmi中斷的一些源碼與文檔分析總結(jié),并請大牛點撥疑問
http://www.72891.cn/forum.p ... mp;fromuid=28788494

LZ可以看看答得對不對。

論壇徽章:
0
9 [報告]
發(fā)表于 2013-08-23 20:59 |只看該作者
軟狗喂狗不僅限于上中斷等情況,狗的作用是檢查長時間沒有調(diào)度,中斷,軟中斷,關(guān)中斷的進程上下文都可以喂狗,前提是你的關(guān)中斷進程上下文是一個你預期的合理的關(guān)中斷長時間占用cpu的動作,否則狗不喂就是問題



硬狗也是要喂的,他的作用是檢查處理器是否在正常運行,否則狗叫重啟
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP