From owner-svn-src-head@freebsd.org Fri Nov 30 04:59:45 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E4DDA1157FF7; Fri, 30 Nov 2018 04:59:44 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 876E76C8C3; Fri, 30 Nov 2018 04:59:44 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 62B3C23CDA; Fri, 30 Nov 2018 04:59:44 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAU4xiZI016059; Fri, 30 Nov 2018 04:59:44 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAU4xhtC016056; Fri, 30 Nov 2018 04:59:43 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201811300459.wAU4xhtC016056@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Fri, 30 Nov 2018 04:59:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341282 - in head/sys: kern vm X-SVN-Group: head X-SVN-Commit-Author: vangyzen X-SVN-Commit-Paths: in head/sys: kern vm X-SVN-Commit-Revision: 341282 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 876E76C8C3 X-Spamd-Result: default: False [0.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_LONG(0.34)[0.335,0]; NEURAL_SPAM_MEDIUM(0.31)[0.312,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_SPAM_SHORT(0.30)[0.303,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Nov 2018 04:59:45 -0000 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);