• Petr Mladek's avatar
    watchdog/hardlockup: make HAVE_NMI_WATCHDOG sparc64-specific · a5fcc236
    Petr Mladek authored
    There are several hardlockup detector implementations and several Kconfig
    values which allow selection and build of the preferred one.
    
    CONFIG_HARDLOCKUP_DETECTOR was introduced by the commit 23637d47
    ("lockup_detector: Introduce CONFIG_HARDLOCKUP_DETECTOR") in v2.6.36.
    It was a preparation step for introducing the new generic perf hardlockup
    detector.
    
    The existing arch-specific variants did not support the to-be-created
    generic build configurations, sysctl interface, etc. This distinction
    was made explicit by the commit 4a7863cc ("x86, nmi_watchdog:
    Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR")
    in v2.6.38.
    
    CONFIG_HAVE_NMI_WATCHDOG was introduced by the commit d314d74c
    ("nmi watchdog: do not use cpp symbol in Kconfig") in v3.4-rc1. It replaced
    the above mentioned ARCH_HAS_NMI_WATCHDOG. At that time, it was still used
    by three architectures, namely blackfin, mn10300, and sparc.
    
    The support for blackfin and mn10300 architectures has been completely
    dropped some time ago. And sparc is the only architecture with the historic
    NMI watchdog at the moment.
    
    And the old sparc implementation is really special. It is always built on
    sparc64. It used to be always enabled until the commit 7a5c8b57
    ("sparc: implement watchdog_nmi_enable and watchdog_nmi_disable") added
    in v4.10-rc1.
    
    There are only few locations where the sparc64 NMI watchdog interacts
    with the generic hardlockup detectors code:
    
      + implements arch_touch_nmi_watchdog() which is called from the generic
        touch_nmi_watchdog()
    
      + implements watchdog_hardlockup_enable()/disable() to support
        /proc/sys/kernel/nmi_watchdog
    
      + is always preferred over other generic watchdogs, see
        CONFIG_HARDLOCKUP_DETECTOR
    
      + includes asm/nmi.h into linux/nmi.h because some sparc-specific
        functions are needed in sparc-specific code which includes
        only linux/nmi.h.
    
    The situation became more complicated after the commit 05a4a952
    ("kernel/watchdog: split up config options") and commit 2104180a
    ("powerpc/64s: implement arch-specific hardlockup watchdog") in v4.13-rc1.
    They introduced HAVE_HARDLOCKUP_DETECTOR_ARCH. It was used for powerpc
    specific hardlockup detector. It was compatible with the perf one
    regarding the general boot, sysctl, and programming interfaces.
    
    HAVE_HARDLOCKUP_DETECTOR_ARCH was defined as a superset of
    HAVE_NMI_WATCHDOG. It made some sense because all arch-specific
    detectors had some common requirements, namely:
    
      + implemented arch_touch_nmi_watchdog()
      + included asm/nmi.h into linux/nmi.h
      + defined the default value for /proc/sys/kernel/nmi_watchdog
    
    But it actually has made things pretty complicated when the generic
    buddy hardlockup detector was added. Before the generic perf detector
    was newer supported together with an arch-specific one. But the buddy
    detector could work on any SMP system. It means that an architecture
    could support both the arch-specific and buddy detector.
    
    As a result, there are few tricky dependencies. For example,
    CONFIG_HARDLOCKUP_DETECTOR depends on:
    
      ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
    
    The problem is that the very special sparc implementation is defined as:
    
      HAVE_NMI_WATCHDOG && !HAVE_HARDLOCKUP_DETECTOR_ARCH
    
    Another problem is that the meaning of HAVE_NMI_WATCHDOG is far from clear
    without reading understanding the history.
    
    Make the logic less tricky and more self-explanatory by making
    HAVE_NMI_WATCHDOG specific for the sparc64 implementation. And rename it to
    HAVE_HARDLOCKUP_DETECTOR_SPARC64.
    
    Note that HARDLOCKUP_DETECTOR_PREFER_BUDDY, HARDLOCKUP_DETECTOR_PERF,
    and HARDLOCKUP_DETECTOR_BUDDY may conflict only with
    HAVE_HARDLOCKUP_DETECTOR_ARCH. They depend on HARDLOCKUP_DETECTOR
    and it is not longer enabled when HAVE_NMI_WATCHDOG is set.
    
    Link: https://lkml.kernel.org/r/20230616150618.6073-5-pmladek@suse.comSigned-off-by: default avatarPetr Mladek <pmladek@suse.com>
    Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    a5fcc236
watchdog.c 27.1 KB