LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-07-2011, 09:07 PM   #1
grob115
Member
 
Registered: Oct 2005
Posts: 526

Rep: Reputation: 32
pmap


Given the following output, can someone tell me:
1) Hex Decimal
080b0fff = 134942719
08048000 = 134512640
Diff = 430079

Why does pmap indicate the size as 420k?

2) What's the purpose of the Offset column when the whole address range is shown?

3) The "rwxpc" column indicates that this segment is readable, executable, private, and the + sign indicates that COW is required.

If there has been 3 forks (ie 1 parent and 3 child processes), and only of these three child processes has attempted to write to the segment, is this enough to cause this + sign to change to a - sign? Or all 3 child processes needs to have attempted to write to the segment, and all 3 has a COW, before the - sign will appear?

4) What does the I/W/A column indicate?

Code:
$ pmap -a
           Start    End         Size  Offset   rwxpc  RWX  I/W/A ...
           08048000-080b0fff     420k 00000000 r-xp+ (rwx) 1/0/0 ...
 
Old 05-08-2011, 06:23 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by grob115 View Post
Why does pmap indicate the size as 420k?
420k is really 420KiB, meaning 420 x 1024 bytes (ie 430080 bytes). We've been happily misusing SI prefixes for some time now

Quote:
What's the purpose of the Offset column when the whole address range is shown?
It's just the offset into the paging object.

Quote:
If there has been 3 forks (ie 1 parent and 3 child processes), and only one of these three child processes has attempted to write to the segment, is this enough to cause this + sign to change to a - sign?
If the region is shared by multiple processes, then the copied flag would have to remain 'uncopied' while there was more than one process still capable of writing to it (ie, the shared region cannot change to '-' until each process has its own copy).

Quote:
What does the I/W/A column indicate?
The 'I' is the inheritance type of the region (ie, whether child processes share, copy or do not have the region); the 'W' is the wired count of the region (ie, whether the region is wired in and cannot be paged, as is typical of kernel memory); the 'A' is the advice parameter (ie, hints regarding the page priority of the region).

Last edited by neonsignal; 05-08-2011 at 06:24 AM.
 
Old 05-22-2011, 12:37 PM   #3
grob115
Member
 
Registered: Oct 2005
Posts: 526

Original Poster
Rep: Reputation: 32
neonsignal, thanks for the explanations. Regarding the following, can you give me some examples of what is a "wired count"? I'm not following what you meant by "whether the region is wired in". As for the number "1" under the "I" column, I guess this is because the memory is shown as a COW type with the "+" sign under the "rwxpc" column?
Quote:
The 'I' is the inheritance type of the region (ie, whether child processes share, copy or do not have the region); the 'W' is the wired count of the region (ie, whether the region is wired in and cannot be paged, as is typical of kernel memory); the 'A' is the advice parameter (ie, hints regarding the page priority of the region).
BTW, I've noticed differences between the pmap and jmap output. Can you tell me how I should account for the differences?
 
Old 05-23-2011, 04:24 AM   #4
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by grob115 View Post
can you give me some examples of what is a "wired count"?
These are pages that cannot be swapped out, typically memory that is being used by the kernel - stacks, memory pools, page tables, and the like).

Quote:
As for the number "1" under the "I" column, I guess this is because the memory is shown as a COW type with the "+" sign under the "rwxpc" column?
No, it means that this page is of type VM_INHERIT_COPY, meaning that child processes will get a copy of the page (which is the default). The COW is showing how any copies are to be handled (functionally).

Quote:
BTW, I've noticed differences between the pmap and jmap output. Can you tell me how I should account for the differences?
I haven't used jmap, I'll leave that question for someone else! You might want to give an example.
 
Old 05-23-2011, 10:57 AM   #5
grob115
Member
 
Registered: Oct 2005
Posts: 526

Original Poster
Rep: Reputation: 32
Quote:
No, it means that this page is of type VM_INHERIT_COPY, meaning that child processes will get a copy of the page (which is the default). The COW is showing how any copies are to be handled (functionally).
Thanks. Would I be correct if I say, however, that if there is no COW, as indicated with the "+" sign, then there won't be a "1" under the "I" column also? Basically the way I get what you are saying is that the "1" under the "I" column means the child will get a copy, and the "+" means the child will get the copy when it attempts to write to that area. Right?
 
Old 05-23-2011, 06:09 PM   #6
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by grob115 View Post
Basically the way I get what you are saying is that the "1" under the "I" column means the child will get a copy, and the "+" means the child will get the copy when it attempts to write to that area.
Yes. I was just being pedantic in pointing out that in theory the child could still get a copy even if the system didn't have a copy-on-write mechanism (instead just a straightforward copy). And you could have a copy-on-write page that is memory shared between unrelated processes, even if it wasn't a page that was inheritable by child processes. In other words, that the two concepts are independent. But in practice, yes, a page that is going to be inherited by the child will be copied when the child (or parent) writes to it.

Last edited by neonsignal; 05-23-2011 at 06:11 PM.
 
Old 05-24-2011, 08:41 AM   #7
grob115
Member
 
Registered: Oct 2005
Posts: 526

Original Poster
Rep: Reputation: 32
For the jmap vs pmap output example, here's what I see (truncated a lot of other stuff).
Essentially the key points I notice are:
1) jmap lists the code section and pmap lists both code and data sections.
2) Size in jmap is different than size in pmap.
For example:
46k vs 40k for java
1225k vs 104k for ld-2.4.so
1261k vs 104k for liba.so
47343k vs 31652k for liba.so
3) pmap lists things like [heap], [anon]. What are these?

