Chinaunix首页 | 论坛 | 博客
  • 博客访问: 647368
  • 博文数量: 139
  • 博客积分: 2655
  • 博客等级: 少校
  • 技术积分: 1723
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-02 16:03
文章分类

全部博文(139)

文章存档

2013年(2)

2011年(17)

2010年(14)

2009年(86)

2008年(20)

分类:

2009-09-06 14:42:34

今天在网上看到一篇谈2.4和2.6内核堆栈的比较的文章:
"在2.6的内核上允许内核栈的大小在4K和8K之间选择,于是,根据内核
的配置,在thread_info.h中,加入了下面的一段代码
#ifdef CONFIG_4KSTACKS
#define THREAD_SIZE          (4096)
#else
#define THREAD_SIZE          (8192)
"
偶在2.6.30.1的内核中thread_info.h中没找到上面这样的定义,而在page_32_types.h中找到相关的东西,Mark一下


//From:linux-2.6.30.1/arch/x86/include/asm/page_32_types.h
#ifdef CONFIG_4KSTACKS
#define THREAD_ORDER    0
#else
#define THREAD_ORDER    1
#endif
#define THREAD_SIZE     (PAGE_SIZE << THREAD_ORDER)
(page_64_types.h是这样定义的
#define THREAD_ORDER    1
#define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
#define CURRENT_MASK (~(THREAD_SIZE - 1))
)
/*
* Kernel image size is limited to 512 MB (see in arch/x86/kernel/head_32.S)
*/
#define KERNEL_IMAGE_SIZE       (512 * 1024 * 1024)
在page_types.h中继续找:
 //From: linux-2.6.30.1/arch/x86/include/asm/page_types.h
/* PAGE_SHIFT determines the page size */
  #define PAGE_SHIFT      12
  #define PAGE_SIZE       (_AC(1,UL) << PAGE_SHIFT)
  #define PAGE_MASK       (~(PAGE_SIZE-1))
//由于不能总是单方面注解UL等表示符,因此在const.h中定义_AC几个宏,用在汇编和C中
#ifdef __ASSEMBLY__
#define _AC(X,Y)        X
#define _AT(T,X)        X
#else
#define __AC(X,Y)       (X##Y)
#define _AC(X,Y)        __AC(X,Y)
#define _AT(T,X)        ((T)(X))
#endif
----------------------------------------------------------------------------------
关于PAE,虽然能看懂以下写法,但不知具体想表达啥意思?尤其是44=32+12
#define __PHYSICAL_MASK         ((phys_addr_t)(1ULL << __PHYSICAL_MASK_SHIFT) - 1)
#define __VIRTUAL_MASK        ((1UL << __VIRTUAL_MASK_SHIFT) - 1)
#ifdef CONFIG_X86_PAE
/* 44=32+12, the limit we can fit into an unsigned long pfn */
#define __PHYSICAL_MASK_SHIFT   44
#define __VIRTUAL_MASK_SHIFT    32
#else  /* !CONFIG_X86_PAE */
#define __PHYSICAL_MASK_SHIFT   32
#define __VIRTUAL_MASK_SHIFT    32
#endif  /* CONFIG_X86_PAE */
 
google到一篇
"When a 64-bit x86 processor runs in 32-bit PAE mode, a pte can
potentially have the same number of physical address bits as the
64-bit host ("Enhanced Legacy PAE Paging"). This means, in theory,
we could have up to 52 bits of physical address in a pte.

The 32-bit kernel uses a 32-bit unsigned long to represent a pfn.
This means that it can only represent physical addresses up to 32+12=44
bits wide. Rather than widening pfns everywhere, just set 2^44 as the
Linux x86_32-PAE architectural limit for physical address size.
"
在上说页目录和页表表项由32位变成64位之后,最多有52可用于物理内存寻址,现在只用了其中的36位(也即现在x86 PAE最大支持的64GB内存),不知这个和上面有啥关系没?

Reference:
http://hi.baidu.com/zqfazqq/blog/item/12db349980343b0b6f068c5d.html
http://www.lupaworld.com/home/space-359096-do-blog-id-130754.html


阅读(1277) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~