kexec-tools/98-kexec.rules

17 lines
695 B
Plaintext
Raw Normal View History

Rewrite kdump's udev rules According to udev's man page, PROGRAM is either used to determine device's name or whether the device matches the rule. So we should use RUN insteand. Meanwhile, both RUN / PROGRAM only accepts very short-running foreground tasks, but kdump restart may take a long time if there are any device changes that will lead to image rebuild, which may lead to buggy behavior. On the other hand, memory / CPU hot plug should never trigger a initramfs rebuild. To solve this problem, we will use new introduced "kdumpctl reload" instead, and use systemd-run to create a transient service unit for the reload and run it in no-block mode, so udev won't be blocked by anything. We need to make systemd-run execute in non-blocking mode, and do not synchronously wait for the operation to finish, because udev expect the command line in RUN to be finished immediately, however, kdumpctl reload may take 0.5-1s for an ordinary reload, or even slower on some machines. So we give systemd-run an explicit --no-block option to run in non-blocking mode. Without --no-blocking, systemd-run will verify, enqueue and wait for the operation to finish. By using the --no-block option, systemd-run will only verify and enqueue the unit then return. In this way, we make sure the command is executed asynchronously, and the status will be monitored and logged by systemd, which is reliable and non-blocking. Another thing to mention is that --no-block is only needed after systemd-v220, before v220 systemd-run uses non-blocking mode by default and --no-block option is not available on earlier systemd versions. Also reformat the udev rules to a more maintanceable format. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
2018-10-24 08:58:51 +00:00
SUBSYSTEM=="cpu", ACTION=="add", GOTO="kdump_reload"
SUBSYSTEM=="cpu", ACTION=="remove", GOTO="kdump_reload"
SUBSYSTEM=="memory", ACTION=="online", GOTO="kdump_reload"
SUBSYSTEM=="memory", ACTION=="offline", GOTO="kdump_reload"
GOTO="kdump_reload_end"
LABEL="kdump_reload"
Make udev reload rules quiet during bootup In commit 1c97aee and commit 227c185 udev rules was rewritten to use systemd-run to run in a non-blocking mode. The problem is that it's a bit noise, especially on machine bootup, systemd will always generate extra logs for service start, you might see your journal full of lines like these if you have many CPUs (each CPU generates a udev event on boot): ... Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. Nov 22 22:23:05 localhost systemd[1]: Started /usr/lib/udev/kdump-udev-throttler. ... While system is still booting up, kdump service is not started yet, so systemd-run calls will end up doing nothing, the throttler being called by systemd-run will just exit if kdump is not loaded. This patch avoid systemd-run from being called at first place if kdump service is not running by checking kdump.service status in udev rule, so there won't be unnecessary logs. Also remove the kdump service checking logic in kdump-udev-throttler as udev is the only expected callee of this script, if it's not being called at first place when kdump service is running, this checking will be redundant. And even if any user called this script manually, it will still work well as this script will call 'kdumpctl reload', it reload the kdump resource only if kdump is loaded already. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
2018-11-22 14:56:08 +00:00
# If kdump is not loaded, calling kdump-udev-throttle will end up
# doing nothing, but systemd-run will always generate extra logs for
# each call, so trigger the kdump-udev-throttler only if kdump
# service is active to avoid unnecessary logs
RUN+="/bin/sh -c '/usr/bin/systemctl is-active kdump.service || exit 0; /usr/bin/systemd-run --quiet --no-block /usr/lib/udev/kdump-udev-throttler'"
Rewrite kdump's udev rules According to udev's man page, PROGRAM is either used to determine device's name or whether the device matches the rule. So we should use RUN insteand. Meanwhile, both RUN / PROGRAM only accepts very short-running foreground tasks, but kdump restart may take a long time if there are any device changes that will lead to image rebuild, which may lead to buggy behavior. On the other hand, memory / CPU hot plug should never trigger a initramfs rebuild. To solve this problem, we will use new introduced "kdumpctl reload" instead, and use systemd-run to create a transient service unit for the reload and run it in no-block mode, so udev won't be blocked by anything. We need to make systemd-run execute in non-blocking mode, and do not synchronously wait for the operation to finish, because udev expect the command line in RUN to be finished immediately, however, kdumpctl reload may take 0.5-1s for an ordinary reload, or even slower on some machines. So we give systemd-run an explicit --no-block option to run in non-blocking mode. Without --no-blocking, systemd-run will verify, enqueue and wait for the operation to finish. By using the --no-block option, systemd-run will only verify and enqueue the unit then return. In this way, we make sure the command is executed asynchronously, and the status will be monitored and logged by systemd, which is reliable and non-blocking. Another thing to mention is that --no-block is only needed after systemd-v220, before v220 systemd-run uses non-blocking mode by default and --no-block option is not available on earlier systemd versions. Also reformat the udev rules to a more maintanceable format. Signed-off-by: Kairui Song <kasong@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
2018-10-24 08:58:51 +00:00
LABEL="kdump_reload_end"