]> git.karo-electronics.de Git - karo-tx-linux.git/commit
watchdog: fix error handling in proc_watchdog_thresh()
authorUlrich Obergfell <uobergfe@redhat.com>
Wed, 21 Oct 2015 22:02:48 +0000 (09:02 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 21 Oct 2015 22:02:48 +0000 (09:02 +1100)
commit0ea7e9d8d7ddfe0027fea9474ff1e7e89388bce9
treee8d83cec686b34c40b87f4065731e80f2f9c8e8f
parentb6da8fc4f3bff6d761631662ccb00fcd653f5576
watchdog: fix error handling in proc_watchdog_thresh()

The original watchdog_park_threads() function that was introduced by
81a4beef91ba4a9 ("watchdog: introduce watchdog_park_threads() and
watchdog_unpark_threads()") takes a very simple approach to handle errors
returned by kthread_park(): It attempts to roll back all watchdog threads
to the unparked state.  However, this may be undesired behaviour from the
perspective of the caller which may want to handle errors as appropriate
in its specific context.  Currently, there are two possible call chains:

- watchdog suspend/resume interface

    lockup_detector_suspend
      watchdog_park_threads

- write to parameters in /proc/sys/kernel

    proc_watchdog_update
      watchdog_enable_all_cpus
        update_watchdog_all_cpus
          watchdog_park_threads

Instead of 'blindly' attempting to unpark the watchdog threads if a
kthread_park() call fails, the new approach is to disable the lockup
detectors in the above call chains.  Failure becomes visible to the user
as follows:

- error messages from lockup_detector_suspend()
                   or watchdog_enable_all_cpus()

- the state that can be read from /proc/sys/kernel/watchdog_enabled

- the 'write' system call in the latter call chain returns an error

I did not experience kthread_park() failures in practice, I used some
instrumentation to fake error returns from kthread_park() in order to test
the patches.

This patch (of 5):

Restore the previous value of watchdog_thresh _and_ sample_period if
proc_watchdog_update() returns an error.  The variables must be consistent
to avoid false positives of the lockup detectors.

Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/watchdog.c