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

Re: [Xen-devel] [PATCH 5/7] x86/domain: Optimise the order of actions in arch_domain_create()



On Fri, Mar 09, 2018 at 01:18:40PM +0000, Andrew Cooper wrote:
> The only relevent initialisation for the idle domain is the context switch and
           ^ relevant
> poisoned pointers.  Collect these bits together early in the function and exit
> when complete (although as a consequence, the e820 and vtsc lock
> initialisation are moved forwards).  This allows us to remove subsequent
> is_idle_domain() checks and unindent most of the logic.
> 
> Furthermore, we no longer call these functions for the idle domain:
>  * mapcache_domain_init() and tsc_set_info() were previously guarded against
>    the idle domain, and have had their guards turned into ASSERT()s.
>  * pit_init() is implicitly guarded by has_vpit().
>  * psr_domain_init() no longer allocates a socket array.
> 
> Finally, two changes are introduced for the benefit of the following patch:
>  * For PV hardware domains, or XEN_X86_EMU_PIT into emflags rather than into
>    config->emulation_flags, to facilitating config becoming const.
>  * References to domcr_flags are moved until after the idle early exist, to
                                                                    ^ exit
>    facilitiate them being unavailable for system domains.
> 
> No practical change in behaviour.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Wei Liu <wei.liu2@xxxxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
>  xen/arch/x86/domain.c      | 152 
> ++++++++++++++++++++++-----------------------
>  xen/arch/x86/domain_page.c |   3 +-
>  xen/arch/x86/time.c        |   4 +-
>  3 files changed, 78 insertions(+), 81 deletions(-)
> 
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index 81ee992..48dc2b9 100644
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -430,20 +430,37 @@ int arch_domain_create(struct domain *d, unsigned int 
> domcr_flags,
>                         struct xen_arch_domainconfig *config)
>  {
>      bool paging_initialised = false;
> +    uint32_t emflags;
>      int rc;
>  
> -    if ( config == NULL && !is_idle_domain(d) )
> -        return -EINVAL;
> -
> -    d->arch.s3_integrity = domcr_flags & XEN_DOMCTL_CDF_s3_integrity;
> -
>      INIT_LIST_HEAD(&d->arch.pdev_list);
>  
>      d->arch.relmem = RELMEM_not_started;
>      INIT_PAGE_LIST_HEAD(&d->arch.relmem_list);
>  
> -    if ( d->domain_id && !is_idle_domain(d) &&
> -         cpu_has_amd_erratum(&boot_cpu_data, AMD_ERRATUM_121) )
> +    spin_lock_init(&d->arch.e820_lock);
> +    spin_lock_init(&d->arch.vtsc_lock);
> +
> +    /* Minimal initialisation for the idle domain. */
> +    if ( unlikely(is_idle_domain(d)) )
> +    {
> +        static const struct arch_csw idle_csw = {
> +            .from = paravirt_ctxt_switch_from,
> +            .to   = paravirt_ctxt_switch_to,
> +            .tail = continue_idle_domain,
> +        };
> +
> +        d->arch.ctxt_switch = &idle_csw;
> +
> +        d->arch.cpuid = ZERO_BLOCK_PTR; /* Catch stray misuses. */
> +        d->arch.msr = ZERO_BLOCK_PTR;
> +
> +        return 0;
> +    }
> +    else if ( !config )

Unneeded else.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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