Chinaunix首页 | 论坛 | 博客
  • 博客访问: 437465
  • 博文数量: 123
  • 博客积分: 2686
  • 博客等级: 少校
  • 技术积分: 1349
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-23 22:11
文章分类
文章存档

2012年(3)

2011年(10)

2010年(100)

2009年(10)

我的朋友

分类: LINUX

2010-10-25 11:39:42

KERNEL VERSION:

STEP 1:

How is the zone be initiated?

start_kernel() > setup_arch() > paging init() > zone_sizes_init() > free_area_init_nodes() > free_area_init_node() > free_area_init_core() > init_currently_empty_zone() > zone_init_free_lists()


static void __meminit zone_init_free_lists(struct zone *zone)
{
    int order, t;
    for_each_migratetype_order(order, t) {
        INIT_LIST_HEAD(&zone->free_area[order].free_list[t]);
        zone->free_area[order].nr_free = 0;
    }
}



__meminit int init_currently_empty_zone(struct zone *zone,
                    unsigned long zone_start_pfn,
                    unsigned long size,
                    enum memmap_context context)
{
    struct pglist_data *pgdat = zone->zone_pgdat;
    int ret;
    ret = zone_wait_table_init(zone, size);
    if (ret)
        return ret;
    pgdat->nr_zones = zone_idx(zone) + 1;

    zone->zone_start_pfn = zone_start_pfn;

    mminit_dprintk(MMINIT_TRACE, "memmap_init",
            "Initialising map node %d zone %lu pfns %lu -> %lu\n",
            pgdat->node_id,
            (unsigned long)zone_idx(zone),
            zone_start_pfn, (zone_start_pfn + size));

    zone_init_free_lists(zone);

    return 0;
}



STEP 2:
The kernel performs optimization if only a single page is to be allocated, that is, if the allocation order is 0 because 2^0 = 1. The page is not taken directly from the buddy system but from the per-CPU page cache.

STEP 3:
For buddy system, there are two helper function, which are the core of buddy system. They are:
buffered_rmqueue() and __rmqueue().


STEP 3:
related function, __free_one_page(), expand(), __rmqueue_smallest(), __rmqueue_fallback(), free_pages(), zone_init_free_lists().
阅读(1379) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-10-26 19:00:29

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com