This page lists the different ways to get the kernel page size used in the
device. To connect to the device, you can use adb
.
$ adb shell
Use the getconf
command
Use the getconf
command to get the page size, shown as follows:
$ getconf PAGE_SIZE
4096
Use the /proc/<pid>/smaps
pseudo file
The KernelPageSize
field in the pseudo file /proc/<pid>/smaps
shows the page
size, shown as follows:
$ cat /proc/1/smaps | grep KernelPageSize
KernelPageSize: 4 kB
Use the LD_SHOW_AUXV=1
linker flag
Use the LD_SHOW_AUXV
flag to print the auxiliary vector of the program
that is about to be executed. The AT_PAGESZ
field contains the page size,
shown as follows:
$ LD_SHOW_AUXV=1 ls
AT_SYSINFO_EHDR 0x7250460000
AT_MINSIGSTKSZ 4720
AT_HWCAP 0b11111111111111111111111111111111
AT_PAGESZ 4096
AT_CLKTCK 100
AT_PHDR 0x5fda1e0040
AT_PHENT 56
AT_PHNUM 12
AT_BASE 0x72502f8000
AT_FLAGS 0
AT_ENTRY 0x5fda210000
AT_UID 0
AT_EUID 0
AT_GID 0
AT_EGID 0
AT_SECURE 0
AT_RANDOM 0x7fc59d66f8
AT_HWCAP2 0b100011001111111111
AT_EXECFN "/system/bin/ls"
AT_PLATFORM "aarch64"
data dev. init vendor
Use the /proc/config.gz
pseudo file
Check the kernel configuration for the page size in the pseudo file
/proc/config.gz
. The possible configurations for the page size are:
CONFIG_ARM64_4K_PAGES=y
: the kernel supports 4096 page sizes.CONFIG_ARM64_16K_PAGES=y
: the kernel supports 16384 page sizes.CONFIG_ARM64_64K_PAGES=y
: the kernel supports 65536 page sizes.
$ zcat /proc/config.gz | grep "CONFIG_ARM64_[164K]*_PAGES=y"
CONFIG_ARM64_16K_PAGES=y
Use the Auxiliary Vector
When a program is executed, the kernel allocates and initializes the auxiliary
vector with information, such as the page size, that is used by the dynamic
linker. The auxiliary vector is located in the pseudo file
/proc/<pid>/auxv
and can be printed with the command:
$ od -t d8 /proc/<pid>/auxv
Where:
- od dumps files in hexadecimal, decimal or other formats.
- -t refers to the type of format.
- d8 indicates that the format is decimal and the integer size is 8 bytes.
- <pid> refers to the process ID.
After running the command, the page size is at the offset 0x68
, shown as
follows:
$ od -t d8 /proc/1/auxv
0000000 33 548087410688
0000020 51 4720
0000040 16 4294967295
0000060 6 4096
0000100 17 100
0000120 3 367056650304
0000140 4 56
0000160 5 12
0000200 7 548085936128
0000220 8 0
0000240 9 367057567744
0000260 11 0
0000300 12 0
0000320 13 0
0000340 14 0
0000360 23 1
0000400 25 549659104168
0000420 26 144383
0000440 31 549659107303
0000460 15 549659104184
0000500 0 0
0000520