All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] vmalloc/vzalloc: Add memflags parameter.
@ 2015-11-02 17:12 Konrad Rzeszutek Wilk
  2015-11-03 12:39 ` Ian Campbell
  2015-11-05 17:08 ` Jan Beulich
  0 siblings, 2 replies; 3+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-11-02 17:12 UTC (permalink / raw)
  To: xen-devel, andrew.cooper3, jbeulich; +Cc: Konrad Rzeszutek Wilk

And use it amongst the callers of this function.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 xen/arch/x86/mm/hap/hap.c       | 2 +-
 xen/arch/x86/mm/shadow/common.c | 2 +-
 xen/common/domain.c             | 2 +-
 xen/common/domctl.c             | 2 +-
 xen/common/grant_table.c        | 3 ++-
 xen/common/vmap.c               | 8 ++++----
 xen/include/asm-x86/domain.h    | 4 ++--
 xen/include/xen/vmap.h          | 4 ++--
 8 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
index e9c0080..acc5219 100644
--- a/xen/arch/x86/mm/hap/hap.c
+++ b/xen/arch/x86/mm/hap/hap.c
@@ -86,7 +86,7 @@ int hap_track_dirty_vram(struct domain *d,
         }
 
         rc = -ENOMEM;
-        dirty_bitmap = vzalloc(size);
+        dirty_bitmap = vzalloc(size, MEMF_node(domain_to_node(d)));
         if ( !dirty_bitmap )
             goto out;
 
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index bad355b..4169083 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -3491,7 +3491,7 @@ int shadow_track_dirty_vram(struct domain *d,
     if ( !nr )
         goto out;
 
-    dirty_bitmap = vzalloc(dirty_size);
+    dirty_bitmap = vzalloc(dirty_size, MEMF_node(domain_to_node(d)));
     if ( dirty_bitmap == NULL )
     {
         rc = -ENOMEM;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index b0378aa..55a94d4 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1223,7 +1223,7 @@ 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 = alloc_vcpu_guest_context(MEMF_node(domain_to_node(d)))) == NULL )
             return -ENOMEM;
 
         if ( copy_from_guest(ctxt, arg, 1) )
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 46b967e..b874b01 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -492,7 +492,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 = alloc_vcpu_guest_context(MEMF_node(domain_to_node(d)))) == NULL )
             break;
 
 #ifdef CONFIG_COMPAT
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index c92abda..b86286f 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -3200,7 +3200,8 @@ grant_table_create(
     }
 
     /* Tracking of mapped foreign frames table */
-    t->maptrack = vzalloc(max_maptrack_frames * sizeof(*t->maptrack));
+    t->maptrack = vzalloc(max_maptrack_frames * sizeof(*t->maptrack),
+                          MEMF_node(domain_to_node(d)));
     if ( t->maptrack == NULL )
         goto no_mem_2;
 
diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index c57239f..fd295b1 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -216,7 +216,7 @@ void vunmap(const void *va)
     vm_free(va);
 }
 
-void *vmalloc(size_t size)
+void *vmalloc(size_t size, unsigned int memflags)
 {
     mfn_t *mfn;
     size_t pages, i;
@@ -232,7 +232,7 @@ void *vmalloc(size_t size)
 
     for ( i = 0; i < pages; i++ )
     {
-        pg = alloc_domheap_page(NULL, 0);
+        pg = alloc_domheap_page(NULL, memflags);
         if ( pg == NULL )
             goto error;
         mfn[i] = _mfn(page_to_mfn(pg));
@@ -252,9 +252,9 @@ void *vmalloc(size_t size)
     return NULL;
 }
 
-void *vzalloc(size_t size)
+void *vzalloc(size_t size, unsigned int memflags)
 {
-    void *p = vmalloc(size);
+    void *p = vmalloc(size, memflags);
     int i;
 
     if ( p == NULL )
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index f1d7ed6..a98bf3b 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -577,9 +577,9 @@ 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)
+static inline struct vcpu_guest_context *alloc_vcpu_guest_context(unsigned int memflags)
 {
-    return vmalloc(sizeof(struct vcpu_guest_context));
+    return vmalloc(sizeof(struct vcpu_guest_context), memflags);
 }
 
 static inline void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
index 5671ac8..f24a29e 100644
--- a/xen/include/xen/vmap.h
+++ b/xen/include/xen/vmap.h
@@ -11,8 +11,8 @@ void *__vmap(const mfn_t *mfn, unsigned int granularity,
              unsigned int nr, unsigned int align, unsigned int flags);
 void *vmap(const mfn_t *mfn, unsigned int nr);
 void vunmap(const void *);
-void *vmalloc(size_t size);
-void *vzalloc(size_t size);
+void *vmalloc(size_t size, unsigned int memflags);
+void *vzalloc(size_t size, unsigned int memflags);
 void vfree(void *va);
 
 void __iomem *ioremap(paddr_t, size_t);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC] vmalloc/vzalloc: Add memflags parameter.
  2015-11-02 17:12 [PATCH RFC] vmalloc/vzalloc: Add memflags parameter Konrad Rzeszutek Wilk
