Thursday, September 21, 2006

How to find PAGE SIZE in linux kernel

Sometimes i was finding what is the PAGE SIZE of my linux kernel? . I knew that it could be 4KB,8KB,16KB or 64KB. But the the real question was , how do i find the value? After lot of serching, i came to know the following command from Rik Van Riel (kernelnewbies mailing list)..
[suman@ajit ~]$ getconf PAGE_SIZE
4096
it says that i am using 4KB PAGE SIZE. Now i went to find out where the PAGE SIZE has been wriiten into the source code. I found it /include/asm-i386/page.h in my kernel-source(2.6.17) directory.My system architecture is i386 machine. I could see
#ifndef _I386_PAGE_H
#define _I386_PAGE_H
/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
i see that PAGE_SIZE depends on the value of PAGE_SHIFT. i yet to see if i change the PAGE_SHIFT value,what would be the impact of my kernel? Let see..i will be informing....

Also i came to know that PAGE SIZE varries on architecture to architecure. Here is the code snapshot for ia64 archi.
 #ifndef _ASM_IA64_PAGE_H
#define _ASM_IA64_PAGE_H
* PAGE_SHIFT determines the actual kernel page size. */
#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
# define PAGE_SHIFT 12
#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
# define PAGE_SHIFT 13
#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
# define PAGE_SHIFT 14
#elif defined(CONFIG_IA64_PAGE_SIZE_64KB)
# define PAGE_SHIFT 16
#else
So ia64 machine can use 4KB,8KB,16KB or 64KB depends upon the configuration during compilation.

1 comment:

Unknown said...

Thanks informative....