Re: gaps in process's virtual address space(/proc/pid/maps)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi...



As I see in my system, around 4 GB of virtual address space is mapped
to a process. Theoretically, CMIIW, I should be able to use 4GB of
virtual address space.

Not really. Assuming your kernel use 3:1 VM split, your address space is actually 3GB... well not exactly 3GB but you can say so for simplicity. 1 GB is for kernel space.


From the output from /proc/30563/maps below, there exists a
significant gap or a hole from vma's end address 00978000 to another
vma's start address 08048000. Because of these gaps we'll not be able
utilize complete address space allocated to a process.
***************************************************************************
[bash: /usr2/vskrishn]$ ./test &
[1] 30563

==========================================================================
[bash: /usr2/vskrishn]$
[bash: /usr2/vskrishn]$ cat /proc/30563/maps
00835000-0084a000 r-xp 00000000 08:11 385942     /lib/ld-2.3.4.so
0084a000-0084b000 r--p 00015000 08:11 385942     /lib/ld-2.3.4.so
0084b000-0084c000 rw-p 00016000 08:11 385942     /lib/ld-2.3.4.so
0084e000-00972000 r-xp 00000000 08:11 386926     /lib/tls/libc-2.3.4.so
00972000-00973000 r--p 00124000 08:11 386926     /lib/tls/libc-2.3.4.so
00973000-00976000 rw-p 00125000 08:11 386926     /lib/tls/libc-2.3.4.so
00976000-00978000 rw-p 00976000 00:00 0
08048000-08049000 r-xp 00000000 00:1e 2191602    /usr2/vskrishn/test
08049000-0804a000 rw-p 00000000 00:1e 2191602    /usr2/vskrishn/test
b7ff2000-b7ff3000 rw-p b7ff2000 00:00 0
bff69000-c0000000 rw-p bff69000 00:00 0
ffffe000-fffff000 ---p 00000000 00:00 0

It's normal. In non PIE (Position Independent Executable) kind of ELF, binary is loaded in 0x08048000. For PIE ELF binary, it could be anywhere assuming your kernel and your loader treat PIE attribute correctly too.

Is there any way to optimize/reduce those gaps?
Yes, compile a PIE binary and execute it. Or, create custom ld script and define another starting address. However, I am not sure how and whether it will work correctly. Google for ELF documents, especially ones written by Ulrich Drepper.

And one more thing, due to process address space randomization, your libc and other file mapped VMA could have variable gap between them. It could be short, or long...depending on kernel decision.

Hope it enlightens you.

regards,

Mulyadi


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux