Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-11 Thread Jan Beulich
>>> On 11.05.15 at 14:11, wrote: > El 11/05/15 a les 12.41, Jan Beulich ha escrit: > On 11.05.15 at 11:52, wrote: >>> El 11/05/15 a les 9.42, Jan Beulich ha escrit: >>> On 08.05.15 at 16:34, wrote: There actually is another problem here: You must not free the pages before havin

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-11 Thread Roger Pau Monné
El 11/05/15 a les 12.41, Jan Beulich ha escrit: On 11.05.15 at 11:52, wrote: >> El 11/05/15 a les 9.42, Jan Beulich ha escrit: >> On 08.05.15 at 16:34, wrote: >>> There actually is another problem here: You must not free the >>> pages before having torn down the mapping. An option (to >>

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-11 Thread Jan Beulich
>>> On 11.05.15 at 11:52, wrote: > El 11/05/15 a les 9.42, Jan Beulich ha escrit: > On 08.05.15 at 16:34, wrote: >>> +void vfree(void *va) >>> +{ >>> +unsigned int i, pages = vm_size(va); >>> + >>> +if ( pages == 0 ) >>> +return; >>> + >>> +for ( i = 0; i < pages; i++ ) >>

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-11 Thread Roger Pau Monné
Hello, El 11/05/15 a les 9.42, Jan Beulich ha escrit: On 08.05.15 at 16:34, wrote: >> +void vfree(void *va) >> +{ >> +unsigned int i, pages = vm_size(va); >> + >> +if ( pages == 0 ) >> +return; >> + >> +for ( i = 0; i < pages; i++ ) >> +free_domheap_pages(vmap_to_

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-11 Thread Jan Beulich
>>> On 08.05.15 at 16:34, wrote: > +void vfree(void *va) > +{ > +unsigned int i, pages = vm_size(va); > + > +if ( pages == 0 ) > +return; > + > +for ( i = 0; i < pages; i++ ) > +free_domheap_pages(vmap_to_page(va + i * PAGE_SIZE), 1); > + > +vunmap(va); > +} There

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-08 Thread Jan Beulich
>>> On 08.05.15 at 16:34, wrote: > --- a/xen/common/vmap.c > +++ b/xen/common/vmap.c > @@ -146,7 +146,7 @@ static unsigned int vm_index(const void *va) > test_bit(idx, vm_bitmap) ? idx : 0; > } > > -static unsigned int vm_size(const void *va) > +unsigned int vm_size(const void *va)

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-08 Thread Jan Beulich
>>> On 08.05.15 at 16:50, wrote: > On 08/05/15 15:34, Roger Pau Monne wrote: >> + >> +void *vmalloc(unsigned long size) >> +{ >> +unsigned long *mfn; >> +unsigned long pages, i; >> +struct page_info *pg; >> +void *va = NULL; >> + >> +ASSERT(!in_irq()); >> + >> +if ( size ==

Re: [Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-08 Thread Andrew Cooper
On 08/05/15 15:34, Roger Pau Monne wrote: > The allocator uses independent calls to alloc_domheap_pages in order to get > the desired amount of memory and then maps all the independent physical > addresses into a contiguous virtual address space. > > Signed-off-by: Roger Pau Monné > Tested-by: Jul

[Xen-devel] [PATCH v5 1/4] xen: introduce a helper to allocate non-contiguous memory

2015-05-08 Thread Roger Pau Monne
The allocator uses independent calls to alloc_domheap_pages in order to get the desired amount of memory and then maps all the independent physical addresses into a contiguous virtual address space. Signed-off-by: Roger Pau Monné Tested-by: Julien Grall (ARM) Cc: Stefano Stabellini Cc: Ian Camp