05 Sep, 2018

1 commit

  • commit cb9d7fd51d9fbb329d182423bd7b92d0f8cb0e01 upstream.

    Some architectures need to use stop_machine() to patch functions for
    ftrace, and the assumption is that the stopped CPUs do not make function
    calls to traceable functions when they are in the stopped state.

    Commit ce4f06dcbb5d ("stop_machine: Touch_nmi_watchdog() after
    MULTI_STOP_PREPARE") added calls to the watchdog touch functions from
    the stopped CPUs and those functions lack notrace annotations. This
    leads to crashes when enabling/disabling ftrace on ARM kernels built
    with the Thumb-2 instruction set.

    Fix it by adding the necessary notrace annotations.

    Fixes: ce4f06dcbb5d ("stop_machine: Touch_nmi_watchdog() after MULTI_STOP_PREPARE")
    Signed-off-by: Vincent Whitchurch
    Signed-off-by: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: oleg@redhat.com
    Cc: tj@kernel.org
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20180821152507.18313-1-vincent.whitchurch@axis.com
    Signed-off-by: Greg Kroah-Hartman

    Vincent Whitchurch
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

04 Oct, 2017

5 commits

  • The variable is unused when the softlockup detector is disabled in Kconfig.

    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • The function names made sense up to the point where the watchdog
    (re)configuration was unified to use softlockup_reconfigure_threads() for
    all configuration purposes. But that includes scenarios which solely
    configure the nmi watchdog.

    Rename softlockup_reconfigure_threads() and softlockup_init_threads() so
    the function names match the functionality.

    Signed-off-by: Thomas Gleixner
    Cc: Linus Torvalds
    Cc: Michael Ellerman
    Cc: Peter Zijlstra
    Cc: Don Zickus

    Thomas Gleixner
     
  • The rework of the core hotplug code triggers the WARN_ON in start_wd_cpu()
    on powerpc because it is called multiple times for the boot CPU.

    The first call is via:

    start_wd_on_cpu+0x80/0x2f0
    watchdog_nmi_reconfigure+0x124/0x170
    softlockup_reconfigure_threads+0x110/0x130
    lockup_detector_init+0xbc/0xe0
    kernel_init_freeable+0x18c/0x37c
    kernel_init+0x2c/0x160
    ret_from_kernel_thread+0x5c/0xbc

    And then again via the CPU hotplug registration:

    start_wd_on_cpu+0x80/0x2f0
    cpuhp_invoke_callback+0x194/0x620
    cpuhp_thread_fun+0x7c/0x1b0
    smpboot_thread_fn+0x290/0x2a0
    kthread+0x168/0x1b0
    ret_from_kernel_thread+0x5c/0xbc

    This can be avoided by setting up the cpu hotplug state with nocalls and
    move the initialization to the watchdog_nmi_probe() function. That
    initializes the hotplug callbacks without invoking the callback and the
    following core initialization function then configures the watchdog for the
    online CPUs (in this case CPU0) via softlockup_reconfigure_threads().

    Reported-and-tested-by: Michael Ellerman
    Signed-off-by: Thomas Gleixner
    Acked-by: Michael Ellerman
    Cc: Benjamin Herrenschmidt
    Cc: Nicholas Piggin
    Cc: linuxppc-dev@lists.ozlabs.org

    Thomas Gleixner
     
  • Instead of dropping the cpu hotplug lock after stopping NMI watchdog and
    threads and reaquiring for restart, the code and the protection rules
    become more obvious when holding cpu hotplug lock across the full
    reconfiguration.

    Suggested-by: Linus Torvalds
    Signed-off-by: Thomas Gleixner
    Acked-by: Michael Ellerman
    Cc: Peter Zijlstra
    Cc: Don Zickus
    Cc: Benjamin Herrenschmidt
    Cc: Nicholas Piggin
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1710022105570.2114@nanos

    Thomas Gleixner
     
  • The recent cleanup of the watchdog code split watchdog_nmi_reconfigure()
    into two stages. One to stop the NMI and one to restart it after
    reconfiguration. That was done by adding a boolean 'run' argument to the
    code, which is functionally correct but not necessarily a piece of art.

    Replace it by two explicit functions: watchdog_nmi_stop() and
    watchdog_nmi_start().

    Fixes: 6592ad2fcc8f ("watchdog/core, powerpc: Make watchdog_nmi_reconfigure() two stage")
    Requested-by: Linus 'Nursing his pet-peeve' Torvalds
    Signed-off-by: Thomas 'Mopping up garbage' Gleixner
    Acked-by: Michael Ellerman
    Cc: Peter Zijlstra
    Cc: Don Zickus
    Cc: Benjamin Herrenschmidt
    Cc: Nicholas Piggin
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1710021957480.2114@nanos

    Thomas Gleixner
     

14 Sep, 2017

21 commits

  • All watchdog thread related functions are delegated to the smpboot thread
    infrastructure, which handles serialization against CPU hotplug correctly.

    The sysctl interface is completely decoupled from anything which requires
    CPU hotplug protection.

    No need to protect the sysctl writes against cpu hotplug anymore. Remove it
    and add the now required protection to the powerpc arch_nmi_watchdog
    implementation.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Michael Ellerman
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/20170912194148.418497420@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Get rid of the hodgepodge which tries to be smart about perf being
    unavailable and error printout rate limiting.

    That's all not required simply because this is never invoked when the perf
    NMI watchdog is not functional.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194148.259651788@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Use the init time detection of the perf NMI watchdog to determine whether
    the perf NMI watchdog is functional. If not disable it permanentely. It
    won't come back magically at runtime.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194148.099799541@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Letting user space poke directly at variables which are used at run time is
    stupid and causes a lot of race conditions and other issues.

    Seperate the user variables and on change invoke the reconfiguration, which
    then stops the watchdogs, reevaluates the new user value and restarts the
    watchdogs with the new parameters.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.939985640@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Both the perf reconfiguration and the powerpc watchdog_nmi_reconfigure()
    need to be done in two steps.

    1) Stop all NMIs
    2) Read the new parameters and start NMIs

    Right now watchdog_nmi_reconfigure() is a combination of both. To allow a
    clean reconfiguration add a 'run' argument and split the functionality in
    powerpc.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Michael Ellerman
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/20170912194147.862865570@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Reflect that these variables are user interface related and remove the
    whitespace damage in the sysctl table while at it.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.783210221@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Use a single function to update sysctl changes. This is not a high
    frequency user space interface and it's root only.

    Preparatory patch to cleanup the sysctl variable handling.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.549114957@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The lockup detector reconfiguration tears down all watchdog threads when
    the watchdog is disabled and sets them up again when its enabled.

    That's a pointless exercise. The watchdog threads are not consuming an
    insane amount of resources, so it's enough to set them up at init time and
    keep them in parked position when the watchdog is disabled and unpark them
    when it is reenabled. The smpboot thread infrastructure takes care of
    keeping the force parked threads in place even across cpu hotplug.

    Aside of that the code implements the park/unpark facility of smp hotplug
    threads on its own, which is even more pointless. We have functionality in
    the smpboot thread code to do so.

    Use the new thread management functions and get rid of the unholy mess.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.470370113@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The lockup detector reconfiguration tears down all watchdog threads when
    the watchdog is disabled and sets them up again when its enabled.

    That's a pointless exercise. The watchdog threads are not consuming an
    insane amount of resources, so it's enough to set them up at init time and
    keep them in parked position when the watchdog is disabled and unpark them
    when it is reenabled. The smpboot thread infrastructure takes care of
    keeping the force parked threads in place even across cpu hotplug.

    Another horrible mechanism are the open coded park/unpark loops which are
    used for reconfiguration of the watchdog. The smpboot infrastructure allows
    exactly the same via smpboot_update_cpumask_thread_percpu(), which is cpu
    hotplug safe. Using that instead of the open coded loops allows to get rid
    of the hotplug locking mess in the watchdog code.

    Implement a clean infrastructure which allows to replace the open coded
    nonsense.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.377182587@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • smpboot_update_cpumask_threads_percpu() allocates a temporary cpumask at
    runtime. This is suboptimal because the call site needs more code size for
    proper error handling than a statically allocated temporary mask requires
    data size.

    Add static temporary cpumask. The function is globaly serialized, so no
    further protection required.

    Remove the half baken error handling in the watchdog code and get rid of
    the export as there are no in tree modular users of that function.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.297288838@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Split the write part of the cpumask proc handler out into a separate helper
    to avoid deep indentation. This also reduces the patch complexity in the
    following cleanups.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.218075991@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The #ifdef maze in this file is horrible, group stuff at least a bit so one
    can figure out what belongs to what.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.139629546@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Having stub functions which take a full page is not helping the
    readablility of code.

    Condense them and move the doubled #ifdef variant into the SYSFS section.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194147.045545271@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Commit:

    b94f51183b06 ("kernel/watchdog: prevent false hardlockup on overloaded system")

    tries to fix the following issue:

    proc_write()
    set_sample_period() park()
    disable_nmi()

    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1709052038270.2393@nanos
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The following deadlock is possible in the watchdog hotplug code:

    cpus_write_lock()
    ...
    takedown_cpu()
    smpboot_park_threads()
    smpboot_park_thread()
    kthread_park()
    ->park() := watchdog_disable()
    watchdog_nmi_disable()
    perf_event_release_kernel();
    put_event()
    _free_event()
    ->destroy() := hw_perf_event_destroy()
    x86_release_hardware()
    release_ds_buffers()
    get_online_cpus()

    when a per cpu watchdog perf event is destroyed which drops the last
    reference to the PMU hardware. The cleanup code there invokes
    get_online_cpus() which instantly deadlocks because the hotplug percpu
    rwsem is write locked.

    To solve this add a deferring mechanism:

    cpus_write_lock()
    kthread_park()
    watchdog_nmi_disable(deferred)
    perf_event_disable(event);
    move_event_to_deferred(event);
    ....
    cpus_write_unlock()
    cleaup_deferred_events()
    perf_event_release_kernel()

    This is still properly serialized against concurrent hotplug via the
    cpu_add_remove_lock, which is held by the task which initiated the hotplug
    event.

    This is also used to handle event destruction when the watchdog threads are
    parked via other mechanisms than CPU hotplug.

    Analyzed-by: Peter Zijlstra

    Reported-by: Borislav Petkov
    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194146.884469246@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The self disabling feature is broken vs. CPU hotplug locking:

    CPU 0 CPU 1
    cpus_write_lock();
    cpu_up(1)
    wait_for_completion()
    ....
    unpark_watchdog()
    ->unpark()
    perf_event_create() parked);

    Result: End of hotplug and instantaneous full lockup of the machine.

    There is a similar problem with disabling the watchdog via the user space
    interface as the sysctl function fiddles with watchdog_enable directly.

    It's very debatable whether this is required at all. If the watchdog works
    nicely on N CPUs and it fails to enable on the N + 1 CPU either during
    hotplug or because the user space interface disabled it via sysctl cpumask
    and then some perf user grabbed the counter which is then unavailable for
    the watchdog when the sysctl cpumask gets changed back.

    There is no real justification for this.

    One of the reasons WHY this is done is the utter stupidity of the init code
    of the perf NMI watchdog. Instead of checking upfront at boot whether PERF
    is available and functional at all, it just does this check at run time
    over and over when user space fiddles with the sysctl. That's broken beyond
    repair along with the idiotic error code dependent warn level printks and
    the even more silly printk rate limiting.

    If the init code checks whether perf works at boot time, then this mess can
    be more or less avoided completely. Perf does not come magically into life
    at runtime. Brain usage while coding is overrated.

    Remove the cruft and add a temporary safe guard which gets removed later.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194146.806708429@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The function is only used by the KVM init code. Mark it __init to prevent
    creative abuse.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194146.727134632@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • Following patches will use the mutex for other purposes as well. Rename it
    as it is not longer a proc specific thing.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194146.647714850@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • The watchdog proc interface causes extensive recursive locking of the CPU
    hotplug percpu rwsem, which is deadlock prone.

    Replace the get/put_online_cpus() pairs with cpu_hotplug_disable()/enable()
    calls for now. Later patches will remove that requirement completely.

    Reported-by: Borislav Petkov
    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194146.568079057@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • This interface has several issues:

    - It's causing recursive locking of the hotplug lock.

    - It's complete overkill to teardown all threads and then recreate them

    The same can be achieved with the simple hardlockup_detector_perf_stop /
    restart() interfaces. The abuse from the busy looping poweroff() loop of
    PARISC has been solved as well.

    Remove the cruft.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Link: http://lkml.kernel.org/r/20170912194146.487537732@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     
  • PARISC has a a busy looping power off routine. If the watchdog is enabled
    the watchdog timer will still fire, but the thread is not running, which
    causes the softlockup watchdog to trigger.

    Provide a interface which allows to turn the watchdog off.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Don Zickus
    Cc: Andrew Morton
    Cc: Borislav Petkov
    Cc: Chris Metcalf
    Cc: Helge Deller
    Cc: Linus Torvalds
    Cc: Nicholas Piggin
    Cc: Peter Zijlstra
    Cc: Sebastian Siewior
    Cc: Ulrich Obergfell
    Cc: linux-parisc@vger.kernel.org
    Link: http://lkml.kernel.org/r/20170912194146.327343752@linutronix.de
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     

