Subject: Re: linux-next: Tree for Jun 28 (arch/powerpc/platforms/pseries/mobility.c)

From: Petr Mladek <[email-masked]>
Date: Thu, 29 Jun 2023 10:40:14 +0200

On Wed 2023-06-28 22:07:17, Randy Dunlap wrote:
> 
> 
> On 6/27/23 21:27, Stephen Rothwell wrote:
> > Hi all,
> > 
> > Please do *not* add any v5.6 related stuff to your linux-next included
> > branches until after v5.5-rc1 has been released.
> > 
> > Changes since 20230627:
> > 
> 
> on powerpc64, when
> # CONFIG_HARDLOCKUP_DETECTOR is not set:
> 
> ../arch/powerpc/platforms/pseries/mobility.c: In function 'pseries_migrate_partition':
> ../arch/powerpc/platforms/pseries/mobility.c:753:17: error: implicit declaration of function 'watchdog_hardlockup_set_timeout_pct'; did you mean 'watchdog_hardlockup_stop'? [-Werror=implicit-function-declaration]
>   753 |                 watchdog_hardlockup_set_timeout_pct(factor);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                 watchdog_hardlockup_stop
> cc1: all warnings being treated as errors
> 
> 
> Full randconfig file is attached.
> 
> 
> If I blatantly modify include/linux/nmi.h with these comments, it builds OK:
> 
> //#if defined(CONFIG_HARDLOCKUP_DETECTOR_ARCH) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64)
> #include <asm/nmi.h>
> //#endif

This is well describes the probem.

The decision whether to include asm/nmi.h should not depend only on
CONFIG_HARDLOCKUP_DETECTOR_* when it is needed also for other stuff.

Well, it could not be always included because it exists only
on 4 architectures:

$> ls -1 arch/*/include/asm/nmi.h
arch/powerpc/include/asm/nmi.h
arch/s390/include/asm/nmi.h
arch/sparc/include/asm/nmi.h
arch/x86/include/asm/nmi.h

and include/asm-generic/nmi.h. does not exist.

I see two reasonable solutions:

1. We either create an empty "include/asm-generic/nmi.h" and
   always include asm/nmi.h in linux/nmi.h.

   It looks is a bit weird but it might be the easiest solution
   unless it creates another problems elsewhere.

2. Explicitely include asm/nmi.h where needed, in
   arch/powerpc/platforms/pseries/mobility.c and maybe somewhere as
   well.

   It is already done in many cases:

$> git grep asm/nmi.h
arch/Kconfig:     asm/nmi.h, and defines its own arch_touch_nmi_watchdog().
arch/powerpc/kernel/mce.c:#include <asm/nmi.h>
arch/powerpc/kernel/traps.c:#include <asm/nmi.h>
arch/powerpc/kernel/watchdog.c:#include <asm/nmi.h>
arch/s390/kernel/entry.S:#include <asm/nmi.h>
arch/s390/kernel/idle.c:#include <asm/nmi.h>
arch/s390/kernel/machine_kexec.c:#include <asm/nmi.h>
arch/s390/kernel/nmi.c:#include <asm/nmi.h>
arch/s390/kernel/process.c:#include <asm/nmi.h>
arch/s390/kernel/setup.c:#include <asm/nmi.h>
arch/s390/kernel/smp.c:#include <asm/nmi.h>
arch/s390/kvm/interrupt.c:#include <asm/nmi.h>
arch/s390/kvm/kvm-s390.c:#include <asm/nmi.h>
arch/s390/kvm/vsie.c:#include <asm/nmi.h>
arch/sparc/kernel/pcr.c:#include <asm/nmi.h>
arch/sparc/kernel/perf_event.c:#include <asm/nmi.h>
arch/x86/events/amd/core.c:#include <asm/nmi.h>
arch/x86/events/amd/ibs.c:#include <asm/nmi.h>
arch/x86/events/core.c:#include <asm/nmi.h>
arch/x86/kernel/alternative.c:#include <asm/nmi.h>
arch/x86/kernel/apic/hw_nmi.c:#include <asm/nmi.h>
arch/x86/kernel/cpu/mce/inject.c:#include <asm/nmi.h>
arch/x86/kernel/cpu/mshyperv.c:#include <asm/nmi.h>
arch/x86/kernel/cpu/perfctr-watchdog.c:#include <asm/nmi.h>
arch/x86/kernel/crash.c:#include <asm/nmi.h>
arch/x86/kernel/kgdb.c:#include <asm/nmi.h>
arch/x86/kernel/nmi.c:#include <asm/nmi.h>
arch/x86/kernel/nmi_selftest.c:#include <asm/nmi.h>
arch/x86/kernel/process.c:#include <asm/nmi.h>
arch/x86/kernel/reboot.c:#include <asm/nmi.h>
arch/x86/kernel/smp.c:#include <asm/nmi.h>
arch/x86/kernel/smpboot.c:#include <asm/nmi.h>
arch/x86/kernel/tsc.c:#include <asm/nmi.h>
arch/x86/platform/uv/uv_nmi.c:#include <asm/nmi.h>
drivers/char/ipmi/ipmi_watchdog.c:#include <asm/nmi.h>
drivers/edac/igen6_edac.c:#include <asm/nmi.h>
drivers/s390/cio/cio.c:#include <asm/nmi.h>
drivers/watchdog/hpwdt.c:#include <asm/nmi.h>
include/linux/nmi.h:#include <asm/nmi.h>
include/linux/nmi.h:#include <asm/nmi.h>
kernel/sysctl.c:#include <asm/nmi.h>

I would personally prefer the 2nd variant.

I am going to check other locations where it might be needed.

Best Regards,
Petr