About bootmem allocation/freeing flow
yoma sophian
sophian.yoma at gmail.com
Tue May 5 13:50:22 EDT 2015
2015-04-18 15:28 GMT+08:00 yoma sophian <sophian.yoma at gmail.com>:
> hi all:
> I have several questions about free_all_bootmem_core:
>
> 1.
> In __free_pages_bootmem, we set set_page_count(p, 0) while looping nr_pages,
> why we need to set_page_refcounted(page) before calling __free_pages?
below is excerpted from mm/page_alloc.c and mm/internal.h
the reason why we use set_page_refcounted(page) is because
set_page_refcounted(page) will calling VM_BUG_ON
to checking page property?
static inline void set_page_refcounted(struct page *page)
{
VM_BUG_ON(PageTail(page));
VM_BUG_ON(atomic_read(&page->_
count));
set_page_count(page, 1);
}
void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
{
unsigned int nr_pages = 1 << order;
unsigned int loop;
prefetchw(page);
for (loop = 0; loop < nr_pages; loop++) {
struct page *p = &page[loop];
if (loop + 1 < nr_pages)
prefetchw(p + 1);
__ClearPageReserved(p);
set_page_count(p, 0);
}
page_zone(page)->managed_pages += 1 << order;
set_page_refcounted(page);
__free_pages(page, order);
}
thanks for your help,
More information about the Kernelnewbies
mailing list