Skip to contentSkip to conversation

systemd: Set RebootWatchdogSec to 60s as watchdog

PATCH In review Robert Yang 2 participants 4 messages May 27, 2022 – May 28, 2022

lore
Share & tools
lore
#0 lore raw

cover systemd: Set RebootWatchdogSec to 60s as watchdog

The following changes since commit 579906b9f4ea32c8d4e0e11a87ee6c9e27cdf0dc:

kernel.bbclass: Do not overwrite recipe's custom postinst (2022-05-23 21:31:07 +0100)

are available in the Git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/watdog
http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/watdog

Robert Yang (1):
systemd: Set RebootWatchdogSec to 60s as watchdog

 meta/recipes-core/systemd/systemd_250.5.bb        | 8 ++++++++
 meta/recipes-extended/watchdog/watchdog-config.bb | 7 +++++++
 2 files changed, 15 insertions(+)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/1 systemd: Set RebootWatchdogSec to 60s as watchdog

The systemd-shutdown sets watchdog timeout to 10m (600 seconds) which is too large, and caused errors when reboot on boars such as rpi4:

systemd-shutdown[1]: Failed to set timeout to 10min: Invalid argument

The watchog's default value is 60s, so set RebootWatchdogSec to 60s to fix the errors. And <machin.conf> can set WATCHDOG_TIMEOUT when needed, for example, the max timeout of rpi4 is 15 seconds.

---
 meta/recipes-core/systemd/systemd_250.5.bb        | 8 ++++++++
 meta/recipes-extended/watchdog/watchdog-config.bb | 7 +++++++
 2 files changed, 15 insertions(+)
meta/recipes-core/systemd/systemd_250.5.bb +8 -0
index 006b2f86eab..6fac27ee56d 100644
@@ -238,6 +238,9 @@ EXTRA_OEMESON += "-Dkexec-path=${sbindir}/kexec \
                   -Dnologin-path=${base_sbindir}/nologin \
                   -Dumount-path=${base_bindir}/umount"
 
