[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 1/2] lib/ukallocbbuddy: Fix definition and assertions of memr.nr_pages



Currently, nr_pages is set to the range size instead of the number of pages in
the memory region. Fixed by shifting by __PAGE_SIZE. Assertions are fixed
accordingly.

Signed-off-by: Bruno Alvisio <bruno.alvisio@xxxxxxxxx>
---
 lib/ukallocbbuddy/bbuddy.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/ukallocbbuddy/bbuddy.c b/lib/ukallocbbuddy/bbuddy.c
index b830995..13cb0c8 100644
--- a/lib/ukallocbbuddy/bbuddy.c
+++ b/lib/ukallocbbuddy/bbuddy.c
@@ -107,7 +107,7 @@ static inline struct uk_bbpalloc_memr *map_get_memr(struct 
uk_bbpalloc *b,
         */
        for (memr = b->memr_head; memr != NULL; memr = memr->next) {
                if ((page_num >= memr->first_page)
-                   && (page_num < (memr->first_page + memr->nr_pages)))
+                   && (page_num < (memr->first_page + memr->nr_pages << 
__PAGE_SIZE)))
                        return memr;
        }
 
@@ -145,7 +145,7 @@ static void map_alloc(struct uk_bbpalloc *b, uintptr_t 
first_page,
        memr = map_get_memr(b, first_page);
        UK_ASSERT(memr != NULL);
        UK_ASSERT((first_page + nr_pages)
-                 <= (memr->first_page + memr->nr_pages));
+                 <= (memr->first_page + memr->nr_pages << __PAGE_SIZE));
 
        first_page -= memr->first_page;
        curr_idx = first_page / PAGES_PER_MAPWORD;
@@ -362,7 +362,8 @@ static int bbuddy_addmem(struct uk_alloc *a, void *base, 
size_t len)
         * Initialize region's bitmap
         */
        memr->first_page = min;
-       memr->nr_pages = max - min;
+       memr->nr_pages = (max - min) >> __PAGE_SIZE;
+
        /* add to list */
        memr->next = b->memr_head;
        b->memr_head = memr;
-- 
2.3.2 (Apple Git-55)


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.