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

2012年(3)

2011年(10)

2010年(100)

2009年(10)

我的朋友

分类: LINUX

2010-10-15 10:57:20

[start_kernel() --> page_address_init()]

page_address_init() do nothing when all RAM can be mapped directly, otherwise, do following operations:

 highmem.c:

static struct page_address_map page_address_maps[LAST_PKMAP];

void __init page_address_init(void)
{
    int i;

    INIT_LIST_HEAD(&page_address_pool);
    for (i = 0; i < ARRAY_SIZE(page_address_maps); i++)
        list_add(&page_address_maps[i].list, &page_address_pool);
    for (i = 0; i < ARRAY_SIZE(page_address_htable); i++) {
        INIT_LIST_HEAD(&page_address_htable[i].lh);
        spin_lock_init(&page_address_htable[i].lock);
    }
    spin_lock_init(&pool_lock);
}


page_address_pool is a global variable defined in highmem.c

/*
 * page_address_map freelist, allocated from page_address_maps.
 */

static struct list_head page_address_pool;    /* freelist */
static spinlock_t pool_lock;            /* protects page_address_pool */


page_address_htable[] is also a global variable defined in highmem.c

/*
 * Hash table bucket
 */

static struct page_address_slot {
    struct list_head lh;            /* List of page_address_maps */
    spinlock_t lock;            /* Protect this bucket's list */
} ____cacheline_aligned_in_smp page_address_htable[1<<PA_HASH_ORDER];


There is a very important data structure: struct page_address_map, this structure's main purpose is to maintain the association of struct page and its virtual memory. However, this will be wasteful if the page has a linear association with its virtual memory. This becomes necessary when the addressing is hashed.


/*
 * Describes one page->virtual association
 */

struct page_address_map {
    struct page *page;
    void *virtual;
    struct list_head list;
};



Summary:
1. The main purpose of page_address_init() is to initiate global variable page_address_pool, which is used to support high memory that cannot be directly mapped.

page_address_pool is a list header pointing to lots of struct page_address_map connected each other using list.

2. page_address_htable[] is used to hold the list of entry that hash to the same bucket. page_address_init() initiates it.
阅读(3093) | 评论(1) | 转发(1) |
0

上一篇:lock_kernel()

下一篇:start_kernel()之setup_arch()

给主人留下些什么吧!~~

chinaunix网友2010-10-15 16:53:26

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