Skip to contentSkip to conversation

Install kernel module for active watchdog

PATCH Superseded Pratyush Anand 2 participants 5 messages Mar 7, 2016 2 messages not in the archive

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Install kernel module for active watchdog

Changes since V2:
-- Added one more patch to update rd.driver.pre with watchdog module name, so that they are loaded into kernel as early as possible.
-- Removed creation of tmp/active-watchdogs. modinfo will be helpful for kexec-tools.
-- Now we add modules for active watchdog in hostonly mode and modules for all watchdog in no-hostonly mode.

Changes since RFC:
-- Added one more patch to take care that dracut does not add watchdog hooks when systemd module is included. In that case systemd daemon will manage watchdog for kicking.
-- Removed --nowdt argument. User can use -o or --omit when wathdog module is not needed. Thanks Harald for this suggestion.
-- Now I also do not check for "hostonly" to add modules for active watchdog. It seems reasonable to add kernel watchdog modules whenever, dracut watchdog module has been added.

Pratyush Anand (3):
watchdog: Do not add hooks if systemd module is included
watchdog: install module for active watchdog
watchdog: ensure that module is loaded as early as possible

Cc Dave Young <[email protected]>
Cc Don Zickus <[email protected]>
Cc Harald Hoyer <[email protected]>
 modules.d/04watchdog/module-setup.sh | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
Signature · 1 line
2.5.0

A message that is not in the archive (sent off-list or not yet received): cover.1457321591.git.panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH v3 1/3 watchdog: Do not add hooks if systemd module is included

When systemd is present, let it manage watchdog feed.

Cc Dave Young <[email protected]>
Cc Don Zickus <[email protected]>
Cc Harald Hoyer <[email protected]>
---
 modules.d/04watchdog/module-setup.sh | 5 +++++
 1 file changed, 5 insertions(+)
