On 4/13/21 9:56 AM, Stefan Eichenberger wrote: > Hi Guenter, > > Thanks a lot for the fast feedback! > > On Tue, Apr 13, 2021 at 09:15:35AM -0700, Guenter Roeck wrote: >> On 4/13/21 8:45 AM, Stefan Eichenberger wrote: >>> Add a governor which calls a notifier call chain. This allows the >>> registration of custom functions to the watchdog pretimeout. This is >>> useful when writing out-of-tree kernel modules and it is more similar to >>> the register_reboot_notifier or register_oom_notifier API. >>> >>> Signed-off-by: Stefan Eichenberger <eichest@xxxxxxxxx> >> >> It seems questionable to implement such a notification as governor. >> A governor is configurable, and letting userspace override notifications >> seems very odd and unusual. Please provide a use case. > > What I would like to do is to have an out-of-tree module which will > write a pattern into a reserved memory region when a watchdog occurs. > After a reboot the module then read this reserved memory region and can > differentiate between different reset reasons. Here the example kernel > module: > https://github.com/embear-engineering/sample-kernel-modules/blob/use-watchdog-register/reset-reason/reset-reason.c > > Registering to the watchdog happens on line 180. > > I think I could just implement a governor in the module but it is not > really flexible because then I would have to compile the kernel with > e.g. the noop governor and then switch to my governor after the module > loaded. Then I thought why not using a notifier chain similar to reboot, > panic, or oom. > I have two problems with this: First, we do not support in-kernel code purely for out-of-tree drivers. Second, the idea of using a configurable notifier (ie one that can be disabled by userspace action) seems odd. If anything, that would have to be an unconditional notifier. However, again, that would require a use case in the upstream kernel. Guenter