18 Aug, 2017

1 commit

  • The hardlockup detector on x86 uses a performance counter based on unhalted
    CPU cycles and a periodic hrtimer. The hrtimer period is about 2/5 of the
    performance counter period, so the hrtimer should fire 2-3 times before the
    performance counter NMI fires. The NMI code checks whether the hrtimer
    fired since the last invocation. If not, it assumess a hard lockup.

    The calculation of those periods is based on the nominal CPU
    frequency. Turbo modes increase the CPU clock frequency and therefore
    shorten the period of the perf/NMI watchdog. With extreme Turbo-modes (3x
    nominal frequency) the perf/NMI period is shorter than the hrtimer period
    which leads to false positives.

    A simple fix would be to shorten the hrtimer period, but that comes with
    the side effect of more frequent hrtimer and softlockup thread wakeups,
    which is not desired.

    Implement a low pass filter, which checks the perf/NMI period against
    kernel time. If the perf/NMI fires before 4/5 of the watchdog period has
    elapsed then the event is ignored and postponed to the next perf/NMI.

    That solves the problem and avoids the overhead of shorter hrtimer periods
    and more frequent softlockup thread wakeups.

    Fixes: 58687acba592 ("lockup_detector: Combine nmi_watchdog and softlockup detector")
    Reported-and-tested-by: Kan Liang
    Signed-off-by: Thomas Gleixner
    Cc: dzickus@redhat.com
    Cc: prarit@redhat.com
    Cc: ak@linux.intel.com
    Cc: babu.moger@oracle.com
    Cc: peterz@infradead.org
    Cc: eranian@google.com
    Cc: acme@redhat.com
    Cc: stable@vger.kernel.org
    Cc: atomlin@redhat.com
    Cc: akpm@linux-foundation.org
    Cc: torvalds@linux-foundation.org
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1708150931310.1886@nanos

    Thomas Gleixner
     

