函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:mm\page_ext.c Create Date:2022-07-27 18:07:59
首页 Copyright©Brick

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
static int __init alloc_node_page_ext(int nid)
{
    struct page_ext *base;
    unsigned long table_size;
    unsigned long nr_pages;
 
    nr_pages = NODE_DATA(nid)->node_spanned_pages;
    if (!nr_pages)
        return 0;
 
    /*
     * Need extra space if node range is not aligned with
     * MAX_ORDER_NR_PAGES. When page allocator's buddy algorithm
     * checks buddy's status, range could be out of exact node range.
     */
    if (!IS_ALIGNED(node_start_pfn(nid), MAX_ORDER_NR_PAGES) ||
        !IS_ALIGNED(node_end_pfn(nid), MAX_ORDER_NR_PAGES))
        nr_pages += MAX_ORDER_NR_PAGES;
 
    table_size = page_ext_size * nr_pages;
 
    base = memblock_alloc_try_nid(
            table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS),
            MEMBLOCK_ALLOC_ACCESSIBLE, nid);
    if (!base)
        return -ENOMEM;
    NODE_DATA(nid)->node_page_ext = base;
    total_usage += table_size;
    return 0;
}