@ 2015-11-03 12:39 ` Ian Campbell
  2015-11-05 17:08 ` Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2015-11-03 12:39 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, xen-devel, andrew.cooper3, jbeulich

On Mon, 2015-11-02 at 12:12 -0500, Konrad Rzeszutek Wilk wrote:
> And use it amongst the callers of this function.

I expect this will also need some (hopefully trivial) changes for ARM too?

> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  xen/arch/x86/mm/hap/hap.c       | 2 +-
>  xen/arch/x86/mm/shadow/common.c | 2 +-
>  xen/common/domain.c             | 2 +-
>  xen/common/domctl.c             | 2 +-
>  xen/common/grant_table.c        | 3 ++-
>  xen/common/vmap.c               | 8 ++++----
>  xen/include/asm-x86/domain.h    | 4 ++--
>  xen/include/xen/vmap.h          | 4 ++--
>  8 files changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c
> index e9c0080..acc5219 100644
> --- a/xen/arch/x86/mm/hap/hap.c
> +++ b/xen/arch/x86/mm/hap/hap.c
> @@ -86,7 +86,7 @@ int hap_track_dirty_vram(struct domain *d,
>          }
>  
>          rc = -ENOMEM;
> -        dirty_bitmap = vzalloc(size);
> +        dirty_bitmap = vzalloc(size, MEMF_node(domain_to_node(d)));
>          if ( !dirty_bitmap )
>              goto out;
>  
> diff --git a/xen/arch/x86/mm/shadow/common.c
> b/xen/arch/x86/mm/shadow/common.c
> index bad355b..4169083 100644
> --- a/xen/arch/x86/mm/shadow/common.c
> +++ b/xen/arch/x86/mm/shadow/common.c
> @@ -3491,7 +3491,7 @@ int shadow_track_dirty_vram(struct domain *d,
>      if ( !nr )
>          goto out;
>  
> -    dirty_bitmap = vzalloc(dirty_size);
> +    dirty_bitmap = vzalloc(dirty_size, MEMF_node(domain_to_node(d)));
>      if ( dirty_bitmap == NULL )
>      {
>          rc = -ENOMEM;
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index b0378aa..55a94d4 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -1223,7 +1223,7 @@ 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 =
> alloc_vcpu_guest_context(MEMF_node(domain_to_node(d)))) == NULL )
>              return -ENOMEM;
>  
>          if ( copy_from_guest(ctxt, arg, 1) )
> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
> index 46b967e..b874b01 100644
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -492,7 +492,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 =
> alloc_vcpu_guest_context(MEMF_node(domain_to_node(d)))) == NULL )
>              break;
>  
>  #ifdef CONFIG_COMPAT
> diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
> index c92abda..b86286f 100644
> --- a/xen/common/grant_table.c
> +++ b/xen/common/grant_table.c
> @@ -3200,7 +3200,8 @@ grant_table_create(
>      }
>  
>      /* Tracking of mapped foreign frames table */
> -    t->maptrack = vzalloc(max_maptrack_frames * sizeof(*t->maptrack));
> +    t->maptrack = vzalloc(max_maptrack_frames * sizeof(*t->maptrack),
> +                          MEMF_node(domain_to_node(d)));
>      if ( t->maptrack == NULL )
>          goto no_mem_2;
>  
> diff --git a/xen/common/vmap.c b/xen/common/vmap.c
> index c57239f..fd295b1 100644
> --- a/xen/common/vmap.c
> +++ b/xen/common/vmap.c
> @@ -216,7 +216,7 @@ void vunmap(const void *va)
>      vm_free(va);
>  }
>  
> -void *vmalloc(size_t size)
> +void *vmalloc(size_t size, unsigned int memflags)
>  {
>      mfn_t *mfn;
>      size_t pages, i;
> @@ -232,7 +232,7 @@ void *vmalloc(size_t size)
>  
>      for ( i = 0; i < pages; i++ )
>      {
> -        pg = alloc_domheap_page(NULL, 0);
> +        pg = alloc_domheap_page(NULL, memflags);
>          if ( pg == NULL )
>              goto error;
>          mfn[i] = _mfn(page_to_mfn(pg));
> @@ -252,9 +252,9 @@ void *vmalloc(size_t size)
>      return NULL;
>  }
>  
> -void *vzalloc(size_t size)
> +void *vzalloc(size_t size, unsigned int memflags)
>  {
> -    void *p = vmalloc(size);
> +    void *p = vmalloc(size, memflags);
>      int i;
>  
>      if ( p == NULL )
> diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
> index f1d7ed6..a98bf3b 100644
> --- a/xen/include/asm-x86/domain.h
> +++ b/xen/include/asm-x86/domain.h
> @@ -577,9 +577,9 @@ 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)
> +static inline struct vcpu_guest_context
> *alloc_vcpu_guest_context(unsigned int memflags)
>  {
> -    return vmalloc(sizeof(struct vcpu_guest_context));
> +    return vmalloc(sizeof(struct vcpu_guest_context), memflags);
>  }
>  
>  static inline void free_vcpu_guest_context(struct vcpu_guest_context
> *vgc)
> diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
> index 5671ac8..f24a29e 100644
> --- a/xen/include/xen/vmap.h
> +++ b/xen/include/xen/vmap.h
> @@ -11,8 +11,8 @@ void *__vmap(const mfn_t *mfn, unsigned int
> granularity,
>               unsigned int nr, unsigned int align, unsigned int flags);
>  void *vmap(const mfn_t *mfn, unsigned int nr);
>  void vunmap(const void *);
> -void *vmalloc(size_t size);
> -void *vzalloc(size_t size);
> +void *vmalloc(size_t size, unsigned int memflags);
> +void *vzalloc(size_t size, unsigned int memflags);
>  void vfree(void *va);
>  
>  void __iomem *ioremap(paddr_t, size_t);

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC] vmalloc/vzalloc: Add memflags parameter.
  2015-11-02 17:12 [PATCH RFC] vmalloc/vzalloc: Add memflags parameter Konrad Rzeszutek Wilk
  2015-11-03 12:39 ` Ian Campbell
@ 2015-11-05 17:08 ` Jan Beulich
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2015-11-05 17:08 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: andrew.cooper3, xen-devel

