Page MenuHomeFreeBSD

Report offset relative to the backing object for kinfo_vmentry structures.
ClosedPublic

Authored by jhb on Jan 4 2018, 7:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 6, 2:02 PM
Unknown Object (File)
Sat, Nov 30, 2:47 PM
Unknown Object (File)
Sep 14 2024, 10:56 PM
Unknown Object (File)
Sep 11 2024, 4:43 PM
Unknown Object (File)
Sep 9 2024, 2:05 AM
Unknown Object (File)
Sep 7 2024, 8:31 PM
Unknown Object (File)
Sep 6 2024, 3:33 AM
Unknown Object (File)
Sep 1 2024, 6:29 AM
Subscribers

Details

Summary

For the pathname reported in kinfo_vmentry structures (kve_path), the
sysctl handlers walk the object chain to find the bottom-most VM object.
This permits a COW mapping of a file with dirty pages to report the
pathname of the originally mapped file. Do the same for the object
offset (kve_offset) computing a cumulative offset during the same object
walk so that the reported offset is relative to the reported pathname.

Note that this does not affect procstat -v output (even structured
output) since that output does not include the kve_offset field.

Test Plan
  • Compare 'info proc mappings' from a gdb patch set that adds 'info proc' support and reports project mappings.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Here is some before/after output. The 'before' is actually from stable/11 rather than HEAD. Both are from running /bin/ls to the start of main() via 'start':

Before:

(gdb) info proc mappings 
process 34399
Mapped address spaces:

          Start Addr           End Addr       Size     Offset   Flags   File
            0x400000           0x408000     0x8000        0x0  r-x C--- /bin/ls
            0x607000           0x609000     0x2000        0x0  rw- ---- 
         0x800607000        0x800628000    0x21000        0x0  r-x C--- /libexec/ld-elf.so.1
         0x800628000        0x800630000     0x8000        0x0  rw- ---- 
         0x800631000        0x800652000    0x21000        0x0  rw- ---- 
         0x800827000        0x800828000     0x1000        0x0  rw- C--- /libexec/ld-elf.so.1
         0x800828000        0x800829000     0x1000        0x0  rw- ---- 
         0x800829000        0x800845000    0x1c000        0x0  r-x CN-- /lib/libxo.so.0
         0x800845000        0x800a45000   0x200000    0x1c000  --- CN-- 
         0x800a45000        0x800a46000     0x1000        0x0  rw- C--- /lib/libxo.so.0
         0x800a46000        0x800a57000    0x11000        0x0  r-x CN-- /lib/libutil.so.9
         0x800a57000        0x800c57000   0x200000    0x11000  --- CN-- 
         0x800c57000        0x800c58000     0x1000        0x0  rw- C--- /lib/libutil.so.9
         0x800c58000        0x800c5a000     0x2000        0x0  rw- ---- 
         0x800c5a000        0x800cb3000    0x59000        0x0  r-x CN-- /lib/libncursesw.so.8
         0x800cb3000        0x800eb2000   0x1ff000    0x59000  --- CN-- 
         0x800eb2000        0x800eb8000     0x6000        0x0  rw- C--- /lib/libncursesw.so.8
         0x800eb8000        0x80104d000   0x195000        0x0  r-x CN-- /lib/libc.so.7
         0x80104d000        0x80124c000   0x1ff000   0x195000  --- CN-- 
         0x80124c000        0x801258000     0xc000        0x0  rw- C--- /lib/libc.so.7
         0x801258000        0x801272000    0x1a000        0x0  rw- ---- 
         0x801400000        0x801600000   0x200000   0x1a8000  rw- ---- 
      0x7fffdffff000     0x7ffffffdf000 0x1ffe0000        0x0  --- ---- 
      0x7ffffffdf000     0x7ffffffff000    0x20000        0x0  rw- ---D 
      0x7ffffffff000     0x800000000000     0x1000        0x0  r-x ----

After:

(gdb) info proc mappings 
process 822
Mapped address spaces:

          Start Addr           End Addr       Size     Offset   Flags   File
            0x400000           0x408000     0x8000        0x0  r-x C--- /bin/ls
            0x607000           0x608000     0x1000        0x0  rw- ---- 
         0x800607000        0x800629000    0x22000        0x0  r-x C--- /libexec/ld-elf.so.1
         0x800629000        0x800649000    0x20000        0x0  rw- ---- 
         0x800649000        0x80064a000     0x1000        0x0  r-- ---- 
         0x80064a000        0x800653000     0x9000        0x0  rw- ---- 
         0x800829000        0x80082b000     0x2000        0x0  rw- ---- 
         0x80082b000        0x800847000    0x1c000        0x0  r-x CN-- /lib/libxo.so.0
         0x800847000        0x800a47000   0x200000    0x1c000  --- CN-- 
         0x800a47000        0x800a48000     0x1000    0x1c000  rw- C--- /lib/libxo.so.0
         0x800a48000        0x800a59000    0x11000        0x0  r-x CN-- /lib/libutil.so.9
         0x800a59000        0x800c59000   0x200000    0x11000  --- CN-- 
         0x800c59000        0x800c5a000     0x1000    0x11000  rw- C--- /lib/libutil.so.9
         0x800c5a000        0x800c5c000     0x2000        0x0  rw- ---- 
         0x800c5c000        0x800cb5000    0x59000        0x0  r-x CN-- /lib/libncursesw.so.8
         0x800cb5000        0x800eb4000   0x1ff000    0x59000  --- CN-- 
         0x800eb4000        0x800eb9000     0x5000    0x58000  rw- C--- /lib/libncursesw.so.8
         0x800eb9000        0x800eba000     0x1000        0x0  rw- ---- 
         0x800eba000        0x801083000   0x1c9000        0x0  r-x CN-- /lib/libc.so.7
         0x801083000        0x801283000   0x200000   0x1c9000  --- CN-- 
         0x801283000        0x801292000     0xf000   0x1c9000  rw- C--- /lib/libc.so.7
         0x801292000        0x801abc000   0x82a000        0x0  rw- ---- 
      0x7fffdffff000     0x7ffffffdf000 0x1ffe0000        0x0  --- ---- 
      0x7ffffffdf000     0x7ffffffff000    0x20000        0x0  rw- ---D 
      0x7ffffffff000     0x800000000000     0x1000        0x0  r-x ----

I do find the entries with an offset in the 'before' version rather curious. All but one of them are PROT_NONE mappings that from the corresponding 'procstat -v' output all have "dead" VM objects (type shows up as "--" in procstat -v output).

In D13767#288235, @jhb wrote:

I do find the entries with an offset in the 'before' version rather curious. All but one of them are PROT_NONE mappings that from the corresponding 'procstat -v' output all have "dead" VM objects (type shows up as "--" in procstat -v output).

This is because these entries are remnants of the larger entry created for the whole dso region, and then covered by segment mappings. The inter-segment space is obtained by split of the large MAP_GUARD map entry, which does not have the backing object at all. This is cosmetic and I am not sure we need to do anything with the offsets in case of splitting MAP_GUARD.

ptrace(PT_VM_ENTRY) is already summing offsets.

This revision is now accepted and ready to land.Jan 4 2018, 8:08 PM
This revision was automatically updated to reflect the committed changes.