modules.d/04watchdog/module-setup.sh +5 -0
index 576c589c198d..7ec757aec032 100755
@@ -12,6 +12,11 @@ depends() {
 
 # called by dracut
 install() {
+    # Do not add watchdog hooks if systemd module is included
+    # In that case, systemd will manage watchdog kick
+    if dracut_module_included "systemd"; then
+	    return
+    fi
     inst_hook cmdline   00 "$moddir/watchdog.sh"
     inst_hook cmdline   50 "$moddir/watchdog.sh"
     inst_hook pre-trigger 00 "$moddir/watchdog.sh"
Signature · 1 line
2.5.0
#3 lore raw

PATCH v3 2/3 watchdog: install module for active watchdog

In reply to a message not in the archive

Recently following patches have been added in upstream Linux kernel, which
(1) fixes parent of watchdog_device so that /sys/class/watchdog/watchdogn/device is populated. (2) adds some sysfs device attributes so that different watchdog status can be read.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6551881c86c791237a3bebf11eb3bd70b60ea782
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=906d7a5cfeda508e7361f021605579a00cd82815
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=33b711269ade3f6bc9d9d15e4343e6fa922d999b

With the above support, now we can find out whether a watchdog is active or not. We can also find out the driver/module responsible for that watchdog device.

Proposed patch uses above support and then adds module of active watchdog in initramfs generated by dracut for hostonly mode. Kernel module for inactive watchdog will be added as well for none hostonly mode.

When an user does not want to add kernel module, then one should exclude complete dracut watchdog module with --omit.

Testing:
-- When watchdog is active watchdog modules were added

	# cat /sys/class/watchdog/watchdog0/identity
	iTCO_wdt
	# cat /sys/class/watchdog/watchdog0/state
	active
	# dracut --hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img | grep iTCO
	-rw-r--r--   1 root     root         9100 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_vendor_support.ko
	-rw-r--r--   1 root     root        19252 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_wdt.ko

-- When watchdog is inactive then watchdog modules were not added

	# cat /sys/class/watchdog/watchdog0/state
	inactive
	# dracut --hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img | grep iTCO

-- When watchdog is inactive, but no hostonly mode, watchdog modules were added

	# cat /sys/class/watchdog/watchdog0/state
	inactive
	# dracut --no-hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img | grep iTCO
	-rw-r--r--   1 root     root         9100 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_vendor_support.ko
	-rw-r--r--   1 root     root        19252 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_wdt.ko
Cc Dave Young <[email protected]>
Cc Don Zickus <[email protected]>
Cc Harald Hoyer <[email protected]>
---
 modules.d/04watchdog/module-setup.sh | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
modules.d/04watchdog/module-setup.sh +30 -0
index 7ec757aec032..62e3fdf7829f 100755
@@ -32,3 +32,33 @@ install() {
     inst_multiple -o wdctl
 }
 
+installkernel() {
+    cd /sys/class/watchdog
+    for dir in */; do
+	    cd $dir
+	    active=`[ -f state ] && cat state`
+	    if ! [[ $hostonly ]] || [[ "$active" =  "active" ]]; then
+		    # device/modalias will return driver of this device
+		    wdtdrv=`cat device/modalias`
+		    # There can be more than one module represented by same
+		    # modalias. Currently load all of them.
+		    # TODO: Need to find a way to avoid any unwanted module
+		    # represented by modalias
+		    wdtdrv=`modprobe -R $wdtdrv | tr "\n" "," | sed 's/.$//'`
+		    instmods $wdtdrv
+		    # however in some cases, we also need to check that if
+		    # there is a specific driver for the parent bus/device.
+		    # In such cases we also need to enable driver for parent
+		    # bus/device.
+		    wdtppath="device/..";
+		    while [ -f "$wdtppath/modalias" ]
+		    do
+			    wdtpdrv=`cat $wdtppath/modalias`
+			    wdtpdrv=`modprobe -R $wdtpdrv | tr "\n" "," | sed 's/.$//'`
+			    instmods $wdtpdrv
+			    wdtppath="$wdtppath/.."
+		    done
+	    fi
+	    cd ..
+    done
+}
Signature · 1 line
2.5.0
#4 lore raw

PATCH v3 3/3 watchdog: ensure that module is loaded as early as possible

In reply to a message not in the archive

It is expected that a watchdog module will disable an active watchdog when its probe is called ie, when it is loaded. So an early load of the module will help to disable it earlier.
This can be helpful in some corner cases where kdump and watchdog daemon both are active.

Cc Dave Young <[email protected]>
Cc Don Zickus <[email protected]>
Cc Harald Hoyer <[email protected]>
---
 modules.d/04watchdog/module-setup.sh | 7 +++++++
 1 file changed, 7 insertions(+)
modules.d/04watchdog/module-setup.sh +7 -0
index 62e3fdf7829f..7667850ece8f 100755
@@ -33,6 +33,7 @@ install() {
 }
 
 installkernel() {
+    wdtcmdline=""
     cd /sys/class/watchdog
     for dir in */; do
 	    cd $dir
@@ -46,6 +47,7 @@ installkernel() {
 		    # represented by modalias
 		    wdtdrv=`modprobe -R $wdtdrv | tr "\n" "," | sed 's/.$//'`
 		    instmods $wdtdrv
+		    wdtcmdline="$wdtcmdline$wdtdrv,"
 		    # however in some cases, we also need to check that if
 		    # there is a specific driver for the parent bus/device.
 		    # In such cases we also need to enable driver for parent
@@ -56,9 +58,14 @@ installkernel() {
 			    wdtpdrv=`cat $wdtppath/modalias`
 			    wdtpdrv=`modprobe -R $wdtpdrv | tr "\n" "," | sed 's/.$//'`
 			    instmods $wdtpdrv
+			    wdtcmdline="$wdtcmdline$wdtpdrv,"
 			    wdtppath="$wdtppath/.."
 		    done
 	    fi
 	    cd ..
     done
+    # ensure that watchdog module is loaded as early as possible
+    if [[ $wdtcmdline ]]; then
+	    echo "rd.driver.pre=$wdtcmdline" > ${initdir}/etc/cmdline.d/04-watchdog.conf
+    fi
 }
Signature · 1 line
2.5.0

A message that is not in the archive (sent off-list or not yet received): 28a6dc93202c66f9dfaa1ceae073040ae71508bb.1457321591.git.panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org