linux内核- PAGE_ALIGN()
PAGE_ALIGN()
·
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) (include/linux/mm.h)
|->#define ALIGN(x,a)__ALIGN_MASK(x,(typeof(x))(a)-1)(include/linux/kernel.h)
|->#define __ALIGN_MASK(x,mask)(((x)+(mask))&~(mask))
PAGE_ALIGN宏表示将物理地址addr修整为页边界地址(页的上边界)
page.h
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
PAGE_ALIGN(addr) ==> ALIGN(addr, 1<<12)
==>__ALIGN_MASK(addr,(typeof(addr))(1<<12)-1)
==>(((addr)+((1<<12)-1))&~((1<<12)-1))
==>(((addr)+(0xffff)&~(0xffff)
==>(((addr)+(0xffff)&0xffff0000)
也就是以PAGE_SIZE页对其,向上取整
更多推荐
已为社区贡献1条内容
所有评论(0)