Created attachment 154029 [details] Proposed patch Since r250030, when a superfluous VM object for tmpfs VREG files was eliminated, various interfaces (e.g. procfs, KERN_PROC sysctl) that return info about memory maps for processes stopped returning vnode info for tmpfs files. Instead, the mappings would appear as swap type with no further detail. This prevents tools using this information (e.g. dtrace's pid provider) from working correctly. Attached a proposed patch. It will, in cases where a VM object with type OBJT_SWAP and OBJ_TMPFS flag is found, populate the vnode pointer appropriately so the vnode information can be extracted. It will also (where applicable) set the memory mapping to appear as a vnode type (this matches FreeBSD 9 behavior, and, per advice from jhb@ and kib@, is desirable because it hides implementation details). In the case where the VM object has the OBJ_TMPFS_NODE but not OBJ_TMPFS flag (i.e. vnode has been recycled), the mapping is still returned as a vnode type, but the vnode pointer is not populated. The proposed patch covers procstat (-v), procfs, linprocfs, pmc (pmcstat), and ptrace (PT_VM_ENTRY).
Created attachment 154829 [details] Proposed patch v2
Per out of band comment from vangyzen@, I believe the "v2" patch is more correct (doesn't vref with vm_map read locked).
A commit references this bug: Author: vangyzen Date: Tue Jun 2 18:37:06 UTC 2015 New revision: 283924 URL: https://svnweb.freebsd.org/changeset/base/283924 Log: Provide vnode in memory map info for files on tmpfs When providing memory map information to userland, populate the vnode pointer for tmpfs files. Set the memory mapping to appear as a vnode type, to match FreeBSD 9 behavior. This fixes the use of tmpfs files with the dtrace pid provider, procstat -v, procfs, linprocfs, pmc (pmcstat), and ptrace (PT_VM_ENTRY). Submitted by: Eric Badger <eric@badgerio.us> (initial revision) Obtained from: Dell Inc. PR: 198431 MFC after: 2 weeks Reviewed by: jhb Approved by: kib (mentor) Changes: head/sys/compat/linprocfs/linprocfs.c head/sys/dev/hwpmc/hwpmc_mod.c head/sys/fs/procfs/procfs_map.c head/sys/kern/kern_proc.c head/sys/kern/sys_process.c head/sys/vm/vm_object.c head/sys/vm/vm_object.h
A commit references this bug: Author: vangyzen Date: Fri Oct 2 14:36:43 UTC 2015 New revision: 288499 URL: https://svnweb.freebsd.org/changeset/base/288499 Log: MFC r283924 Provide vnode in memory map info for files on tmpfs When providing memory map information to userland, populate the vnode pointer for tmpfs files. Set the memory mapping to appear as a vnode type, to match FreeBSD 9 behavior. This fixes the use of tmpfs files with the dtrace pid provider, procstat -v, procfs, linprocfs, pmc (pmcstat), and ptrace (PT_VM_ENTRY). Submitted by: Eric Badger <eric@badgerio.us> (initial revision) Obtained from: Dell Inc. PR: 198431 Changes: _U stable/10/ stable/10/sys/compat/linprocfs/linprocfs.c stable/10/sys/dev/hwpmc/hwpmc_mod.c stable/10/sys/fs/procfs/procfs_map.c stable/10/sys/kern/kern_proc.c stable/10/sys/kern/sys_process.c stable/10/sys/vm/vm_object.c stable/10/sys/vm/vm_object.h
This only affects 10 and later, so no merge to stable/9 is needed.