svn commit: r288499 - in stable/10/sys: compat/linprocfs dev/hwpmc fs/procfs kern vm

Eric van Gyzen vangyzen at FreeBSD.org
Fri Oct 2 14:36:44 UTC 2015


Author: vangyzen
Date: Fri Oct  2 14:36:41 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 at badgerio.us> (initial revision)
  Obtained from:  Dell Inc.
  PR:             198431

Modified:
  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
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- stable/10/sys/compat/linprocfs/linprocfs.c	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/compat/linprocfs/linprocfs.c	Fri Oct  2 14:36:41 2015	(r288499)
@@ -1042,20 +1042,16 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
 		ino = 0;
 		if (lobj) {
 			off = IDX_TO_OFF(lobj->size);
-			if (lobj->type == OBJT_VNODE) {
-				vp = lobj->handle;
-				if (vp)
-					vref(vp);
-			}
-			else
-				vp = NULL;
+			vp = vm_object_vnode(lobj);
+			if (vp != NULL)
+				vref(vp);
 			if (lobj != obj)
 				VM_OBJECT_RUNLOCK(lobj);
 			flags = obj->flags;
 			ref_count = obj->ref_count;
 			shadow_count = obj->shadow_count;
 			VM_OBJECT_RUNLOCK(obj);
-			if (vp) {
+			if (vp != NULL) {
 				vn_fullpath(td, vp, &name, &freename);
 				vn_lock(vp, LK_SHARED | LK_RETRY);
 				VOP_GETATTR(vp, &vat, td->td_ucred);

Modified: stable/10/sys/dev/hwpmc/hwpmc_mod.c
==============================================================================
--- stable/10/sys/dev/hwpmc/hwpmc_mod.c	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/dev/hwpmc/hwpmc_mod.c	Fri Oct  2 14:36:41 2015	(r288499)
@@ -1660,7 +1660,8 @@ pmc_log_process_mappings(struct pmc_owne
 			continue;
 		}
 
-		if (lobj->type != OBJT_VNODE || lobj->handle == NULL) {
+		vp = vm_object_vnode(lobj);
+		if (vp == NULL) {
 			if (lobj != obj)
 				VM_OBJECT_RUNLOCK(lobj);
 			VM_OBJECT_RUNLOCK(obj);
@@ -1672,7 +1673,7 @@ pmc_log_process_mappings(struct pmc_owne
 		 * vnode, so we don't emit redundant MAP-IN
 		 * directives.
 		 */
-		if (entry->start == last_end && lobj->handle == last_vp) {
+		if (entry->start == last_end && vp == last_vp) {
 			last_end = entry->end;
 			if (lobj != obj)
 				VM_OBJECT_RUNLOCK(lobj);
@@ -1695,7 +1696,6 @@ pmc_log_process_mappings(struct pmc_owne
 		last_timestamp = map->timestamp;
 		vm_map_unlock_read(map);
 
-		vp = lobj->handle;
 		vref(vp);
 		if (lobj != obj)
 			VM_OBJECT_RUNLOCK(lobj);

Modified: stable/10/sys/fs/procfs/procfs_map.c
==============================================================================
--- stable/10/sys/fs/procfs/procfs_map.c	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/fs/procfs/procfs_map.c	Fri Oct  2 14:36:41 2015	(r288499)
@@ -159,11 +159,11 @@ procfs_doprocmap(PFS_FILL_ARGS)
 		freepath = NULL;
 		fullpath = "-";
 		if (lobj) {
+			vp = NULL;
 			switch (lobj->type) {
 			default:
 			case OBJT_DEFAULT:
 				type = "default";
-				vp = NULL;
 				break;
 			case OBJT_VNODE:
 				type = "vnode";
@@ -171,13 +171,19 @@ procfs_doprocmap(PFS_FILL_ARGS)
 				vref(vp);
 				break;
 			case OBJT_SWAP:
-				type = "swap";
-				vp = NULL;
+				if ((lobj->flags & OBJ_TMPFS_NODE) != 0) {
+					type = "vnode";
+					if ((lobj->flags & OBJ_TMPFS) != 0) {
+						vp = lobj->un_pager.swp.swp_tmpfs;
+						vref(vp);
+					}
+				} else {
+					type = "swap";
+				}
 				break;
 			case OBJT_SG:
 			case OBJT_DEVICE:
 				type = "device";
-				vp = NULL;
 				break;
 			}
 			if (lobj != obj)

Modified: stable/10/sys/kern/kern_proc.c
==============================================================================
--- stable/10/sys/kern/kern_proc.c	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/kern/kern_proc.c	Fri Oct  2 14:36:41 2015	(r288499)
@@ -2074,7 +2074,15 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_A
 				vref(vp);
 				break;
 			case OBJT_SWAP:
-				kve->kve_type = KVME_TYPE_SWAP;
+				if ((lobj->flags & OBJ_TMPFS_NODE) != 0) {
+					kve->kve_type = KVME_TYPE_VNODE;
+					if ((lobj->flags & OBJ_TMPFS) != 0) {
+						vp = lobj->un_pager.swp.swp_tmpfs;
+						vref(vp);
+					}
+				} else {
+					kve->kve_type = KVME_TYPE_SWAP;
+				}
 				break;
 			case OBJT_DEVICE:
 				kve->kve_type = KVME_TYPE_DEVICE;
@@ -2300,7 +2308,15 @@ kern_proc_vmmap_out(struct proc *p, stru
 				vref(vp);
 				break;
 			case OBJT_SWAP:
-				kve->kve_type = KVME_TYPE_SWAP;
+				if ((lobj->flags & OBJ_TMPFS_NODE) != 0) {
+					kve->kve_type = KVME_TYPE_VNODE;
+					if ((lobj->flags & OBJ_TMPFS) != 0) {
+						vp = lobj->un_pager.swp.swp_tmpfs;
+						vref(vp);
+					}
+				} else {
+					kve->kve_type = KVME_TYPE_SWAP;
+				}
 				break;
 			case OBJT_DEVICE:
 				kve->kve_type = KVME_TYPE_DEVICE;

Modified: stable/10/sys/kern/sys_process.c
==============================================================================
--- stable/10/sys/kern/sys_process.c	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/kern/sys_process.c	Fri Oct  2 14:36:41 2015	(r288499)
@@ -402,7 +402,7 @@ ptrace_vm_entry(struct thread *td, struc
 			lobj = tobj;
 			pve->pve_offset += tobj->backing_object_offset;
 		}
-		vp = (lobj->type == OBJT_VNODE) ? lobj->handle : NULL;
+		vp = vm_object_vnode(lobj);
 		if (vp != NULL)
 			vref(vp);
 		if (lobj != obj)

Modified: stable/10/sys/vm/vm_object.c
==============================================================================
--- stable/10/sys/vm/vm_object.c	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/vm/vm_object.c	Fri Oct  2 14:36:41 2015	(r288499)
@@ -2270,6 +2270,18 @@ next_page:
 	}
 }
 
+struct vnode *
+vm_object_vnode(vm_object_t object)
+{
+
+	VM_OBJECT_ASSERT_LOCKED(object);
+	if (object->type == OBJT_VNODE)
+		return (object->handle);
+	if (object->type == OBJT_SWAP && (object->flags & OBJ_TMPFS) != 0)
+		return (object->un_pager.swp.swp_tmpfs);
+	return (NULL);
+}
+
 static int
 sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
 {

Modified: stable/10/sys/vm/vm_object.h
==============================================================================
--- stable/10/sys/vm/vm_object.h	Fri Oct  2 14:24:39 2015	(r288498)
+++ stable/10/sys/vm/vm_object.h	Fri Oct  2 14:36:41 2015	(r288499)
@@ -297,6 +297,7 @@ boolean_t vm_object_sync(vm_object_t, vm
     boolean_t);
 void vm_object_unwire(vm_object_t object, vm_ooffset_t offset,
     vm_size_t length, uint8_t queue);
+struct vnode *vm_object_vnode(vm_object_t object);
 #endif				/* _KERNEL */
 
 #endif				/* _VM_OBJECT_ */


More information about the svn-src-stable-10 mailing list