From owner-svn-src-head@freebsd.org Thu Jan 4 21:59:35 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D75ECEBA852; Thu, 4 Jan 2018 21:59:35 +0000 (UTC) (envelope-from jhb@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 mx1.freebsd.org (Postfix) with ESMTPS id A1E343F2E; Thu, 4 Jan 2018 21:59:35 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04LxY2t099339; Thu, 4 Jan 2018 21:59:34 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04LxYfW099338; Thu, 4 Jan 2018 21:59:34 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201801042159.w04LxYfW099338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 4 Jan 2018 21:59:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327561 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 327561 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Thu, 04 Jan 2018 21:59:35 -0000 Author: jhb Date: Thu Jan 4 21:59:34 2018 New Revision: 327561 URL: https://svnweb.freebsd.org/changeset/base/327561 Log: Report offset relative to the backing object for kinfo_vmentry structures. 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 ptrace(PT_VM_ENTRY) already returns a cumulative offset rather than the raw offset of the VM map entry. Note also that this does not affect procstat -v output (even structured output) since that output does not include the kve_offset field. Reviewed by: kib MFC after: 2 weeks Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D13767 Modified: head/sys/kern/kern_proc.c Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Thu Jan 4 21:57:37 2018 (r327560) +++ head/sys/kern/kern_proc.c Thu Jan 4 21:59:34 2018 (r327561) @@ -2159,8 +2159,10 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS) } for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) { - if (tobj != obj) + if (tobj != obj) { VM_OBJECT_RLOCK(tobj); + kve->kve_offset += tobj->backing_object_offset; + } if (lobj != obj) VM_OBJECT_RUNLOCK(lobj); lobj = tobj; @@ -2168,7 +2170,7 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS) kve->kve_start = (void*)entry->start; kve->kve_end = (void*)entry->end; - kve->kve_offset = (off_t)entry->offset; + kve->kve_offset += (off_t)entry->offset; if (entry->protection & VM_PROT_READ) kve->kve_protection |= KVME_PROT_READ; @@ -2389,6 +2391,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s for (tobj = obj; tobj != NULL; tobj = tobj->backing_object) { VM_OBJECT_RLOCK(tobj); + kve->kve_offset += tobj->backing_object_offset; lobj = tobj; } if (obj->backing_object == NULL) @@ -2409,7 +2412,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, s kve->kve_start = entry->start; kve->kve_end = entry->end; - kve->kve_offset = entry->offset; + kve->kve_offset += entry->offset; if (entry->protection & VM_PROT_READ) kve->kve_protection |= KVME_PROT_READ;