diff mbox

[Xen-devel,v2] xen/malloc: handle correctly page allocation when align > size

Message ID 1394455306-13866-1-git-send-email-julien.grall@linaro.org
State Accepted, archived
Headers show

Commit Message

Julien Grall March 10, 2014, 12:41 p.m. UTC
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".

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---
    Changes in v2:
        - Use max
---
 xen/common/xmalloc_tlsf.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Keir Fraser March 10, 2014, 1:28 p.m. UTC | #1
Julien Grall wrote:
> 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".
>
> Signed-off-by: Julien Grall<julien.grall@linaro.org>

Acked-by: Keir Fraser <keir@xen.org>
diff mbox

Patch

diff --git a/xen/common/xmalloc_tlsf.c b/xen/common/xmalloc_tlsf.c
index d3bdfa7..a5769c9 100644
--- a/xen/common/xmalloc_tlsf.c
+++ b/xen/common/xmalloc_tlsf.c
@@ -527,11 +527,10 @@  static void xmalloc_pool_put(void *p)
 
 static void *xmalloc_whole_pages(unsigned long size, unsigned long align)
 {
-    unsigned int i, order = get_order_from_bytes(size);
+    unsigned int i, order;
     void *res, *p;
 
-    if ( align > size )
-        get_order_from_bytes(align);
+    order = get_order_from_bytes(max(align, size));
 
     res = alloc_xenheap_pages(order, 0);
     if ( res == NULL )