All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>, Tim Deegan <tim@xen.org>,
	Xen-devel <xen-devel@lists.xen.org>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH for 4.7] xen: Replace alloc_vcpu_guest_context() with vmalloc()
Date: Fri, 21 Aug 2015 13:55:46 -0400	[thread overview]
Message-ID: <20150821175546.GC26425@l.oracle.com> (raw)
In-Reply-To: <1440179506-478-1-git-send-email-andrew.cooper3@citrix.com>

On Fri, Aug 21, 2015 at 06:51:46PM +0100, 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.

Could you explain what this fixes? Or perhaps with an explanation
of why this will make Xen [ ]better; [ ] faster [ ] magical.

:-)


Thanks.
> 
> 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>
> 
> Build tested on all architectures, functionally tested on x86.
> ---
>  xen/arch/arm/domain.c        |   11 ----------
>  xen/arch/arm/vpsci.c         |    5 +++--
>  xen/arch/x86/domain.c        |   46 ------------------------------------------
>  xen/common/domain.c          |    7 ++++---
>  xen/common/domctl.c          |    5 +++--
>  xen/include/asm-x86/fixmap.h |    3 ---
>  xen/include/xen/domain.h     |    6 ------
>  7 files changed, 10 insertions(+), 73 deletions(-)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index b2bfc7d..e0ef0d8 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/arm/vpsci.c b/xen/arch/arm/vpsci.c
> index aebe1e2..ba3414d 100644
> --- a/xen/arch/arm/vpsci.c
> +++ b/xen/arch/arm/vpsci.c
> @@ -13,6 +13,7 @@
>  #include <xen/errno.h>
>  #include <xen/sched.h>
>  #include <xen/types.h>
> +#include <xen/vmap.h>
>  
>  #include <asm/current.h>
>  #include <asm/gic.h>
> @@ -45,7 +46,7 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point,
>              ( !test_bit(_VPF_down, &v->pause_flags) ) )
>          return PSCI_ALREADY_ON;
>  
> -    if ( (ctxt = alloc_vcpu_guest_context()) == NULL )
> +    if ( (ctxt = vmalloc(sizeof(struct vcpu_guest_context))) == NULL )
>          return PSCI_DENIED;
>  
>      vgic_clear_pending_irqs(v);
> @@ -78,7 +79,7 @@ static int do_common_cpu_on(register_t target_cpu, register_t entry_point,
>  
>      domain_lock(d);
>      rc = arch_set_info_guest(v, ctxt);
> -    free_vcpu_guest_context(ctxt);
> +    vfree(ctxt);
>  
>      if ( rc < 0 )
>      {
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index 045f6ff..12ccdb8 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/common/domain.c b/xen/common/domain.c
> index 1b9fcfc..31d9e56 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -43,6 +43,7 @@
>  #include <xen/trace.h>
>  #include <xen/tmem.h>
>  #include <asm/setup.h>
> +#include <xen/vmap.h>
>  
>  /* Linux config option: propageted to domain0 */
>  /* xen_processor_pmbits: xen control Cx, Px, ... */
> @@ -1185,12 +1186,12 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
>          if ( v->vcpu_info == &dummy_vcpu_info )
>              return -EINVAL;
>  
> -        if ( (ctxt = alloc_vcpu_guest_context()) == NULL )
> +        if ( (ctxt = vmalloc(sizeof(struct vcpu_guest_context))) == NULL )
>              return -ENOMEM;
>  
>          if ( copy_from_guest(ctxt, arg, 1) )
>          {
> -            free_vcpu_guest_context(ctxt);
> +            vfree(ctxt);
>              return -EFAULT;
>          }
>  
> @@ -1198,7 +1199,7 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
>          rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, ctxt);
>          domain_unlock(d);
>  
> -        free_vcpu_guest_context(ctxt);
> +        vfree(ctxt);
>  
>          if ( rc == -ERESTART )
>              rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iuh",
> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
> index 7f959f3..90cc13c 100644
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -32,6 +32,7 @@
>  #include <asm/monitor.h>
>  #include <public/domctl.h>
>  #include <xsm/xsm.h>
> +#include <xen/vmap.h>
>  
>  static DEFINE_SPINLOCK(domctl_lock);
>  DEFINE_SPINLOCK(vcpu_alloc_lock);
> @@ -492,7 +493,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>                       < sizeof(struct compat_vcpu_guest_context));
>  #endif
>          ret = -ENOMEM;
> -        if ( (c.nat = alloc_vcpu_guest_context()) == NULL )
> +        if ( (c.nat = vmalloc(sizeof(struct vcpu_guest_context))) == NULL )
>              break;
>  
>  #ifdef CONFIG_COMPAT
> @@ -518,7 +519,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>                            __HYPERVISOR_domctl, "h", u_domctl);
>          }
>  
> -        free_vcpu_guest_context(c.nat);
> +        vfree(c.nat);
>          break;
>      }
>  
> 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 848db8a..db191d3 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
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

  reply	other threads:[~2015-08-21 17:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-21 17:51 [PATCH for 4.7] xen: Replace alloc_vcpu_guest_context() with vmalloc() Andrew Cooper
2015-08-21 17:55 ` Konrad Rzeszutek Wilk [this message]
2015-08-21 18:10   ` Andrew Cooper
2015-08-24 12:19     ` Jan Beulich
2015-08-24 12:19 ` Jan Beulich
2015-08-28 12:41 ` Julien Grall
2015-08-28 12:56   ` Andrew Cooper
2015-08-28 12:57     ` Julien Grall
2015-08-28 13:07       ` Andrew Cooper
2015-08-28 13:13         ` Julien Grall
2015-08-28 13:26           ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150821175546.GC26425@l.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.