>>> On 02.11.15 at 18:12, <konrad.wilk@oracle.com> wrote:
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -1223,7 +1223,7 @@ 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 = alloc_vcpu_guest_context(MEMF_node(domain_to_node(d)))) == NULL )

This one's a temporary allocation that gets freed a few lines down.
Hence best performance would be achieved by using the current
CPU's node, which iiuc will result if you pass just zero here.

> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -492,7 +492,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 = alloc_vcpu_guest_context(MEMF_node(domain_to_node(d)))) == NULL )

Same here.

> --- a/xen/include/asm-x86/domain.h
> +++ b/xen/include/asm-x86/domain.h
> @@ -577,9 +577,9 @@ 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)
> +static inline struct vcpu_guest_context *alloc_vcpu_guest_context(unsigned int memflags)
>  {
> -    return vmalloc(sizeof(struct vcpu_guest_context));
> +    return vmalloc(sizeof(struct vcpu_guest_context), memflags);

With the above you won't need to add a parameter to the
function anymore, but if for some reason you did you'd need
to mirror this to ARM code.

Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-05 17:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-02 17:12 [PATCH RFC] vmalloc/vzalloc: Add memflags parameter Konrad Rzeszutek Wilk
2015-11-03 12:39 ` Ian Campbell
2015-11-05 17:08 ` Jan Beulich

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.