15 Jul, 2017

1 commit

  • After commit 73ce0511c436 ("kernel/watchdog.c: move hardlockup
    detector to separate file"), 'NMI watchdog' is inappropriate in
    kernel/watchdog.c, using 'watchdog' only.

    Link: http://lkml.kernel.org/r/1499928642-48983-1-git-send-email-wangkefeng.wang@huawei.com
    Signed-off-by: Kefeng Wang
    Cc: Babu Moger
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kefeng Wang
     

13 Jul, 2017

2 commits

  • After reconfiguring watchdog sysctls etc., architecture specific
    watchdogs may not get all their parameters updated.

    watchdog_nmi_reconfigure() can be implemented to pull the new values in
    and set the arch NMI watchdog.

    [npiggin@gmail.com: add code comments]
    Link: http://lkml.kernel.org/r/20170617125933.774d3858@roar.ozlabs.ibm.com
    [arnd@arndb.de: hide unused function]
    Link: http://lkml.kernel.org/r/20170620204854.966601-1-arnd@arndb.de
    Link: http://lkml.kernel.org/r/20170616065715.18390-5-npiggin@gmail.com
    Signed-off-by: Nicholas Piggin
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Don Zickus
    Tested-by: Babu Moger [sparc]
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicholas Piggin
     
  • Split SOFTLOCKUP_DETECTOR from LOCKUP_DETECTOR, and split
    HARDLOCKUP_DETECTOR_PERF from HARDLOCKUP_DETECTOR.

    LOCKUP_DETECTOR implies the general boot, sysctl, and programming
    interfaces for the lockup detectors.

    An architecture that wants to use a hard lockup detector must define
    HAVE_HARDLOCKUP_DETECTOR_PERF or HAVE_HARDLOCKUP_DETECTOR_ARCH.

    Alternatively an arch can define HAVE_NMI_WATCHDOG, which provides the
    minimum arch_touch_nmi_watchdog, and it otherwise does its own thing and
    does not implement the LOCKUP_DETECTOR interfaces.

    sparc is unusual in that it has started to implement some of the
    interfaces, but not fully yet. It should probably be converted to a full
    HAVE_HARDLOCKUP_DETECTOR_ARCH.

    [npiggin@gmail.com: fix]
    Link: http://lkml.kernel.org/r/20170617223522.66c0ad88@roar.ozlabs.ibm.com
    Link: http://lkml.kernel.org/r/20170616065715.18390-4-npiggin@gmail.com
    Signed-off-by: Nicholas Piggin
    Reviewed-by: Don Zickus
    Reviewed-by: Babu Moger
    Tested-by: Babu Moger [sparc]
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicholas Piggin
     

02 Mar, 2017

3 commits


25 Jan, 2017

1 commit

  • On an overloaded system, it is possible that a change in the watchdog
    threshold can be delayed long enough to trigger a false positive.

    This can easily be achieved by having a cpu spinning indefinitely on a
    task, while another cpu updates watchdog threshold.

    What happens is while trying to park the watchdog threads, the hrtimers
    on the other cpus trigger and reprogram themselves with the new slower
    watchdog threshold. Meanwhile, the nmi watchdog is still programmed
    with the old faster threshold.

    Because the one cpu is blocked, it prevents the thread parking on the
    other cpus from completing, which is needed to shutdown the nmi watchdog
    and reprogram it correctly. As a result, a false positive from the nmi
    watchdog is reported.

    Fix this by setting a park_in_progress flag to block all lockups until
    the parking is complete.

    Fix provided by Ulrich Obergfell.

    [akpm@linux-foundation.org: s/park_in_progress/watchdog_park_in_progress/]
    Link: http://lkml.kernel.org/r/1481041033-192236-1-git-send-email-dzickus@redhat.com
    Signed-off-by: Don Zickus
    Reviewed-by: Aaron Tomlin
    Cc: Ulrich Obergfell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Don Zickus
     

15 Dec, 2016

3 commits

  • Separate hardlockup code from watchdog.c and move it to watchdog_hld.c.
    It is mostly straight forward. Remove everything inside
    CONFIG_HARDLOCKUP_DETECTORS. This code will go to file watchdog_hld.c.
    Also update the makefile accordigly.

    Link: http://lkml.kernel.org/r/1478034826-43888-3-git-send-email-babu.moger@oracle.com
    Signed-off-by: Babu Moger
    Acked-by: Don Zickus
    Cc: Ingo Molnar
    Cc: Jiri Kosina
    Cc: Andi Kleen
    Cc: Yaowei Bai
    Cc: Aaron Tomlin
    Cc: Ulrich Obergfell
    Cc: Tejun Heo
    Cc: Hidehiro Kawai
    Cc: Josh Hunt
    Cc: "David S. Miller"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Babu Moger
     
  • Patch series "Clean up watchdog handlers", v2.

    This is an attempt to cleanup watchdog handlers. Right now,
    kernel/watchdog.c implements both softlockup and hardlockup detectors.
    Softlockup code is generic. Hardlockup code is arch specific. Some
    architectures don't use hardlockup detectors. They use their own
    watchdog detectors. To make both these combination work, we have
    numerous #ifdefs in kernel/watchdog.c.

    We are trying here to make these handlers independent of each other.
    Also provide an interface for architectures to implement their own
    handlers. watchdog_nmi_enable and watchdog_nmi_disable will be defined
    as weak such that architectures can override its definitions.

    Thanks to Don Zickus for his suggestions.
    Here are our previous discussions
    http://www.spinics.net/lists/sparclinux/msg16543.html
    http://www.spinics.net/lists/sparclinux/msg16441.html

    This patch (of 3):

    Move shared macros and definitions to nmi.h so that watchdog.c, new file
    watchdog_hld.c or any other architecture specific handler can use those
    definitions.

    Link: http://lkml.kernel.org/r/1478034826-43888-2-git-send-email-babu.moger@oracle.com
    Signed-off-by: Babu Moger
    Acked-by: Don Zickus
    Cc: Ingo Molnar
    Cc: Jiri Kosina
    Cc: Andi Kleen
    Cc: Yaowei Bai
    Cc: Aaron Tomlin
    Cc: Ulrich Obergfell
    Cc: Tejun Heo
    Cc: Hidehiro Kawai
    Cc: Josh Hunt
    Cc: "David S. Miller"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Babu Moger
     
  • NMI handler doesn't call set_irq_regs(), it's set only by normal IRQ.
    Thus get_irq_regs() returns NULL or stale registers snapshot with IP/SP
    pointing to the code interrupted by IRQ which was interrupted by NMI.
    NULL isn't a problem: in this case watchdog calls dump_stack() and
    prints full stack trace including NMI. But if we're stuck in IRQ
    handler then NMI watchlog will print stack trace without IRQ part at
    all.

    This patch uses registers snapshot passed into NMI handler as arguments:
    these registers point exactly to the instruction interrupted by NMI.

    Fixes: 55537871ef66 ("kernel/watchdog.c: perform all-CPU backtrace in case of hard lockup")
    Link: http://lkml.kernel.org/r/146771764784.86724.6006627197118544150.stgit@buzz
    Signed-off-by: Konstantin Khlebnikov
    Cc: Jiri Kosina
    Cc: Ulrich Obergfell
    Cc: Aaron Tomlin
    Cc: [4.4+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     

18 Mar, 2016

1 commit

  • While working on a script to restore all sysctl params before a series of
    tests I found that writing any value into the
    /proc/sys/kernel/{nmi_watchdog,soft_watchdog,watchdog,watchdog_thresh}
    causes them to call proc_watchdog_update().

    NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
    NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
    NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
    NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.

    There doesn't appear to be a reason for doing this work every time a write
    occurs, so only do it when the values change.

    Signed-off-by: Josh Hunt
    Acked-by: Don Zickus
    Reviewed-by: Aaron Tomlin
    Cc: Ulrich Obergfell
    Cc: [4.1.x+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joshua Hunt