Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jan 2018 23:43:04 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328571 - in stable: 10/sys/kern 11/sys/kern
Message-ID:  <201801292343.w0TNh44C064635@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon Jan 29 23:43:04 2018
New Revision: 328571
URL: https://svnweb.freebsd.org/changeset/base/328571

Log:
  MFC 327561:
  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.
  
  Sponsored by:	DARPA / AFRL

Modified:
  stable/11/sys/kern/kern_proc.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/kern/kern_proc.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/11/sys/kern/kern_proc.c
==============================================================================
--- stable/11/sys/kern/kern_proc.c	Mon Jan 29 23:36:05 2018	(r328570)
+++ stable/11/sys/kern/kern_proc.c	Mon Jan 29 23:43:04 2018	(r328571)
@@ -2138,8 +2138,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;
@@ -2147,7 +2149,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;
@@ -2367,6 +2369,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)
@@ -2387,7 +2390,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;



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