本文共 1207 字,大约阅读时间需要 4 分钟。
static inline void set_page_order(struct page *page, unsigned int order){ set_page_private(page, order); __SetPageBuddy(page);} static inline void rmv_page_order(struct page *page){ __ClearPageBuddy(page); set_page_private(page, 0);}
在页设置order情况下,也同时设置buddy标识。
页的order存放在private中。
PageBuddy检查是否空闲即mapcount是否为PAGE_BUDDY_MAPCOUNT_VALUE
__SetPageBuddy设置mapcount为PAGE_BUDDY_MAPCOUNT_VALUE
__ClearPageBuddy清除mapcount的PAGE_BUDDY_MAPCOUNT_VALUE 值为-1
#define PAGE_MAPCOUNT_OPS(uname, lname) \static __always_inline int Page##uname(struct page *page) \{ \ return atomic_read(&page->_mapcount) == \ PAGE_##lname##_MAPCOUNT_VALUE; \} \static __always_inline void __SetPage##uname(struct page *page) \{ \ VM_BUG_ON_PAGE(atomic_read(&page->_mapcount) != -1, page); \ atomic_set(&page->_mapcount, PAGE_##lname##_MAPCOUNT_VALUE); \} \static __always_inline void __ClearPage##uname(struct page *page) \{ \ VM_BUG_ON_PAGE(!Page##uname(page), page); \ atomic_set(&page->_mapcount, -1); \} /* * PageBuddy() indicate that the page is free and in the buddy system * (see mm/page_alloc.c). */#define PAGE_BUDDY_MAPCOUNT_VALUE (-128)PAGE_MAPCOUNT_OPS(Buddy, BUDDY)
转载地址:http://szhti.baihongyu.com/