Chinaunix首页 | 论坛 | 博客
  • 博客访问: 327082
  • 博文数量: 100
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 665
  • 用 户 组: 普通用户
  • 注册时间: 2015-02-02 12:43
文章分类

全部博文(100)

文章存档

2015年(100)

我的朋友

分类: LINUX

2015-05-11 20:33:28

[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.
阅读(1253) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~