@@ -155,7 +155,7 @@ static void *page_memalign(size_t alignment, size_t size)
if (!size)
return NULL;
- order = is_power_of_2(n) ? fls(n) : fls(n) + 1;
+ order = get_order(n);
return alloc_pages(order);
}
@@ -175,3 +175,8 @@ void page_alloc_ops_enable(void)
{
alloc_ops = &page_alloc_ops;
}
+
+int get_order(size_t size)
+{
+ return is_power_of_2(size) ? fls(size) : fls(size) + 1;
+}
@@ -15,5 +15,6 @@ void *alloc_pages(unsigned long order);
void free_page(void *page);
void free_pages(void *mem, unsigned long size);
void free_pages_by_order(void *mem, unsigned long order);
+int get_order(size_t size);
#endif
Compute the power of 2 order of a size. Use it in page_memalign. Other users are looming. Signed-off-by: Eric Auger <eric.auger@redhat.com> --- lib/alloc_page.c | 7 ++++++- lib/alloc_page.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)