Install kernel module for active watchdog
v5 cover Install kernel module for active watchdog
Changes since V4:
-- Renamed 04watchdog.conf to 00watchdog.conf Changes since V3:
-- Incorporated changes suggested by Harald for V2 patches
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
modules.d/04watchdog/module-setup.sh | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Signature · 1 line
2.5.0
A message that is not in the archive (sent off-list or not yet received): cover.1458099200.git.panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH v5 1/3 watchdog: Do not add hooks if systemd module is included
When systemd is present, let it manage watchdog feed.
--- modules.d/04watchdog/module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+)
modules.d/04watchdog/module-setup.sh +5 -0
@@ -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
PATCH v5 2/3 watchdog: install module for active watchdog
In reply to a message not in the archiveRecently 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
--- modules.d/04watchdog/module-setup.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
modules.d/04watchdog/module-setup.sh +28 -0
@@ -32,3 +32,31 @@ install() { inst_multiple -o wdctl } +installkernel() { + [[ -d /sys/class/watchdog/ ]] || return + for dir in /sys/class/watchdog/*; do + [[ -d "$dir" ]] || continue + [[ -f "$dir/state" ]] || continue + active=$(< "$dir/state") + ! [[ $hostonly ]] || [[ "$active" = "active" ]] || continue + # device/modalias will return driver of this device + wdtdrv=$(< "$dir/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) + 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=$(readlink -f "$dir/device/..") + while [ -f "$wdtppath/modalias" ] + do + wdtpdrv=$(< "$wdtppath/modalias") + wdtpdrv=$(modprobe -R $wdtpdrv) + instmods $wdtpdrv + wdtppath=$(readlink -f "$wdtppath/..") + done + done +}
Signature · 1 line
2.5.0
PATCH v5 3/3 watchdog: ensure that module is loaded as early as possible
In reply to a message not in the archiveIt 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.
Testing:
-- When watchdog kernel modules were added
# dracut --no-hostonly initramfs-test.img -a watchdog # lsinitrd initramfs-test.img -f etc/cmdline.d/04-watchdog.conf rd.driver.pre=iTCO_wdt,lpc_ich,
--- modules.d/04watchdog/module-setup.sh | 5 +++++ 1 file changed, 5 insertions(+)
modules.d/04watchdog/module-setup.sh +5 -0
@@ -34,6 +34,7 @@ install() { installkernel() { [[ -d /sys/class/watchdog/ ]] || return + wdtcmdline="" for dir in /sys/class/watchdog/*; do [[ -d "$dir" ]] || continue [[ -f "$dir/state" ]] || continue
@@ -47,6 +48,7 @@ installkernel() { # represented by modalias wdtdrv=$(modprobe -R $wdtdrv) instmods $wdtdrv + wdtcmdline="$wdtcmdline$(echo $wdtdrv | tr " " ",")," # 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.
@@ -56,7 +58,10 @@ installkernel() { wdtpdrv=$(< "$wdtppath/modalias") wdtpdrv=$(modprobe -R $wdtpdrv) instmods $wdtpdrv + wdtcmdline="$wdtcmdline$(echo $wdtpdrv | tr " " ",")," wdtppath=$(readlink -f "$wdtppath/..") done done + # ensure that watchdog module is loaded as early as possible + [[ $wdtcmdline = "" ]] || echo "rd.driver.pre=$wdtcmdline" > ${initdir}/etc/cmdline.d/00-watchdog.conf }
Signature · 1 line
2.5.0
A message that is not in the archive (sent off-list or not yet received): 2751555c29f26f69a63888745513edeceb39d416.1458099200.git.panand-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH V5 dracut (Resend)3/3] watchdog: ensure that module is loaded as early as possible
Patchset imported to github.
Pull request:
<https://github.com/haraldh/dracut/compare/master...dracut-mailing-devs:2751555c29f26f69a63888745513edeceb39d416.1458099200.git.panand%40redhat.com>
Re: [PATCH V5 dracut 3/3] watchdog: ensure that module is loaded as early as possible
In reply to a message not in the archiveQuoted 10 lines · Pratyush Anand
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.Testing:
-- When watchdog kernel modules were added
# dracut --no-hostonly initramfs-test.img -a watchdog # lsinitrd initramfs-test.img -fetc/cmdline.d/04-watchdog.conf
Sorry, please ignore this patch and take "resend" if there is not any further comment.
~Pratyush
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH V5 dracut 3/3] watchdog: ensure that module is loaded as early as possible
Quoted 14 lines · Pratyush Anand
Quoted 10 lines · Pratyush Anand
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.Testing:
-- When watchdog kernel modules were added
# dracut --no-hostonly initramfs-test.img -a watchdog # lsinitrd initramfs-test.img -fetc/cmdline.d/04-watchdog.conf
Quoted 8 lines
Sorry, please ignore this patch and take "resend" if there is not any further comment.
~Pratyush
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Imported to github:
https://github.com/dracutdevs/dracut/pull/121
I will comment there.
Quoted 30 lines · Pratyush Anand
Changes since V4:
-- Renamed 04watchdog.conf to 00watchdog.conf Changes since V3:
-- Incorporated changes suggested by Harald for V2 patchesChanges 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
Quoted 7 lines
Cc Dave Young <[email protected]>Cc Don Zickus <[email protected]>Cc Harald Hoyer <[email protected]>modules.d/04watchdog/module-setup.sh | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
pushed, please review my changes:
<https://github.com/dracutdevs/dracut/commit/74e2d1e69f5527ab31b01fc19f67143d1f091980>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Harald,
Quoted 2 lines · Harald Hoyer
pushed, please review my changes:
<https://github.com/dracutdevs/dracut/commit/74e2d1e69f5527ab31b01fc19f67143d1f091980>
Thanks for rewriting the module nicely. I have to learn a lot in shell scripting :-).
I have commented at github. I found two errors during my testing:
(1) A case when install_kenrel() may not return 0 and it will cause to fail dracut process.
(2) _wdtppath calculation before while loop need to be corrected, otherwise we will not be able to install parent device's driver.
Following patches on top op upstream/master is working fine.
modules.d/04watchdog/module-setup.sh +2 -2
@@ -56,7 +56,7 @@ installkernel() { # 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=$(readlink -f "$_dir/device/..") + _wdtppath=$(readlink -f "$_dir/device/") while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do _wdtppath=$(readlink -f "$_wdtppath/..") [[ -f "$_wdtppath/modalias" ]] || continue
@@ -73,5 +73,5 @@ installkernel() { done # ensure that watchdog module is loaded as early as possible _alldrivers="${!_drivers[*]}" - [[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf + [[ $_alldrivers = "" ]] || echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf }
~Pratyush