Skip to contentSkip to conversation

xen: Improve x86's alloc_vcpu_guest_context()

PATCH In review Andrew Cooper 4 participants 4 messages Sep 17, 2015 – Sep 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen: Improve x86's alloc_vcpu_guest_context()

This essentially reverts c/s 2037f2adb "x86: introduce alloc_vcpu_guest_context()", including the newer arm bits, but achieves the same end goal by using the newer vmalloc() infrastructure.

For both x86 and ARM, {alloc,free}_vcpu_guest_context() become arch-local static inlines (which avoids a call into a separate translation), and removes an x86 scalability limit when compiling with a large NR_CPUS.

---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monne <[email protected]>

v2:
* Retain the use of x{malloc,free}() on ARM

Build tested on all architectures, functionally tested on x86.

---
 xen/arch/arm/domain.c        |   11 ----------
 xen/arch/x86/domain.c        |   46 ------------------------------------------
 xen/include/asm-arm/domain.h |   10 +++++++++
 xen/include/asm-x86/domain.h |   10 +++++++++
 xen/include/asm-x86/fixmap.h |    3 ---
 xen/include/xen/domain.h     |    6 ------
 6 files changed, 20 insertions(+), 66 deletions(-)
xen/arch/arm/domain.c +0 -11
index 5bdc2e9..575745c 100644
@@ -466,17 +466,6 @@ void free_vcpu_struct(struct vcpu *v)
     free_xenheap_page(v);
 }
 
-struct vcpu_guest_context *alloc_vcpu_guest_context(void)
-{
-    return xmalloc(struct vcpu_guest_context);
-
-}
-
-void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
-{
-    xfree(vgc);
-}
-
 int vcpu_initialise(struct vcpu *v)
 {
     int rc = 0;
xen/arch/x86/domain.c +0 -46

58 lines not on this page · raw message

xen/include/asm-arm/domain.h +10 -0
index 7ddaeaa..c3f5a95 100644
@@ -300,6 +300,16 @@ static inline register_t vcpuid_to_vaffinity(unsigned int vcpuid)
     return vaff;
 }
 
+static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void)
+{
+    return xmalloc(struct vcpu_guest_context);
+}
+
+static inline void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
+{
+    xfree(vgc);
+}
+
 #endif /* __ASM_DOMAIN_H__ */
 
 /*
xen/include/asm-x86/domain.h +10 -0
index 59cf826..f0aeade 100644
@@ -576,6 +576,16 @@ void domain_cpuid(struct domain *d,
 
 #define domain_max_vcpus(d) (is_hvm_domain(d) ? HVM_MAX_VCPUS : MAX_VIRT_CPUS)
 
+static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void)
+{
+    return vmalloc(sizeof(struct vcpu_guest_context));
+}
+
+static inline void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
+{
+    vfree(vgc);
+}
+
 #endif /* __ASM_DOMAIN_H__ */
 
 /*
xen/include/asm-x86/fixmap.h +0 -3
index 70eadff..1e24b11 100644
@@ -47,9 +47,6 @@ enum fixed_addresses {
     FIX_COM_END,
     FIX_EHCI_DBGP,
     /* Everything else should go further down. */
-    FIX_VGC_END,
-    FIX_VGC_BEGIN = FIX_VGC_END
-      + PFN_UP(sizeof(struct vcpu_guest_context)) * NR_CPUS - 1,
     FIX_APIC_BASE,
     FIX_IO_APIC_BASE_0,
     FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
xen/include/xen/domain.h +0 -6
index a469fe0..3dca3f6 100644
@@ -31,12 +31,6 @@ struct vcpu *alloc_vcpu(
 struct vcpu *alloc_vcpu_struct(void);
 void free_vcpu_struct(struct vcpu *v);
 
-/* Allocate/free a vcpu_guest_context structure. */
-#ifndef alloc_vcpu_guest_context
-struct vcpu_guest_context *alloc_vcpu_guest_context(void);
-void free_vcpu_guest_context(struct vcpu_guest_context *);
-#endif
-
 /* Allocate/free a PIRQ structure. */
 #ifndef alloc_pirq_struct
 struct pirq *alloc_pirq_struct(struct domain *);
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#1 lore raw

Hi Andrew,

Quoted 8 lines · Andrew Cooper

This essentially reverts c/s 2037f2adb "x86: introduce alloc_vcpu_guest_context()", including the newer arm bits, but achieves the same end goal by using the newer vmalloc() infrastructure.

For both x86 and ARM, {alloc,free}_vcpu_guest_context() become arch-local static inlines (which avoids a call into a separate translation), and removes an x86 scalability limit when compiling with a large NR_CPUS.

Quoted 8 lines

---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monne <[email protected]>

For the ARM bits:

Regards,

Signature · 1 line
Julien Grall
Reviewed-by on v2 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 17.09.15 at 18:52, <[email protected]> wrote:

This essentially reverts c/s 2037f2adb "x86: introduce alloc_vcpu_guest_context()", including the newer arm bits, but achieves the same end goal by using the newer vmalloc() infrastructure.

For both x86 and ARM, {alloc,free}_vcpu_guest_context() become arch-local static inlines (which avoids a call into a separate translation), and removes an x86 scalability limit when compiling with a large NR_CPUS.

(still awaiting an ARM maintainer ack for this to go in)

Acked-by
#3 lore raw
Quoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 17.09.15 at 18:52, <[email protected]> wrote:

This essentially reverts c/s 2037f2adb "x86: introduce alloc_vcpu_guest_context()", including the newer arm bits, but achieves the same end goal by using the newer vmalloc() infrastructure.

For both x86 and ARM, {alloc,free}_vcpu_guest_context() become arch -local
static inlines (which avoids a call into a separate translation), and removes an x86 scalability limit when compiling with a large NR_CPUS.

Quoted 5 lines
Quoted 1 line

(still awaiting an ARM maintainer ack for this to go in)

Sorry, thought I had already: