diff mbox series

[1/4] xen/domain: Introduce arch_init_idle_domain()

Message ID 20240718215744.3892072-2-andrew.cooper3@citrix.com (mailing list archive)
State New
Headers show
Series xen/domain: Idle domain creation improvements | expand

Commit Message

Andrew Cooper July 18, 2024, 9:57 p.m. UTC
The idle domain causes a large amount of complexity in domain_create() because
of x86's need to initialise d->arch.ctxt_switch in arch_domain_create().

In order to address this, introduce an optional hook to perform extra
initialisation of the idle domain.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/common/domain.c     | 3 +++
 xen/include/xen/sched.h | 5 +++++
 2 files changed, 8 insertions(+)

Comments

Stefano Stabellini July 30, 2024, 11:43 p.m. UTC | #1
On Thu, 18 Jul 2024, Andrew Cooper wrote:
> The idle domain causes a large amount of complexity in domain_create() because
> of x86's need to initialise d->arch.ctxt_switch in arch_domain_create().
> 
> In order to address this, introduce an optional hook to perform extra
> initialisation of the idle domain.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien@xen.org>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis <bertrand.marquis@arm.com>
> CC: Michal Orzel <michal.orzel@amd.com>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> ---
>  xen/common/domain.c     | 3 +++
>  xen/include/xen/sched.h | 5 +++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index fb262dcec919..e312c820d641 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -685,6 +685,9 @@ struct domain *domain_create(domid_t domid,
>  
>      rangeset_domain_initialise(d);
>  
> +    if ( is_idle_domain(d) )
> +        arch_init_idle_domain(d);
> +
>      /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. */
>      if ( is_system_domain(d) && !is_idle_domain(d) )
>          return d;
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 2dcd1d1a4f8a..90666576c2f8 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -728,6 +728,11 @@ struct domain *domain_create(domid_t domid,
>                               struct xen_domctl_createdomain *config,
>                               unsigned int flags);
>  
> +#ifndef arch_init_idle_domain
> +/* Optional, if there's any construction necessary for DOMID_IDLE */
> +static inline void arch_init_idle_domain(struct domain *d) {}
> +#endif
> +
>  /*
>   * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
>   * This is the preferred function if the returned domain reference
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/xen/common/domain.c b/xen/common/domain.c
index fb262dcec919..e312c820d641 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -685,6 +685,9 @@  struct domain *domain_create(domid_t domid,
 
     rangeset_domain_initialise(d);
 
+    if ( is_idle_domain(d) )
+        arch_init_idle_domain(d);
+
     /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. */
     if ( is_system_domain(d) && !is_idle_domain(d) )
         return d;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 2dcd1d1a4f8a..90666576c2f8 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -728,6 +728,11 @@  struct domain *domain_create(domid_t domid,
                              struct xen_domctl_createdomain *config,
                              unsigned int flags);
 
+#ifndef arch_init_idle_domain
+/* Optional, if there's any construction necessary for DOMID_IDLE */
+static inline void arch_init_idle_domain(struct domain *d) {}
+#endif
+
 /*
  * rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
  * This is the preferred function if the returned domain reference