+# The 60 seconds is watchdog's default vaule.
+WATCHDOG_TIMEOUT ??= "60"
+
 do_install() {
 	meson_do_install
 	install -d ${D}/${base_sbindir}
@@ -337,6 +340,11 @@ do_install() {
 
 	# add a profile fragment to disable systemd pager with busybox less
 	install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh
+
+    if [ -n "${WATCHDOG_TIMEOUT}" ]; then
+        sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
+            ${D}/${sysconfdir}/systemd/system.conf
+    fi
 }
 
 python populate_packages:prepend (){
meta/recipes-extended/watchdog/watchdog-config.bb +7 -0
index a28d28033bc..f1389521284 100644
@@ -13,8 +13,15 @@ SRC_URI = " \
     file://watchdog.conf \
 "
 
+# The default value is 60 seconds when null.
+WATCHDOG_TIMEOUT ??= ""
+
 do_install() {
     install -Dm 0644 ${WORKDIR}/watchdog.default ${D}${sysconfdir}/default/watchdog
     install -Dm 0644 ${WORKDIR}/watchdog.conf ${D}${sysconfdir}/watchdog.conf
+
+    if [ -n "${WATCHDOG_TIMEOUT}" ]; then
+        echo "watchdog-timeout = ${WATCHDOG_TIMEOUT}" >> ${D}/etc/watchdog.conf
+    fi
 }
 
Signature · 1 line
2.35.1
#2 lore raw

Where is the default of 10 minutes set? Should it be fixed there? Patching things with sed after the fact is not necessarily a good idea.

Alex

Quoted 74 lines · Robert Yang

The systemd-shutdown sets watchdog timeout to 10m (600 seconds) which is too large, and caused errors when reboot on boars such as rpi4:

systemd-shutdown[1]: Failed to set timeout to 10min: Invalid argument

The watchog's default value is 60s, so set RebootWatchdogSec to 60s to fix the errors. And <machin.conf> can set WATCHDOG_TIMEOUT when needed, for example, the max timeout of rpi4 is 15 seconds.

---
 meta/recipes-core/systemd/systemd_250.5.bb        | 8 ++++++++
 meta/recipes-extended/watchdog/watchdog-config.bb | 7 +++++++
 2 files changed, 15 insertions(+)
meta/recipes-core/systemd/systemd_250.5.bb +8 -0
index 006b2f86eab..6fac27ee56d 100644
@@ -238,6 +238,9 @@ EXTRA_OEMESON += "-Dkexec-path=${sbindir}/kexec \
                   -Dnologin-path=${base_sbindir}/nologin \
                   -Dumount-path=${base_bindir}/umount"
 
+# The 60 seconds is watchdog's default vaule.
+WATCHDOG_TIMEOUT ??= "60"
+
 do_install() {
        meson_do_install
        install -d ${D}/${base_sbindir}
@@ -337,6 +340,11 @@ do_install() {
 
        # add a profile fragment to disable systemd pager with busybox less
        install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh
+
+    if [ -n "${WATCHDOG_TIMEOUT}" ]; then
+        sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
+            ${D}/${sysconfdir}/systemd/system.conf
+    fi
 }
 
 python populate_packages:prepend (){
meta/recipes-extended/watchdog/watchdog-config.bb +7 -1
index a28d28033bc..f1389521284 100644
@@ -13,8 +13,15 @@ SRC_URI = " \
     file://watchdog.conf \
 "
 
+# The default value is 60 seconds when null.
+WATCHDOG_TIMEOUT ??= ""
+
 do_install() {
     install -Dm 0644 ${WORKDIR}/watchdog.default ${D}${sysconfdir}/default/watchdog
     install -Dm 0644 ${WORKDIR}/watchdog.conf ${D}${sysconfdir}/watchdog.conf
+
+    if [ -n "${WATCHDOG_TIMEOUT}" ]; then
+        echo "watchdog-timeout = ${WATCHDOG_TIMEOUT}" >> ${D}/etc/watchdog.conf
+    fi
 }
 
--

2.35.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#166202): https://lists.openembedded.org/g/openembedded-core/message/166202
Mute This Topic: https://lists.openembedded.org/mt/91371988/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

Hi Alexander,

Quoted 3 lines · Alexander Kanavin

Where is the default of 10 minutes set? Should it be fixed there? Patching things with sed after the fact is not necessarily a good idea.

It's set in src/core/main.c, line 2451:

arg_reboot_watchdog = 10 * USEC_PER_MINUTE;

The ${sysconfdir}/systemd/system.conf is used for configing it, so I didn't modify src/core/main.c, and even if we modify src/core/main.c, we still need config the value depend on the boards, for example, rpi4 (max: 15 seconds), nxp-imx8 (max: 128 seconds), other boards may have a higher or lower value than 60.

// Robert

Quoted 78 lines

Alex

Quoted 74 lines · Robert Yang

The systemd-shutdown sets watchdog timeout to 10m (600 seconds) which is too large, and caused errors when reboot on boars such as rpi4:

systemd-shutdown[1]: Failed to set timeout to 10min: Invalid argument

The watchog's default value is 60s, so set RebootWatchdogSec to 60s to fix the errors. And <machin.conf> can set WATCHDOG_TIMEOUT when needed, for example, the max timeout of rpi4 is 15 seconds.

---
  meta/recipes-core/systemd/systemd_250.5.bb        | 8 ++++++++
  meta/recipes-extended/watchdog/watchdog-config.bb | 7 +++++++
  2 files changed, 15 insertions(+)
meta/recipes-core/systemd/systemd_250.5.bb +8 -0
index 006b2f86eab..6fac27ee56d 100644
@@ -238,6 +238,9 @@ EXTRA_OEMESON += "-Dkexec-path=${sbindir}/kexec \
                    -Dnologin-path=${base_sbindir}/nologin \
                    -Dumount-path=${base_bindir}/umount"
 
+# The 60 seconds is watchdog's default vaule.
+WATCHDOG_TIMEOUT ??= "60"
+
  do_install() {
         meson_do_install
         install -d ${D}/${base_sbindir}
@@ -337,6 +340,11 @@ do_install() {
 
         # add a profile fragment to disable systemd pager with busybox less
         install -Dm 0644 ${WORKDIR}/systemd-pager.sh ${D}${sysconfdir}/profile.d/systemd-pager.sh
+
+    if [ -n "${WATCHDOG_TIMEOUT}" ]; then
+        sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
+            ${D}/${sysconfdir}/systemd/system.conf
+    fi
  }
 
  python populate_packages:prepend (){
meta/recipes-extended/watchdog/watchdog-config.bb +7 -1
index a28d28033bc..f1389521284 100644
@@ -13,8 +13,15 @@ SRC_URI = " \
      file://watchdog.conf \
  "
 
+# The default value is 60 seconds when null.
+WATCHDOG_TIMEOUT ??= ""
+
  do_install() {
      install -Dm 0644 ${WORKDIR}/watchdog.default ${D}${sysconfdir}/default/watchdog
      install -Dm 0644 ${WORKDIR}/watchdog.conf ${D}${sysconfdir}/watchdog.conf
+
+    if [ -n "${WATCHDOG_TIMEOUT}" ]; then
+        echo "watchdog-timeout = ${WATCHDOG_TIMEOUT}" >> ${D}/etc/watchdog.conf
+    fi
  }
 
--

2.35.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#166202): https://lists.openembedded.org/g/openembedded-core/message/166202
Mute This Topic: https://lists.openembedded.org/mt/91371988/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-