Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2018 04:59:43 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341282 - in head/sys: kern vm
Message-ID:  <201811300459.wAU4xhtC016056@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Fri Nov 30 04:59:43 2018
New Revision: 341282
URL: https://svnweb.freebsd.org/changeset/base/341282

Log:
  Include path for tmpfs objects in vm.objects sysctl
  
  This applies the fix in r283924 to the vm.objects sysctl
  added by r283624 so the output will include the vnode
  information (i.e. path) for tmpfs objects.
  
  Reviewed by:	kib, dab
  MFC after:	2 weeks
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D2724

Modified:
  head/sys/kern/kern_proc.c
  head/sys/vm/vm_object.c
  head/sys/vm/vm_object.h

Modified: head/sys/kern/kern_proc.c
==============================================================================
--- head/sys/kern/kern_proc.c	Fri Nov 30 04:18:31 2018	(r341281)
+++ head/sys/kern/kern_proc.c	Fri Nov 30 04:59:43 2018	(r341282)
@@ -2219,43 +2219,11 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
 		freepath = NULL;
 		fullpath = "";
 		if (lobj) {
-			vp = NULL;
-			switch (lobj->type) {
-			case OBJT_DEFAULT:
-				kve->kve_type = KVME_TYPE_DEFAULT;
-				break;
-			case OBJT_VNODE:
-				kve->kve_type = KVME_TYPE_VNODE;
-				vp = lobj->handle;
-				vref(vp);
-				break;
-			case OBJT_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;
-				break;
-			case OBJT_PHYS:
-				kve->kve_type = KVME_TYPE_PHYS;
-				break;
-			case OBJT_DEAD:
-				kve->kve_type = KVME_TYPE_DEAD;
-				break;
-			case OBJT_SG:
-				kve->kve_type = KVME_TYPE_SG;
-				break;
-			default:
+			kve->kve_type = vm_object_kvme_type(lobj, &vp);
+			if (kve->kve_type == KVME_TYPE_MGTDEVICE)
 				kve->kve_type = KVME_TYPE_UNKNOWN;
-				break;
-			}
+			if (vp != NULL)
+				vref(vp);
 			if (lobj != obj)
 				VM_OBJECT_RUNLOCK(lobj);
 
@@ -2463,46 +2431,9 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s
 		freepath = NULL;
 		fullpath = "";
 		if (lobj != NULL) {
-			vp = NULL;
-			switch (lobj->type) {
-			case OBJT_DEFAULT:
-				kve->kve_type = KVME_TYPE_DEFAULT;
-				break;
-			case OBJT_VNODE:
-				kve->kve_type = KVME_TYPE_VNODE;
-				vp = lobj->handle;
+			kve->kve_type = vm_object_kvme_type(lobj, &vp);
+			if (vp != NULL)
 				vref(vp);
-				break;
-			case OBJT_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;
-				break;
-			case OBJT_PHYS:
-				kve->kve_type = KVME_TYPE_PHYS;
-				break;
-			case OBJT_DEAD:
-				kve->kve_type = KVME_TYPE_DEAD;
-				break;
-			case OBJT_SG:
-				kve->kve_type = KVME_TYPE_SG;
-				break;
-			case OBJT_MGTDEVICE:
-				kve->kve_type = KVME_TYPE_MGTDEVICE;
-				break;
-			default:
-				kve->kve_type = KVME_TYPE_UNKNOWN;
-				break;
-			}
 			if (lobj != obj)
 				VM_OBJECT_RUNLOCK(lobj);
 

Modified: head/sys/vm/vm_object.c
==============================================================================
--- head/sys/vm/vm_object.c	Fri Nov 30 04:18:31 2018	(r341281)
+++ head/sys/vm/vm_object.c	Fri Nov 30 04:59:43 2018	(r341282)
@@ -2330,6 +2330,41 @@ vm_object_vnode(vm_object_t object)
 	return (vp);
 }
 
+/*
+ * Return the kvme type of the given object.
+ * If vpp is not NULL, set it to the object's vm_object_vnode() or NULL.
+ */
+int
+vm_object_kvme_type(vm_object_t object, struct vnode **vpp)
+{
+
+	VM_OBJECT_ASSERT_LOCKED(object);
+	if (vpp != NULL)
+		*vpp = vm_object_vnode(object);
+	switch (object->type) {
+	case OBJT_DEFAULT:
+		return (KVME_TYPE_DEFAULT);
+	case OBJT_VNODE:
+		return (KVME_TYPE_VNODE);
+	case OBJT_SWAP:
+		if ((object->flags & OBJ_TMPFS_NODE) != 0)
+			return (KVME_TYPE_VNODE);
+		return (KVME_TYPE_SWAP);
+	case OBJT_DEVICE:
+		return (KVME_TYPE_DEVICE);
+	case OBJT_PHYS:
+		return (KVME_TYPE_PHYS);
+	case OBJT_DEAD:
+		return (KVME_TYPE_DEAD);
+	case OBJT_SG:
+		return (KVME_TYPE_SG);
+	case OBJT_MGTDEVICE:
+		return (KVME_TYPE_MGTDEVICE);
+	default:
+		return (KVME_TYPE_UNKNOWN);
+	}
+}
+
 static int
 sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
 {
@@ -2404,38 +2439,9 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
 		kvo->kvo_vn_fsid_freebsd11 = 0;
 		freepath = NULL;
 		fullpath = "";
-		vp = NULL;
-		switch (obj->type) {
-		case OBJT_DEFAULT:
-			kvo->kvo_type = KVME_TYPE_DEFAULT;
-			break;
-		case OBJT_VNODE:
-			kvo->kvo_type = KVME_TYPE_VNODE;
-			vp = obj->handle;
+		kvo->kvo_type = vm_object_kvme_type(obj, &vp);
+		if (vp != NULL)
 			vref(vp);
-			break;
-		case OBJT_SWAP:
-			kvo->kvo_type = KVME_TYPE_SWAP;
-			break;
-		case OBJT_DEVICE:
-			kvo->kvo_type = KVME_TYPE_DEVICE;
-			break;
-		case OBJT_PHYS:
-			kvo->kvo_type = KVME_TYPE_PHYS;
-			break;
-		case OBJT_DEAD:
-			kvo->kvo_type = KVME_TYPE_DEAD;
-			break;
-		case OBJT_SG:
-			kvo->kvo_type = KVME_TYPE_SG;
-			break;
-		case OBJT_MGTDEVICE:
-			kvo->kvo_type = KVME_TYPE_MGTDEVICE;
-			break;
-		default:
-			kvo->kvo_type = KVME_TYPE_UNKNOWN;
-			break;
-		}
 		VM_OBJECT_RUNLOCK(obj);
 		if (vp != NULL) {
 			vn_fullpath(curthread, vp, &fullpath, &freepath);

Modified: head/sys/vm/vm_object.h
==============================================================================
--- head/sys/vm/vm_object.h	Fri Nov 30 04:18:31 2018	(r341281)
+++ head/sys/vm/vm_object.h	Fri Nov 30 04:59:43 2018	(r341282)
@@ -263,6 +263,8 @@ extern struct vm_object kernel_object_store;
 #define	VM_OBJECT_WUNLOCK(object)					\
 	rw_wunlock(&(object)->lock)
 
+struct vnode;
+
 /*
  *	The object must be locked or thread private.
  */
@@ -328,6 +330,7 @@ void vm_object_destroy (vm_object_t);
 void vm_object_terminate (vm_object_t);
 void vm_object_set_writeable_dirty (vm_object_t);
 void vm_object_init (void);
+int  vm_object_kvme_type(vm_object_t object, struct vnode **vpp);
 void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int);
 boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start,
     vm_ooffset_t end, int flags);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811300459.wAU4xhtC016056>