Changes between Version 9 and Version 10 of watchdog


Ignore:
Timestamp:
02/03/2026 07:40:10 PM (3 days ago)
Author:
Tim Harvey
Comment:

updated watchdog examples for modern kernels

Legend:

Unmodified
Added
Removed
Modified
  • watchdog

    v9 v10  
    6161The Linux kernel has a [http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/watchdog/watchdog-api.txt watchdog driver API] that can be implemented to provide a common userspace API to a hardware watchdog.
    6262
    63 Most Linux watchdog drivers have a {{{nowayout}}} kernel parameter which can be defaulted at build time via the kernel config {{{CONFIG_WATCHDOG_NOWAYOUT}}} or passed in via a parameter during module loading or via bootargs. Drivers that support this should display the nowayout setting upon driver init. If {{{nowayout=1}}} the driver does not allow the watchdog to be disabled (no way out of the situation). This is desireable in high reliability cases as the normal API behavior is to start the watchdog when {{{/dev/watchdog}}} is opened by the userspace app, and stop/disable the watchdog when it is closed (which can happen if the userspace watchdog process is killed or even crashes).
    64 
    65 Example trying to kill the watchdog:
    66 {{{
    67 #!bash
    68 root@ventana:~# ps
    69   PID USER       VSZ STAT COMMAND
    70     1 root      1676 S    init [5]
    71     2 root         0 SW   [kthreadd]
    72     3 root         0 SW   [ksoftirqd/0]
    73 ....
    74   467 root      1720 S    watchdog
    75 
    76 
    77 root@ventana:~# kill -9 467
    78 [   49.320282] watchdog watchdog0: nowayout prevents watchdog being stopped!
    79 [   49.327081] watchdog watchdog0: watchdog did not stop!
    80 }}}
     63Most Linux watchdog drivers have a {{{nowayout}}} kernel parameter which can be defaulted at build time via the kernel config {{{CONFIG_WATCHDOG_NOWAYOUT}}} or passed in via a parameter during module loading or via bootargs. If {{{nowayout=1}}} the driver does not allow the watchdog to be disabled (no way out of the situation). This is desirable in high reliability cases as the normal API behavior is to start the watchdog when {{{/dev/watchdog}}} is opened by the userspace app, and stop/disable the watchdog when it is closed (which can happen if the userspace watchdog process is killed or even crashes).
     64
     65Examples:
     66- IMX SoC:
     67 * enabling nowayout via U-Boot bootargs:
     68{{{#!bash
     69u-boot=> setenv bootargs "$bootargs imx2_wdt.nowayout=1"; saveenv
     70}}}
     71 * show watchdog source/driver:
     72{{{#!bash
     73# cat /sys/class/watchdog/watchdog0/identity
     74imx2+ watchdog
     75}}}
     76 * show nowayout:
     77{{{#!bash
     78# cat /sys/class/watchdog/watchdog0/nowayout
     791
     80}}}
     81 * show module details for imx2_wdt (watchdog found in IMX SoC's)
     82{{{#!bash
     83# modinfo imx2_wdt
     84name:           imx2_wdt
     85filename:       (builtin)
     86alias:          platform:imx2-wdt
     87license:        GPL v2
     88file:           drivers/watchdog/imx2_wdt
     89description:    Watchdog driver for IMX2 and later
     90author:         Wolfram Sang
     91parm:           nowayout:Watchdog cannot be stopped once started (default=0) (bool)
     92parm:           timeout:Watchdog timeout in seconds (default=60) (uint)
     93}}}
     94 * killing watchdog process
     95{{{#!bash
     96root@noble-venice:~# echo 8 > /proc/sys/kernel/printk
     97root@noble-venice:~# fuser /dev/watchdog
     98/dev/watchdog:         507
     99root@noble-venice:~# ps -ef  | grep 507
     100root         507       1  0 19:37 ?        00:00:00 /usr/sbin/watchdog
     101root         557     538  0 19:38 ttymxc1  00:00:00 grep --color=auto 507
     102root@noble-venice:~# kill -9 507
     103root@noble-venice:~# [   55.457477] watchdog: watchdog0: watchdog did not stop!
     104root@noble-venice:~# fuser /dev/watchdog
     105/dev/watchdog:         567
     106root@noble-venice:~# ps -ef  | grep 567
     107root         567       1  0 19:38 ?        00:00:00 /usr/sbin/wd_keepalive
     108root         574     538  0 19:38 ttymxc1  00:00:00 grep --color=auto 567
     109root@noble-venice:~# kill -9 567
     110root@noble-venice:~# [   68.062109] watchdog: watchdog0: watchdog did not stop!
     111[  117.146646] watchdog: watchdog0: watchdog did not stop!
     112...
     113U-Boot SPL 2024.10-00060-g6b9a0425420c (Jan 29 2026 - 17:17:43 -0800)
     114GSCv3   : v65 0x42a7 RST:CPU Thermal protection:enabled at 96C
     115}}}
     116 * Within 30 seconds of killing the watchdog processes the board reboots with a RST:CPU which indicates CPU watchdog
     117 * Note on Ubuntu root filesystems typically once /sbin/watchdog dies systemd launches /usr/sbin/wd_keepalive
    81118
    82119