[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/x2apic: introduce a mixed physical/cluster mode


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 30 Oct 2023 15:32:56 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zMvcdRPVIlX+D3a1VIhD0jPAKdHF3pYb3ClU7TEg/88=; b=Di2NyoAlMpODNhKnrYMOfcsjnsnwL4u950Vs1OezO98nI3bqKYramVpVZ0RLMd7JPHjiXeyUKWbnmdhezqzNw7lp+/NkU/P4dSD0+lmyPRsbODgPswpSzM7MDAIYhGheMYFs7qD8kSEwz0mu6BcmI+ECAJ0F74uVcIW3sD+IT77Ycf5WeB/mU88HaMvfzMqiNIoQVNBIGkF55uOi9voZyIkFtzgGsF9Qg74ou9AHrcSOIJWtymY/qtMGDlDRQmg/RvnKmqCOPrF6ec0cnx4k9GPqxVGdTyKfRDKu9cHbN+59XomX3VVQIG5mOUz0EccjvuA36x+nqgIuiIh6xeUoXA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a58/eEhrlMxragJZtAmVZ7g3Auf2CkG8KUsubo2w4sjpzREtVX7jVpd84Fcrd0hu73erY352Lg1Xp9b0qdRXFSzbZjZkPLPs2XX7mm31kihgOjbvFkTAefO6OCuh07ajImBov0zcbIymulyjdOdcZfSH1XI3My0SWINihdKEPYH0dh3LEnfIN95/d8TDj99HA8WtxZMrDsn1MOxe8zirnRNm5U9DL6ou6O2tgBTvmZzvc+9kikIh/xVA+yT/cKcs1j80/FTvvONSM3xixJInytVf1oG4GR0VDVnMIUmSAjqSLzLRJRDdty9NTjy4eWt1wHBPnua0X9mBEPXw4FzF7w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 30 Oct 2023 14:33:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.10.2023 15:51, Roger Pau Monne wrote:
> The current implementation of x2APIC requires to either use Cluster Logical or
> Physical mode for all interrupts.  However the selection of Physical vs 
> Logical
> is not done at APIC setup, an APIC can be addressed both in Physical or 
> Logical
> destination modes concurrently.
> 
> Introduce a new x2APIC mode called mixed, which uses Logical Cluster mode for
> IPIs, and Physical mode for external interrupts, thus attempting to use the
> best method for each interrupt type.
> 
> Using Physical mode for external interrupts allows more vectors to be used, 
> and
> interrupt balancing to be more accurate.
> 
> Using Logical Cluster mode for IPIs allows less accesses to the ICR register
> when sending those, as multiple CPUs can be targeted with a single ICR 
> register
> write.
> 
> A simple test calling flush_tlb_all() 10000 times in a tight loop on a 96 CPU
> box gives the following average figures:
> 
> Physical mode: 26617931ns
> Mixed mode:    23865337ns
> 
> So ~10% improvement versus plain Physical mode.

Nice.

>  Note that Xen uses Cluster
> mode by default, and hence is already using the fastest way for IPI delivery 
> at
> the cost of reducing the amount of vectors available system-wide.
> 
> Make the newly introduced mode the default one.
> 
> Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> Do we want to keep a full Logical Cluster mode available?  I don't see a 
> reason
> to target external interrupts in Logical Cluster mode, but maybe there's
> something I'm missing.
> 
> It's not clear to me whether the ACPI FADT flags are meant to apply only to
> external interrupt delivery mode, or also to IPI delivery.  If
> ACPI_FADT_APIC_PHYSICAL is only meant to apply to external interrupts and not
> IPIs then we could possibly get rid of physical mode IPI delivery.
> 
> Still need to put this under XenServer extensive testing, but wanted to get
> some feedback before in case approach greatly changes.

Looks quite okay, just a couple of minor remarks:

> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -2802,6 +2802,14 @@ the watchdog.
>  
>  Permit use of x2apic setup for SMP environments.
>  
> +### x2apic-mode (x86)
> +> `= physical | cluster | mixed`
> +
> +> Default: `physical` if **FADT** mandates physical mode, `mixed` otherwise.
> +
> +In the case that x2apic is in use, this option switches between modes to
> +address APICs in the system as interrupt destinations.
> +
>  ### x2apic_phys (x86)
>  > `= <boolean>`
>  
> @@ -2812,6 +2820,9 @@ In the case that x2apic is in use, this option switches 
> between physical and
>  clustered mode.  The default, given no hint from the **FADT**, is cluster
>  mode.
>  
> +**WARNING: `x2apic_phys` is deprecated and superseded by `x2apic-mode`.
> +The later takes precedence if both are set.**

s/later/latter/ ?

This may further want a CHANGELOG.md entry.

> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -228,11 +228,18 @@ config XEN_ALIGN_2M
>  
>  endchoice
>  
> -config X2APIC_PHYSICAL
> -     bool "x2APIC Physical Destination mode"
> -     help
> -       Use x2APIC Physical Destination mode by default when available.
> +choice
> +     prompt "x2APIC Destination mode"
> +     default X2APIC_MIXED
> +     ---help---

No new ---help--- please (also below); it ought to be just help going forward.

> +       Select APIC addressing when x2APIC is enabled.
>  
> +       The default mode is mixed which should provide the best aspects
> +       of both physical and cluster modes.
> +
> +config X2APIC_PHYSICAL
> +       tristate "Physical Destination mode"
> +     ---help---

Something's odd with indentation here. But first of all - why tristate? We
don't have modules in Xen.

> --- a/xen/arch/x86/genapic/x2apic.c
> +++ b/xen/arch/x86/genapic/x2apic.c
> @@ -180,6 +180,25 @@ static const struct genapic __initconstrel 
> apic_x2apic_cluster = {
>      .send_IPI_self = send_IPI_self_x2apic
>  };
>  
> +/*
> + * Mixed x2APIC mode: use physical for external (device) interrupts, and
> + * cluster for inter processor interrupt.  Such mode has the benefits of not
> + * sharing the vector space with all CPUs on the cluster, while still allows
> + * IPIs to be more efficiently delivered by not having to perform an ICR
> + * write for each target CPU.
> + */
> +static const struct genapic __initconstrel apic_x2apic_mixed = {
> +    APIC_INIT("x2apic_mixed", NULL),
> +    /* NB: int_{delivery,dest}_mode are only used by non-IPI callers. */
> +    .int_delivery_mode = dest_Fixed,
> +    .int_dest_mode = 0 /* physical delivery */,
> +    .init_apic_ldr = init_apic_ldr_x2apic_cluster,
> +    .vector_allocation_cpumask = vector_allocation_cpumask_phys,
> +    .cpu_mask_to_apicid = cpu_mask_to_apicid_phys,

You have a non-IPI-only comment further up, but that - if in fact 
applicable here - would need to extend to these two hook functions as
well.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.