boot_mem分配器

Posted 天地有大美而不言

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了boot_mem分配器相关的知识,希望对你有一定的参考价值。

 

#define alloc_bootmem_low_pages(x) \
    __alloc_bootmem_low(x, PAGE_SIZE, 0)
    

 

void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
                  unsigned long goal)
{
    return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT);
}

 

static void * __init ___alloc_bootmem(unsigned long size, unsigned long align,
                    unsigned long goal, unsigned long limit)
{
    void *mem = ___alloc_bootmem_nopanic(size, align, goal, limit);

    if (mem)
        return mem;
    /*
     * Whoops, we cannot satisfy the allocation request.
     */
    printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
    panic("Out of memory");
    return NULL;
}

 

static void * __init ___alloc_bootmem_nopanic(unsigned long size,
                    unsigned long align,
                    unsigned long goal,
                    unsigned long limit)
{
    bootmem_data_t *bdata;
    void *region;

restart:
    region = alloc_arch_preferred_bootmem(NULL, size, align, goal, limit);
    if (region)
        return region;

    list_for_each_entry(bdata, &bdata_list, list) {
        if (goal && bdata->node_low_pfn <= PFN_DOWN(goal))
            continue;
        if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
            break;

        region = alloc_bootmem_core(bdata, size, align, goal, limit);
        if (region)
            return region;
    }

    if (goal) {
        goal = 0;
        goto restart;
    }

    return NULL;
}

 

以上是关于boot_mem分配器的主要内容,如果未能解决你的问题,请参考以下文章

如何从片段适配器启动活动

片段内带有基本适配器的列表视图

片段中ListView的android自定义适配器

片段中gridview的Android文本和图像适配器

将值从回收器适配器传递到android中的片段

如何使用 Android 片段?