diff mbox series

[1/6] x86/Kconfig: add selection of default x2APIC destination mode

Message ID 20220623082428.28038-2-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series x86/irq: switch x2APIC default destination mode | expand

Commit Message

Roger Pau Monné June 23, 2022, 8:24 a.m. UTC
Allow selecting the default x2APIC destination mode from Kconfig.
Note the default destination mode is still Logical (Cluster) mode.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/Kconfig          | 29 +++++++++++++++++++++++++++++
 xen/arch/x86/genapic/x2apic.c |  6 ++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

Comments

Jan Beulich June 23, 2022, 2:47 p.m. UTC | #1
On 23.06.2022 10:24, Roger Pau Monne wrote:
> Allow selecting the default x2APIC destination mode from Kconfig.
> Note the default destination mode is still Logical (Cluster) mode.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
>  xen/arch/x86/Kconfig          | 29 +++++++++++++++++++++++++++++
>  xen/arch/x86/genapic/x2apic.c |  6 ++++--
>  2 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
> index 1e31edc99f..f560dc13f4 100644
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -226,6 +226,35 @@ config XEN_ALIGN_2M
>  
>  endchoice
>  
> +choice
> +	prompt "x2APIC default destination mode"

What's the point of using "choice" here, and not a single "bool"?

> +	default X2APIC_LOGICAL
> +	---help---

Nit: Please don't use ---help--- anymore - we're trying to phase out its
use as Linux has dropped it altogether (and hence once we update our
Kconfig, we'd like to change as few places as possible), leaving just
"help".

One downside of "choice" (iirc) is that the individual sub-options' help
text is inaccessible from at least the command line version of kconfig.

> +	  Specify default destination mode for x2APIC.
> +
> +	  If unsure, choose "Logical".
> +
> +config X2APIC_LOGICAL
> +	bool "Logical mode"
> +	---help---
> +	  Use Logical Destination mode.
> +
> +	  When using this mode APICs are addressed using the Logical
> +	  Destination mode, which allows for optimized IPI sending,
> +	  but also reduces the amount of vectors available for external
> +	  interrupts when compared to physical mode.
> +
> +config X2APIC_PHYS

X2APIC_PHYSICAL (to be in line with X2APIC_LOGICAL)?

Jan
Roger Pau Monné June 29, 2022, 8:47 a.m. UTC | #2
On Thu, Jun 23, 2022 at 04:47:22PM +0200, Jan Beulich wrote:
> On 23.06.2022 10:24, Roger Pau Monne wrote:
> > Allow selecting the default x2APIC destination mode from Kconfig.
> > Note the default destination mode is still Logical (Cluster) mode.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> >  xen/arch/x86/Kconfig          | 29 +++++++++++++++++++++++++++++
> >  xen/arch/x86/genapic/x2apic.c |  6 ++++--
> >  2 files changed, 33 insertions(+), 2 deletions(-)
> > 
> > diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
> > index 1e31edc99f..f560dc13f4 100644
> > --- a/xen/arch/x86/Kconfig
> > +++ b/xen/arch/x86/Kconfig
> > @@ -226,6 +226,35 @@ config XEN_ALIGN_2M
> >  
> >  endchoice
> >  
> > +choice
> > +	prompt "x2APIC default destination mode"
> 
> What's the point of using "choice" here, and not a single "bool"?

I think choice better reflects the purpose of the option, it's
selecting between two different modes.  It could be expressed with a
bool, but I think it's less clear.

> > +	default X2APIC_LOGICAL
> > +	---help---
> 
> Nit: Please don't use ---help--- anymore - we're trying to phase out its
> use as Linux has dropped it altogether (and hence once we update our
> Kconfig, we'd like to change as few places as possible), leaving just
> "help".
> 
> One downside of "choice" (iirc) is that the individual sub-options' help
> text is inaccessible from at least the command line version of kconfig.

Hm, I usually use menuconfig when wanting to poke at options help.

I guess I could introduce a single X2APIC_PHYSICAL bool that starts
with default false and notes that otherwise the destination mode is
logical.

> > +	  Specify default destination mode for x2APIC.
> > +
> > +	  If unsure, choose "Logical".
> > +
> > +config X2APIC_LOGICAL
> > +	bool "Logical mode"
> > +	---help---
> > +	  Use Logical Destination mode.
> > +
> > +	  When using this mode APICs are addressed using the Logical
> > +	  Destination mode, which allows for optimized IPI sending,
> > +	  but also reduces the amount of vectors available for external
> > +	  interrupts when compared to physical mode.
> > +
> > +config X2APIC_PHYS
> 
> X2APIC_PHYSICAL (to be in line with X2APIC_LOGICAL)?

Right, was about to expand it but did consider PHYS to be clear enough
(opposed to using LOG or LOGIC), will expand in next version.

Thanks, Roger.
diff mbox series

Patch

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 1e31edc99f..f560dc13f4 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -226,6 +226,35 @@  config XEN_ALIGN_2M
 
 endchoice
 
+choice
+	prompt "x2APIC default destination mode"
+	default X2APIC_LOGICAL
+	---help---
+	  Specify default destination mode for x2APIC.
+
+	  If unsure, choose "Logical".
+
+config X2APIC_LOGICAL
+	bool "Logical mode"
+	---help---
+	  Use Logical Destination mode.
+
+	  When using this mode APICs are addressed using the Logical
+	  Destination mode, which allows for optimized IPI sending,
+	  but also reduces the amount of vectors available for external
+	  interrupts when compared to physical mode.
+
+config X2APIC_PHYS
+	bool "Physical mode"
+	---help---
+	  Use Physical Destination mode.
+
+	  When using this mode APICs are addressed using the Physical
+	  Destination mode, which allows using all dynamic vectors on
+	  each CPU independently.
+
+endchoice
+
 config GUEST
 	bool
 
diff --git a/xen/arch/x86/genapic/x2apic.c b/xen/arch/x86/genapic/x2apic.c
index de5032f202..4b9bbe2f3e 100644
--- a/xen/arch/x86/genapic/x2apic.c
+++ b/xen/arch/x86/genapic/x2apic.c
@@ -228,7 +228,7 @@  static struct notifier_block x2apic_cpu_nfb = {
    .notifier_call = update_clusterinfo
 };
 
-static s8 __initdata x2apic_phys = -1; /* By default we use logical cluster mode. */
+static int8_t __initdata x2apic_phys = -1;
 boolean_param("x2apic_phys", x2apic_phys);
 
 const struct genapic *__init apic_x2apic_probe(void)
@@ -241,7 +241,9 @@  const struct genapic *__init apic_x2apic_probe(void)
          * the usage of the high 16 bits to hold the cluster ID.
          */
         x2apic_phys = !iommu_intremap ||
-                      (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL);
+                      (acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL) ||
+                      (IS_ENABLED(CONFIG_X2APIC_PHYS) &&
+                       !(acpi_gbl_FADT.flags & ACPI_FADT_APIC_CLUSTER));
     }
     else if ( !x2apic_phys )
         switch ( iommu_intremap )