* [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context()
@ 2015-09-17 16:52 Andrew Cooper
2015-09-17 18:02 ` Julien Grall
2015-09-21 14:12 ` Jan Beulich
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-09-17 16:52 UTC (permalink / raw)
To: Xen-devel
Cc: Ian Campbell, Andrew Cooper, Tim Deegan, Julien Grall,
Stefano Stabellini, Jan Beulich, Roger Pau Monne
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.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Stefano Stabellini <stefano.stabellini@citrix.com>
CC: Julien Grall <julien.grall@citrix.com>
CC: Roger Pau Monne <roger.pau@citrix.com>
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(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 5bdc2e9..575745c 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -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;
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 5ff09e7..0b97912 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -48,7 +48,6 @@
#include <asm/cpuidle.h>
#include <asm/mpspec.h>
#include <asm/ldt.h>
-#include <asm/fixmap.h>
#include <asm/hvm/hvm.h>
#include <asm/hvm/support.h>
#include <asm/hvm/viridian.h>
@@ -272,51 +271,6 @@ void free_vcpu_struct(struct vcpu *v)
free_xenheap_page(v);
}
-static DEFINE_PER_CPU(struct page_info *[
- PFN_UP(sizeof(struct vcpu_guest_context))], vgc_pages);
-
-struct vcpu_guest_context *alloc_vcpu_guest_context(void)
-{
- unsigned int i, cpu = smp_processor_id();
- enum fixed_addresses idx = FIX_VGC_BEGIN -
- cpu * PFN_UP(sizeof(struct vcpu_guest_context));
-
- BUG_ON(per_cpu(vgc_pages[0], cpu) != NULL);
-
- for ( i = 0; i < PFN_UP(sizeof(struct vcpu_guest_context)); ++i )
- {
- struct page_info *pg = alloc_domheap_page(current->domain,
- MEMF_no_owner);
-
- if ( unlikely(pg == NULL) )
- {
- free_vcpu_guest_context(NULL);
- return NULL;
- }
- __set_fixmap(idx - i, page_to_mfn(pg), __PAGE_HYPERVISOR_RW);
- per_cpu(vgc_pages[i], cpu) = pg;
- }
- return (void *)fix_to_virt(idx);
-}
-
-void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
-{
- unsigned int i, cpu = smp_processor_id();
- enum fixed_addresses idx = FIX_VGC_BEGIN -
- cpu * PFN_UP(sizeof(struct vcpu_guest_context));
-
- BUG_ON(vgc && vgc != (void *)fix_to_virt(idx));
-
- for ( i = 0; i < PFN_UP(sizeof(struct vcpu_guest_context)); ++i )
- {
- if ( !per_cpu(vgc_pages[i], cpu) )
- continue;
- clear_fixmap(idx - i);
- free_domheap_page(per_cpu(vgc_pages[i], cpu));
- per_cpu(vgc_pages[i], cpu) = NULL;
- }
-}
-
static int setup_compat_l4(struct vcpu *v)
{
struct page_info *pg;
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index 7ddaeaa..c3f5a95 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -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__ */
/*
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 59cf826..f0aeade 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -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__ */
/*
diff --git a/xen/include/asm-x86/fixmap.h b/xen/include/asm-x86/fixmap.h
index 70eadff..1e24b11 100644
--- a/xen/include/asm-x86/fixmap.h
+++ b/xen/include/asm-x86/fixmap.h
@@ -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,
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index a469fe0..3dca3f6 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -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 *);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context()
2015-09-17 16:52 [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context() Andrew Cooper
@ 2015-09-17 18:02 ` Julien Grall
2015-09-21 14:12 ` Jan Beulich
1 sibling, 0 replies; 4+ messages in thread
From: Julien Grall @ 2015-09-17 18:02 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel
Cc: Stefano Stabellini, Tim Deegan, Ian Campbell, Jan Beulich,
Roger Pau Monne
Hi Andrew,
On 17/09/15 17:52, Andrew Cooper 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.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Tim Deegan <tim@xen.org>
> CC: Ian Campbell <ian.campbell@citrix.com>
> CC: Stefano Stabellini <stefano.stabellini@citrix.com>
> CC: Julien Grall <julien.grall@citrix.com>
> CC: Roger Pau Monne <roger.pau@citrix.com>
For the ARM bits:
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Regards,
--
Julien Grall
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context()
2015-09-17 16:52 [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context() Andrew Cooper
2015-09-17 18:02 ` Julien Grall
@ 2015-09-21 14:12 ` Jan Beulich
2015-09-21 14:45 ` Ian Campbell
1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2015-09-21 14:12 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel
Cc: Julien Grall, Tim Deegan, Stefano Stabellini, Ian Campbell,
Roger Pau Monne
>>> On 17.09.15 at 18:52, <andrew.cooper3@citrix.com> 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.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(still awaiting an ARM maintainer ack for this to go in)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context()
2015-09-21 14:12 ` Jan Beulich
@ 2015-09-21 14:45 ` Ian Campbell
0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2015-09-21 14:45 UTC (permalink / raw)
To: Jan Beulich, Andrew Cooper, Xen-devel
Cc: Julien Grall, Tim Deegan, Stefano Stabellini, Roger Pau Monne
On Mon, 2015-09-21 at 08:12 -0600, Jan Beulich wrote:
> > > > On 17.09.15 at 18:52, <andrew.cooper3@citrix.com> 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.
> >
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> (still awaiting an ARM maintainer ack for this to go in)
Sorry, thought I had already:
Acked-by: Ian Campbell <ian.campbell@citrix.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-21 14:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 16:52 [PATCH v2] xen: Improve x86's alloc_vcpu_guest_context() Andrew Cooper
2015-09-17 18:02 ` Julien Grall
2015-09-21 14:12 ` Jan Beulich
2015-09-21 14:45 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).