• [RFC GIT Pull] core watchdog sanitizing

    From Thomas Gleixner@21:1/5 to Linus Torvalds on Mon Oct 2 22:50:03 2017
    On Sun, 1 Oct 2017, Linus Torvalds wrote:
    So get rid of that kind of shit, and I may reconsider. But as is, I
    look at that patch and say "no, this is worse than the garbage it used
    to be".

    I agree that adding that 'run' argument was certainly not a piece of
    art. Though I disagree with the sentiment that non-functional garbage is preferrable over functionally correct code which merily contains a bad implementation choice. Without knowing you for years, it would certainly
    seem more rewarding to dump garbage and get it merged, than caring and
    mopping up garbage, which should not have been merged in the first
    place. Your motivation skills are truly outstanding.

    Enough vented. Find below the cure for that major offense.

    Thanks,

    tglx

    8<--------------------

    Subject: watchdog/core, powerpc: Replace watchdog_nmi_reconfigure()
    From: Thomas Gleixner <tglx@linutronix.de>
    Date: Mon, 02 Oct 2017 12:34:50 +0200

    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 function, 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 <torvalds@linuxfoundation.org>
    Signed-off-by: Thomas 'Mopping up garbage' Gleixner <tglx@linutronix.de>
    Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: linuxppc-dev@lists.ozlabs.org

    ---
    arch/powerpc/kernel/watchdog.c | 23 ++++++++++++++---------
    include/linux/nmi.h | 3 ++-
    kernel/watchdog.c | 33 ++++++++++++++++++---------------
    3 files changed, 34 insertions(+), 25 deletions(-)

    --- a/arch/powerpc/kernel/watchdog.c
    +++ b/arch/powerpc/kernel/watchdog.c
    @@ -355,19 +355,24 @@ static void watchdog_calc_timeouts(void)
    wd_timer_period_ms = watchdog_thresh * 1000 * 2 / 5;
    }

    -void watchdog_nmi_reconfigure(bool run)
    +void watchdog_nmi_stop(void)
    {
    int cpu;

    cpus_read_lock();
    - if (!run) {
    - for_each_cpu(cpu, &wd_cpus_enabled)
    - stop_wd_on_cpu(cpu);
    - } else {
    - watchdog_calc_timeouts();
    - for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpumask)
    - start_wd_on_cpu(cpu);
    - }
    + for_each_cpu(cpu, &wd_cpus_enabled)
    + stop_wd_on_cpu(cpu);
    + cpus_read_unlock();
    +}
    +
    +void watchdog_nmi_start(void)
    +{
    + int cpu;
    +
    + cpus_read_lock();
    + watchdog_calc_timeouts();
    + for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpuma