What is the "shared:" column in the output of pmap -d command?
Environment
- Red Hat Enterprise Linux
Issue
- What is the shared: column in the output of pmap -d command?
- shared: column in the output of pmap -d command is lesser than the total shared library size.
Resolution
Shared in the pmap -d output is calculated by checking the kernel flags of the memory mappings of the process. This is the combined size of data pages which are shared between processes and not the size of total shared libraries. For example, following segments would be counted under shared as they does have s flag set.
00007fe9cab19000 12 rw-s- 0000000000000000 000:00009 [ anon ]
00007fe9cab1c000 12 rw-s- 0000000000000000 000:00009 [ anon ]
00007fe9cab1f000 12 rw-s- 0000000000000000 000:00009 [ anon ]
00007fe9cab22000 12 rw-s- 0000000000000000 000:00009 [ anon ]
Diagnostic Steps
diff = end-start;
if(flags[3]=='s') total_shared += diff;
if(flags[3]=='p'){
flags[3] = '-';
if(flags[1]=='w') total_private_writeable += diff;
else total_private_readonly += diff;
}
[..]
if(d_option){
const char *cp = mapping_name(p, start, diff, mapbuf, 0, dev_major, dev_minor, inode);
printf(
(sizeof(KLONG)==8)
? "%016"KLF"x %7lu %s %016Lx %03x:%05x %s\n"
: "%08lx %7lu %s %016Lx %03x:%05x %s\n",
start,
(unsigned long)(diff>>10),
flags,
file_offset,
dev_major, dev_minor,
cp
);
}
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
