文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>关于compound pages的疑问!

关于compound pages的疑问!

时间:2007-05-24  来源:fineamy

关于compound pages的疑问!
 
static void destroy_compound_page(struct page *page, unsigned long order)
{
        int i;
        int nr_pages = 1 << order;

        if (!PageCompound(page))
                return;

        if (page[1].index != order)
                bad_page(__FUNCTION__, page);

        for (i = 0; i < nr_pages; i++) {
                struct page *p = page + i;

                if (!PageCompound(p))
                        bad_page(__FUNCTION__, page);
                if (page_private(p) != (unsigned long)page)
                        bad_page(__FUNCTION__, page);
                ClearPageCompound(p);
        }
}
 
static inline int page_count(struct page *page)
{
        if (PageCompound(page))
                page = (struct page *)page_private(page);
        return atomic_read(&page->_count) + 1;
}

本来上面两个函数中一直有不明白的地方,例如
为什么销毁前做合法性检查时要检查

QUOTE:
page[1].index != order

还有

QUOTE:
if (page_private(p) != (unsigned long)page)

另外
取page_count时为何有

QUOTE:
if (PageCompound(page))
                page =(struct page *)page_private(page);

后来看到有个注释就全明白了

QUOTE:
/*
* Higher-order pages are called "compound pages".  They are structured thusly:
*
* The first PAGE_SIZE page is called the "head page".
*
* The remaining PAGE_SIZE pages are called "tail pages".
*
* All pages have PG_compound set.  All pages have their ->private pointing at
* the head page (even the head page has this).
*
* The first tail page's ->mapping, if non-zero, holds the address of the
* compound page's put_page() function.
*
* The order of the allocation is stored in the first tail page's ->index
* This is only for debug at present.  This usage means that zero-order pages
* may not be compound.
*/

现在我要问的问题就是

"compound pages"倒底在什么地方用,是出于什么目的。麻烦解释一下!
回复 #1 fineamy 的帖子

puppylove 发表于 2007-5-23 14:08 
一个使用compound pages的实例是huge tlb.
      一般而言,每种处理器都支持几种大小的内存页面映射,例如x86/x86-64支持4k/2m/4m大小的页面映射,而ia64能支持更多种大小的映射,最大可到4g。 使用大的页面进行映射的好处是:相同数目的tlb entry能够覆盖更大的地址空间范围,从而能够提高tlb的使用效率。 在Linux内核中,当使用大的页面进行映射时,需要把几个连续的normal page组合成一个大的页面填写到映射表中去,这个时候就会用到这个compound pages了。
 
Solaris12  发表于 2007-5-23 15:41 
TLB miss对系统的性能有很大影响,Solaris的MPSS(mutil page size support)就可以把一些内核段或者进程内的段影射成大页面。对应用程序来说,可以直接用命令动态修改影射的页尺寸。
排行榜 更多 +
rento大富翁手游

rento大富翁手游

休闲益智 下载
冲撞赛车3无限金币版

冲撞赛车3无限金币版

赛车竞速 下载
电动火车模拟器内置菜单

电动火车模拟器内置菜单

赛车竞速 下载