vmalloc/vzalloc: Add memflags parameter.
RFC PATCH 1/1 vmalloc/vzalloc: Add memflags parameter.
And use it amongst the callers of this function.
--- 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(-)
xen/arch/x86/mm/hap/hap.c +1 -1
@@ -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;
xen/arch/x86/mm/shadow/common.c +1 -1
@@ -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 ;
xen/common/domain.c +1 -1
@@ -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 ) )
xen/common/domctl.c +1 -1
@@ -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
xen/common/grant_table.c +2 -1
@@ -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;
xen/common/vmap.c +4 -4
@@ -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 )
xen/include/asm-x86/domain.h +2 -2
@@ -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)
xen/include/xen/vmap.h +2 -2
@@ -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 );
Signature · 1 line
2.1.0
Quoted 1 line · Konrad Rzeszutek Wilk
And use it amongst the callers of this function.
I expect this will also need some (hopefully trivial) changes for ARM too?
Quoted 151 lines
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>---
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(-)xen/arch/x86/mm/hap/hap.c +0
-0@@ -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;xen/arch/x86/mm/shadow/common.c +0
-0@@ -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;xen/common/domain.c +0
-0@@ -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))xen/common/domctl.c +1
-1@@ -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;
#ifdefCONFIG_COMPATxen/common/grant_table.c +0
-0@@ -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 )
gotono_mem_2;xen/common/vmap.c +0
-0@@ -216,7 +216,7 @@ void vunmap(const void *va) vm_free(va); }xen/common/vmap.c +1
-1-void *vmalloc (size_t size) +void *vmalloc (size_t size,unsigned int memflags){
mfn_t *mfn;
size_t pages, i;xen/common/vmap.c +0
-0@@ -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));xen/common/vmap.c +0
-0@@ -252,9 +252,9 @@ void *vmalloc(size_t size) return NULL; }xen/common/vmap.c +1
-1-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 )xen/include/asm-x86/domain.h +0
-0@@ -577,9 +577,9 @@ void domain_cpuid(struct domain *d,
#definedomain_max_vcpus(d)(is_hvm_domain(d)?HVM_MAX_VCPUS:MAX_VIRT_CPUS)xen/include/asm-x86/domain.h +1
-1-static inline struct vcpu_guest_context *alloc_vcpu_guest_context (void ) +static inline struct vcpu_guest_context*alloc_vcpu_guest_context(unsigned int memflags)
{
- returnvmalloc(sizeof(struct vcpu_guest_context));
+ returnvmalloc(sizeof(struct vcpu_guest_context), memflags); }
static inline voidfree_vcpu_guest_context(struct vcpu_guest_context *vgc)xen/include/xen/vmap.h +2
-2@@ -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);
Quoted 2 lines
void__iomem*ioremap(paddr_t,size_t);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
xen/common/domain.c long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg) · line 1226
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 02.11.15 at 18:12, <[email protected]> wrote:
xen/common/domain.c +1
-1@@ -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.
xen/common/domctl.c long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) · line 495
Quoted 8 lines
xen/common/domctl.c +1
-1@@ -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.
xen/include/asm-x86/domain.h void domain_cpuid(struct domain *d, · line 583
Quoted 12 lines
xen/include/asm-x86/domain.h +2
-2@@ -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