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

Re: [PATCH v2] xen/domain: introduce generic functions for domain struct allocation and freeing


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Wed, 26 Nov 2025 22:35:52 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=sjNEa43S9YozlXIRJEM2jd23F4i/z7miVjUjfFe1MBg=; b=S6604kiK9sOihky+RIagk+W1g7IarLCVeJOwnQzBWW4SH6G4PNcDBT1A+MjX3CjWcxgJRayF6B0CB4FgF698AzVl/XDJ5Js2cnKGgOp7+vGPBDWOrZSDYC6mf1OnimO+7Jcz5YURJQ0HvZJGCM188GrS9uc4W+CLTaXndirjjIZCiaNQ4advKrYOeHvtt2EPPtqYMF+8IJRW9CyoJjlERkIVg+yGDGZSU0TTR4otSBSfwMxtm3ip0UmCUgo/Hy/qb603tLCrapX2qAcJ/7LiT8BDxOWEWdq+xQfTXN1yHO/5DnwueZtnZWrXyhWiRN7KF2PLq/J9E9vLQhGmwzygPQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DXNAY5KumZvZVCdI5W6WCx3TsM7bWjq6++L2z56K4cyIFHF7nubJq+9F5jLKXONc4r3uf7qS3bZm6xz7B9Sd8WNS9RGDXuKE5jgnwMIg/NugW71grgJ6QImngbXGVTChmPkqPw1LbBJwLIPvVEJvBAMc3TvS+hB2uGJ7dEDm34XjJrLWfNxbtGbSLpO4VllFlCVbNValR5dm0LX23S+aIdaM0dETakUBmHf/OUmd8g1L0v7JK7BvhxBDR5QundhCQZL1RYlB1tmuc9oabbb94B7J06TYL4TIj3zgGWjcgBu1LW8Te9bpNSg5QlMfl9aY2GXo+sK2H3Ppz6L+mUGjQw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Timothy Pearson <tpearson@xxxxxxxxxxxxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>
  • Delivery-date: Wed, 26 Nov 2025 20:36:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 26.11.25 16:32, Oleksii Kurochko wrote:
From: Roger Pau Monne <roger.pau@xxxxxxxxxx>

Move x86's free_domain_struct() to common code since it is shared between
architectures.

Move the x86 version of alloc_domain_struct() to common code as most of the
logic is architecture-independent. To handle the remaining architectural
differences, introduce arch_alloc_domain_struct_bits() for x86-specific
allocation requirements.

No functional change.

Suggested-By: Jan Beulich <jbeulich@xxxxxxxx>
[Introduce an arch-specific function instead of using a weak function]
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
Changes in v2:
- CI test results: 
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/2180836457
- Introduce an arch-specific function to handle differences between arch-es
   in domain structure allocation requirements, instead of relying on a weak
   function.
- Add Suggested-by: Jan Beulich <jbeulich@xxxxxxxx>.
- Move free_domain_struct() to common code.
- Update the commit message.
---
  xen/arch/arm/domain.c                | 17 -----------------
  xen/arch/ppc/stubs.c                 | 10 ----------
  xen/arch/riscv/stubs.c               | 10 ----------
  xen/arch/x86/domain.c                | 15 ++-------------
  xen/arch/x86/include/asm/pv/domain.h |  3 +++
  xen/common/domain.c                  | 23 +++++++++++++++++++++++
  6 files changed, 28 insertions(+), 50 deletions(-)


[...]

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 3a21e035f4..34a02f089e 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -463,10 +463,8 @@ void domain_cpu_policy_changed(struct domain *d)
      }
  }
-struct domain *alloc_domain_struct(void)
+unsigned int arch_alloc_domain_struct_bits(void)
  {
-    struct domain *d;
-
      /*
       * Without CONFIG_BIGMEM, we pack the PDX of the domain structure into
       * a 32-bit field within the page_info structure. Hence the MEMF_bits()
@@ -492,16 +490,7 @@ struct domain *alloc_domain_struct(void)
                  - 1;
  #endif
- BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);
-    d = alloc_xenheap_pages(0, MEMF_bits(bits));
-    if ( d != NULL )
-        clear_page(d);
-    return d;
-}
-
-void free_domain_struct(struct domain *d)
-{
-    free_xenheap_page(d);
+    return bits;
  }
struct vcpu *alloc_vcpu_struct(const struct domain *d)
diff --git a/xen/arch/x86/include/asm/pv/domain.h 
b/xen/arch/x86/include/asm/pv/domain.h
index 582d004051..6e65bc22fc 100644
--- a/xen/arch/x86/include/asm/pv/domain.h
+++ b/xen/arch/x86/include/asm/pv/domain.h
@@ -18,6 +18,9 @@ extern int8_t opt_pv32;
  # define opt_pv32 false
  #endif
+unsigned int arch_alloc_domain_struct_bits(void);
+#define arch_alloc_domin_struct_bits arch_alloc_domain_struct_bits

Is it intentionally placed in PV header x86/include/asm/pv/domain.h?

--
Best regards,
-grygorii




 


Rackspace

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