xen/malloc: handle correctly page allocation when align > size
PATCH 1/1 xen/malloc: handle correctly page allocation when align > size
When align is superior to size, we need to retrieve the order from align during multiple page allocation. I guess it was the goal of the commit fb034f42 "xmalloc: make close-to-PAGE_SIZE allocations more efficient".
--- xen/common/xmalloc_tlsf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/xmalloc_tlsf.c +1 -1
@@ -531,7 +531,7 @@ static void *xmalloc_whole_pages(unsigned long size, unsigned long align)void *res, *p;if ( align > size ) -get_order_from_bytes (align); + order =get_order_from_bytes (align); res =alloc_xenheap_pages (order,0 );if ( res ==NULL )
Signature · 1 line
1.8.5.3
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Julien Grall
When align is superior to size, we need to retrieve the order from align during multiple page allocation. I guess it was the goal of the commit
fb034f42"xmalloc: make close-to-PAGE_SIZE allocations more efficient".
Oh, yes, of course it was. Without that the call is pointless.
Quoted 1 line
Signed-off-by Julien Grall <[email protected]>
Albeit in fact the better change might be to simply use max(size, align) in the initializer of order - no idea why I didn't do it that way.
Out of curiosity: I never expected this code path to be actually taken - what is it that you need this to work correctly?
Jan
Quoted 11 lines
xen/common/xmalloc_tlsf.c +1
-1@@ -531,7 +531,7 @@ static void *xmalloc_whole_pages(unsigned long size, unsigned long align)void *res, *p;if ( align > size ) -get_order_from_bytes (align); + order =get_order_from_bytes (align); res =alloc_xenheap_pages (order,0 );if ( res ==NULL )
Quoted 7 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Julien Grall
When align is superior to size, we need to retrieve the order from align during multiple page allocation. I guess it was the goal of the commit
fb034f42"xmalloc: make close-to-PAGE_SIZE allocations more efficient".Oh, yes, of course it was. Without that the call is pointless.
Quoted 7 lines
Quoted 1 line
Signed-off-by Julien Grall <[email protected]>Reviewed-by Jan Beulich <[email protected]>Albeit in fact the better change might be to simply use
max(size, align)in the initializer of order - no idea why I didn't do it that way.
I can send a new version of this page to use max.
Quoted 2 lines
Out of curiosity: I never expected this code path to be actually taken - what is it that you need this to work correctly?
I was looking to the code to decide if the best solution is to use xmalloc or alloc_xenheap_pages directly.
Signature · 1 line
Julien Grall