Use only whole kernel lock

This commit is contained in:
TXuian
2024-03-15 16:21:36 +08:00
parent d987bf0357
commit b939557317
14 changed files with 8 additions and 79 deletions
@@ -75,8 +75,6 @@ static struct KPage* KBuddyPagesAlloc(struct KBuddy* pbuddy, int nPages)
struct KFreeList* list = NULL;
int i = 0, order = 0;
spinlock_lock(&pbuddy->lock);
// find order
for (order = 0; (FREE_LIST_INDEX(order)) < nPages; order++)
;
@@ -99,12 +97,10 @@ static struct KPage* KBuddyPagesAlloc(struct KBuddy* pbuddy, int nPages)
// set the pages' order
_buddy_set_pages_order(page, order);
spinlock_unlock(&pbuddy->lock);
return page;
}
// there is no enough free page to satisfy the nPages
spinlock_unlock(&pbuddy->lock);
return NULL;
}
@@ -116,8 +112,6 @@ static void KBuddyPagesFree(struct KBuddy* pbuddy, struct KPage* page)
uint32_t buddy_idx = 0, new_buddy_idx = 0;
uint32_t page_idx = page - pbuddy->pages;
spinlock_lock(&pbuddy->lock);
for (; order < MAX_BUDDY_ORDER - 1; order++) {
// find and delete buddy to combine
buddy_idx = BUDDY_PAGE_INDEX(page_idx, order);
@@ -141,7 +135,6 @@ static void KBuddyPagesFree(struct KBuddy* pbuddy, struct KPage* page)
doubleListAddOnHead(&page->node, &pbuddy->free_list[order].list_head);
pbuddy->free_list[order].n_free_pages++;
spinlock_unlock(&pbuddy->lock);
return;
}