Can I ask, based on looking at pmap, how can I tell what is the stack and heap boundary addresses?

jmap
Code:
0x0000000008048000      46K     /usr/test/jdk1.6.0_16/bin/java
0x0000000055555000      125K    /lib/ld-2.4.so
.....
0x00000000e36c9000      1261K   /usr/test/lib/liba.so
.....
0x00000000e36f3000      43K     /lib/libgcc_s.so.1
0x00000000e3800000      47343K  /usr/test/lib/libb.so
pmap
Quote:
START SIZE RSS DIRTY PERM MAPPING
08048000 40K 40K 0K r-xp /usr/test/jdk1.6.0_16/bin/java
08052000 4K 4K 4K rwxp /usr/test/jdk1.6.0_16/bin/java
08053000 22748K 22624K 22624K rwxp [heap]
55555000 104K 96K 0K r-xp /lib/ld-2.4.so
5556f000 8K 8K 8K rwxp /lib/ld-2.4.so
55571000 4K 4K 4K rwxp [anon]
55572000 4K 4K 4K r-xp [anon]
55573000 4K 4K 4K rwxp [anon]
.....
e36c9000 104K 104K 4K r-xp /usr/test/lib/liba.so
e36e3000 20K 20K 8K rwxp /usr/test/lib/liba.so
.....
e3700000 972K 972K 972K rwxp [anon]
e37f3000 52K 0K 0K ---p [anon]
e3800000 31652K 19348K 0K r-xp /usr/test/lib/libb.so
e56e9000 4696K 1308K 1288K rwxp /usr/test/lib/libb.so
e5b7f000 160K 160K 160K rwxp [anon]
.....
Total: 2439472K 1372980K 1342128K

2388708K writable-private, 45688K readonly-private, and 5076K shared
 
Old 05-24-2011, 09:28 AM   #8
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by grob115 View Post
jmap lists the code section and pmap lists both code and data sections. Size in jmap is different than size in pmap.
It looks more like jmap is including code and the other segments into a single total. If you add the pmap segments, you get roughly the same totals.

For example,
Code:
   for java      -> 46k vs 40k+4k
   for ld-2.4.so -> 125k vs 104k+8k+4k+4k+4k
   for liba.so   -> 1261k vs 104k+20k+...+972k+52k
and so on

Quote:
pmap lists things like [heap], [anon]. What are these?
These are just different segments used by the executable. The code segment is obvious (because it is not writable). But there can also be initialized data segments, uninitialized data segments, dynamically allocated data space (heap), and stack space, etc (the exact set of segments used can vary).

Quote:
Can I ask, based on looking at pmap, how can I tell what is the stack and heap boundary addresses?
Once the heap and stack segments are located, can't you just add the size to the start address to get the end address? Is that what you mean?
 
Old 05-26-2011, 11:12 AM   #9
grob115
Member
 
Registered: Oct 2005
Posts: 526

Original Poster
Rep: Reputation: 32
Thanks. Didn't realize that jmap is adding the code and data segment. As for
Quote:
Once the heap and stack segments are located, can't you just add the size to the start address to get the end address? Is that what you mean?
I suppose so. However, I'm not sure if the stack or heap may be broken up in a non-contiguous memory space. If so, I guess the lowest address for the stack(s) is the top of the stack, and the highest address for the heap(s) is the top of the heap. However, what would the heap be indicated as? Is it [anon]? Anyway to see look at what's on the stack?
 
Old 05-26-2011, 06:37 PM   #10
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by grob115 View Post
I'm not sure if the stack or heap may be broken up in a non-contiguous memory space.
The mapping is only a virtual address space, not a real one. The stack is necessarily contiguous in this virtual address space (in theory, one could implement a non-contiguous stack, but on current systems it would be seen as an unnecessary complication). The heap doesn't have to be contiguous, but typically implementations are (which is why it is allocated at the end of all the low address segments, so that it can dynamically grow).

The pmap can't be relied upon to identify segment types (the contents will vary depending on how the language/code works). Often the heap will be the largest writable segment at the end of the low address segments, and the stack will be the last of the high address segments.

Quote:
If so, I guess the lowest address for the stack(s) is the top of the stack
Yes, the stack is growing from the end address towards the base address.

Quote:
and the highest address for the heap(s) is the top of the heap.
Yes, although a heap can be grown at run time, so that isn't a hard limit.

Quote:
However, what would the heap be indicated as?
Depends on how smart the pmap implementation is. Your example above had the heap identified, but on some systems it may be just another 'anon' segment.

To view the contents of these address spaces, it would be usual to employ a debugger (eg use gdb to dump memory contents). In a Java context, it might be more useful to run a Java debugger, though that might not have quite the same low level functionality?

Last edited by neonsignal; 05-26-2011 at 06:47 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pmap update fraFFfra Linux - Newbie 3 10-08-2010 04:46 AM
analyse core file using pmap and pstack pramod.srk Linux - Software 1 06-11-2010 08:33 AM
pmap -x available on all linux? amol28kulkarni Linux - Newbie 1 01-24-2009 01:44 AM
interpreting output of pmap on Linux kernel 2.4 rhegde Linux - General 0 08-20-2006 01:32 AM
pmap for linux doraemona Linux - General 0 05-11-2002 04:43 AM


All times are GMT -5. The time now is 03:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration