[1/5] ACPI: NUMA: Add 'nohmat' option
diff mbox series

Message ID 158318760361.2216124.13612198312947463590.stgit@dwillia2-desk3.amr.corp.intel.com
State Superseded
Headers show
Series
  • Manual definition of Soft Reserved memory devices
Related show

Commit Message

Dan Williams March 2, 2020, 10:20 p.m. UTC
Disable parsing of the HMAT for debug, to workaround broken platform
instances, or cases where it is otherwise not wanted.

Cc: x86@kernel.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 arch/x86/mm/numa.c       |    4 ++++
 drivers/acpi/numa/hmat.c |    3 ++-
 include/acpi/acpi_numa.h |    1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

Comments

Dan Williams March 18, 2020, 12:08 a.m. UTC | #1
On Mon, Mar 2, 2020 at 2:36 PM Dan Williams <dan.j.williams@intel.com> wrote:
>
> Disable parsing of the HMAT for debug, to workaround broken platform
> instances, or cases where it is otherwise not wanted.

Rafael, any heartburn with this change to the numa= option?

...as I look at this I realize I failed to also update
Documentation/x86/x86_64/boot-options.rst, will fix.

>
> Cc: x86@kernel.org
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  arch/x86/mm/numa.c       |    4 ++++
>  drivers/acpi/numa/hmat.c |    3 ++-
>  include/acpi/acpi_numa.h |    1 +
>  3 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> index 59ba008504dc..22de2e2610c1 100644
> --- a/arch/x86/mm/numa.c
> +++ b/arch/x86/mm/numa.c
> @@ -44,6 +44,10 @@ static __init int numa_setup(char *opt)
>  #ifdef CONFIG_ACPI_NUMA
>         if (!strncmp(opt, "noacpi", 6))
>                 acpi_numa = -1;
> +#ifdef CONFIG_ACPI_HMAT
> +       if (!strncmp(opt, "nohmat", 6))
> +               hmat_disable = 1;
> +#endif
>  #endif
>         return 0;
>  }
> diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
> index 2c32cfb72370..d3db121e393a 100644
> --- a/drivers/acpi/numa/hmat.c
> +++ b/drivers/acpi/numa/hmat.c
> @@ -26,6 +26,7 @@
>  #include <linux/sysfs.h>
>
>  static u8 hmat_revision;
> +int hmat_disable __initdata;
>
>  static LIST_HEAD(targets);
>  static LIST_HEAD(initiators);
> @@ -814,7 +815,7 @@ static __init int hmat_init(void)
>         enum acpi_hmat_type i;
>         acpi_status status;
>
> -       if (srat_disabled())
> +       if (srat_disabled() || hmat_disable)
>                 return 0;
>
>         status = acpi_get_table(ACPI_SIG_SRAT, 0, &tbl);
> diff --git a/include/acpi/acpi_numa.h b/include/acpi/acpi_numa.h
> index fdebcfc6c8df..48ca468e9b61 100644
> --- a/include/acpi/acpi_numa.h
> +++ b/include/acpi/acpi_numa.h
> @@ -18,6 +18,7 @@ extern int node_to_pxm(int);
>  extern int acpi_map_pxm_to_node(int);
>  extern unsigned char acpi_srat_revision;
>  extern int acpi_numa __initdata;
> +extern int hmat_disable __initdata;
>
>  extern void bad_srat(void);
>  extern int srat_disabled(void);
>
Rafael J. Wysocki March 18, 2020, 8:24 a.m. UTC | #2
On Wed, Mar 18, 2020 at 1:09 AM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Mon, Mar 2, 2020 at 2:36 PM Dan Williams <dan.j.williams@intel.com> wrote:
> >
> > Disable parsing of the HMAT for debug, to workaround broken platform
> > instances, or cases where it is otherwise not wanted.
>
> Rafael, any heartburn with this change to the numa= option?
>
> ...as I look at this I realize I failed to also update
> Documentation/x86/x86_64/boot-options.rst, will fix.

Thanks!

Apart from this just a minor nit below.

> >
> > Cc: x86@kernel.org
> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > Cc: Andy Lutomirski <luto@kernel.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > ---
> >  arch/x86/mm/numa.c       |    4 ++++
> >  drivers/acpi/numa/hmat.c |    3 ++-
> >  include/acpi/acpi_numa.h |    1 +
> >  3 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> > index 59ba008504dc..22de2e2610c1 100644
> > --- a/arch/x86/mm/numa.c
> > +++ b/arch/x86/mm/numa.c
> > @@ -44,6 +44,10 @@ static __init int numa_setup(char *opt)
> >  #ifdef CONFIG_ACPI_NUMA
> >         if (!strncmp(opt, "noacpi", 6))
> >                 acpi_numa = -1;
> > +#ifdef CONFIG_ACPI_HMAT
> > +       if (!strncmp(opt, "nohmat", 6))
> > +               hmat_disable = 1;
> > +#endif

I wonder if IS_ENABLED() would work here?

> >  #endif
> >         return 0;
> >  }
> > diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
> > index 2c32cfb72370..d3db121e393a 100644
> > --- a/drivers/acpi/numa/hmat.c
> > +++ b/drivers/acpi/numa/hmat.c
> > @@ -26,6 +26,7 @@
> >  #include <linux/sysfs.h>
> >
> >  static u8 hmat_revision;
> > +int hmat_disable __initdata;
> >
> >  static LIST_HEAD(targets);
> >  static LIST_HEAD(initiators);
> > @@ -814,7 +815,7 @@ static __init int hmat_init(void)
> >         enum acpi_hmat_type i;
> >         acpi_status status;
> >
> > -       if (srat_disabled())
> > +       if (srat_disabled() || hmat_disable)
> >                 return 0;
> >
> >         status = acpi_get_table(ACPI_SIG_SRAT, 0, &tbl);
> > diff --git a/include/acpi/acpi_numa.h b/include/acpi/acpi_numa.h
> > index fdebcfc6c8df..48ca468e9b61 100644
> > --- a/include/acpi/acpi_numa.h
> > +++ b/include/acpi/acpi_numa.h
> > @@ -18,6 +18,7 @@ extern int node_to_pxm(int);
> >  extern int acpi_map_pxm_to_node(int);
> >  extern unsigned char acpi_srat_revision;
> >  extern int acpi_numa __initdata;
> > +extern int hmat_disable __initdata;
> >
> >  extern void bad_srat(void);
> >  extern int srat_disabled(void);
> >
Dan Williams March 18, 2020, 5:39 p.m. UTC | #3
On Wed, Mar 18, 2020 at 1:24 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Wed, Mar 18, 2020 at 1:09 AM Dan Williams <dan.j.williams@intel.com> wrote:
> >
> > On Mon, Mar 2, 2020 at 2:36 PM Dan Williams <dan.j.williams@intel.com> wrote:
> > >
> > > Disable parsing of the HMAT for debug, to workaround broken platform
> > > instances, or cases where it is otherwise not wanted.
> >
> > Rafael, any heartburn with this change to the numa= option?
> >
> > ...as I look at this I realize I failed to also update
> > Documentation/x86/x86_64/boot-options.rst, will fix.
>
> Thanks!
>
> Apart from this just a minor nit below.
>
> > >
> > > Cc: x86@kernel.org
> > > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > > Cc: Andy Lutomirski <luto@kernel.org>
> > > Cc: Peter Zijlstra <peterz@infradead.org>
> > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > Cc: Ingo Molnar <mingo@redhat.com>
> > > Cc: Borislav Petkov <bp@alien8.de>
> > > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > > ---
> > >  arch/x86/mm/numa.c       |    4 ++++
> > >  drivers/acpi/numa/hmat.c |    3 ++-
> > >  include/acpi/acpi_numa.h |    1 +
> > >  3 files changed, 7 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> > > index 59ba008504dc..22de2e2610c1 100644
> > > --- a/arch/x86/mm/numa.c
> > > +++ b/arch/x86/mm/numa.c
> > > @@ -44,6 +44,10 @@ static __init int numa_setup(char *opt)
> > >  #ifdef CONFIG_ACPI_NUMA
> > >         if (!strncmp(opt, "noacpi", 6))
> > >                 acpi_numa = -1;
> > > +#ifdef CONFIG_ACPI_HMAT
> > > +       if (!strncmp(opt, "nohmat", 6))
> > > +               hmat_disable = 1;
> > > +#endif
>
> I wonder if IS_ENABLED() would work here?

I took a look. hmat_disable, acpi_numa, and numa_emu_cmdline() are in
other compilation units. I could wrap writing those variables with
helper functions, and change numa_emu_cmdline(), to compile away when
their respective configuration options are not present.

Should we do that in general to have a touch point to report "you
specified an option that is invalid for your current kernel
configuration"? I'm happy to do that as a follow-on if you think it's
worthwhile.
Rafael J. Wysocki March 19, 2020, 9:30 a.m. UTC | #4
On Wed, Mar 18, 2020 at 6:39 PM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Wed, Mar 18, 2020 at 1:24 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
> >
> > On Wed, Mar 18, 2020 at 1:09 AM Dan Williams <dan.j.williams@intel.com> wrote:
> > >
> > > On Mon, Mar 2, 2020 at 2:36 PM Dan Williams <dan.j.williams@intel.com> wrote:
> > > >
> > > > Disable parsing of the HMAT for debug, to workaround broken platform
> > > > instances, or cases where it is otherwise not wanted.
> > >
> > > Rafael, any heartburn with this change to the numa= option?
> > >
> > > ...as I look at this I realize I failed to also update
> > > Documentation/x86/x86_64/boot-options.rst, will fix.
> >
> > Thanks!
> >
> > Apart from this just a minor nit below.
> >
> > > >
> > > > Cc: x86@kernel.org
> > > > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > > > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > > > Cc: Andy Lutomirski <luto@kernel.org>
> > > > Cc: Peter Zijlstra <peterz@infradead.org>
> > > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > > Cc: Ingo Molnar <mingo@redhat.com>
> > > > Cc: Borislav Petkov <bp@alien8.de>
> > > > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > > > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> > > > ---
> > > >  arch/x86/mm/numa.c       |    4 ++++
> > > >  drivers/acpi/numa/hmat.c |    3 ++-
> > > >  include/acpi/acpi_numa.h |    1 +
> > > >  3 files changed, 7 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
> > > > index 59ba008504dc..22de2e2610c1 100644
> > > > --- a/arch/x86/mm/numa.c
> > > > +++ b/arch/x86/mm/numa.c
> > > > @@ -44,6 +44,10 @@ static __init int numa_setup(char *opt)
> > > >  #ifdef CONFIG_ACPI_NUMA
> > > >         if (!strncmp(opt, "noacpi", 6))
> > > >                 acpi_numa = -1;
> > > > +#ifdef CONFIG_ACPI_HMAT
> > > > +       if (!strncmp(opt, "nohmat", 6))
> > > > +               hmat_disable = 1;
> > > > +#endif
> >
> > I wonder if IS_ENABLED() would work here?
>
> I took a look. hmat_disable, acpi_numa, and numa_emu_cmdline() are in
> other compilation units. I could wrap writing those variables with
> helper functions, and change numa_emu_cmdline(), to compile away when
> their respective configuration options are not present.
>
> Should we do that in general to have a touch point to report "you
> specified an option that is invalid for your current kernel
> configuration"? I'm happy to do that as a follow-on if you think it's
> worthwhile.

Yes, please.

Patch
diff mbox series

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 59ba008504dc..22de2e2610c1 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -44,6 +44,10 @@  static __init int numa_setup(char *opt)
 #ifdef CONFIG_ACPI_NUMA
 	if (!strncmp(opt, "noacpi", 6))
 		acpi_numa = -1;
+#ifdef CONFIG_ACPI_HMAT
+	if (!strncmp(opt, "nohmat", 6))
+		hmat_disable = 1;
+#endif
 #endif
 	return 0;
 }
diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
index 2c32cfb72370..d3db121e393a 100644
--- a/drivers/acpi/numa/hmat.c
+++ b/drivers/acpi/numa/hmat.c
@@ -26,6 +26,7 @@ 
 #include <linux/sysfs.h>
 
 static u8 hmat_revision;
+int hmat_disable __initdata;
 
 static LIST_HEAD(targets);
 static LIST_HEAD(initiators);
@@ -814,7 +815,7 @@  static __init int hmat_init(void)
 	enum acpi_hmat_type i;
 	acpi_status status;
 
-	if (srat_disabled())
+	if (srat_disabled() || hmat_disable)
 		return 0;
 
 	status = acpi_get_table(ACPI_SIG_SRAT, 0, &tbl);
diff --git a/include/acpi/acpi_numa.h b/include/acpi/acpi_numa.h
index fdebcfc6c8df..48ca468e9b61 100644
--- a/include/acpi/acpi_numa.h
+++ b/include/acpi/acpi_numa.h
@@ -18,6 +18,7 @@  extern int node_to_pxm(int);
 extern int acpi_map_pxm_to_node(int);
 extern unsigned char acpi_srat_revision;
 extern int acpi_numa __initdata;
+extern int hmat_disable __initdata;
 
 extern void bad_srat(void);
 extern int srat_disabled(void);