page_address_init 函数

[start_kernel() --> page_address_init()]

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

 // mm\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 (= 0; i < ARRAY_SIZE(page_address_maps); i++)
        list_add(&page_address_maps[i].list, &page_address_pool);
    for (= 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.

 // mm\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.

 // mm\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. 

 // mm\highmem.c:


/*
 * 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.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值