Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Sep 2009 17:34:49 +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-7@freebsd.org
Subject:   svn commit: r197197 - in stable/7: sys sys/amd64/amd64 sys/arm/arm sys/conf sys/contrib/pf sys/fs/procfs sys/i386/i386 sys/ia64/ia64 sys/kern sys/sparc64/sparc64 sys/sys sys/vm usr.bin/procstat
Message-ID:  <200909141734.n8EHYng3061392@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon Sep 14 17:34:49 2009
New Revision: 197197
URL: http://svn.freebsd.org/changeset/base/197197

Log:
  MFC 195840, 195844, and 196637:
  Add a new type of VM object: OBJT_SG.  An OBJT_SG object is very similar to
  a device pager (OBJT_DEVICE) object in that it uses fictitious pages to
  provide aliases to other memory addresses.  The primary difference is that
  it uses an sglist(9) to determine the physical addresses for a given offset
  into the object instead of invoking the d_mmap() method in a device driver.

Added:
  stable/7/sys/vm/sg_pager.c
     - copied, changed from r195840, head/sys/vm/sg_pager.c
Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/pmap.c
  stable/7/sys/arm/arm/pmap.c
  stable/7/sys/conf/files
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/fs/procfs/procfs_map.c
  stable/7/sys/i386/i386/pmap.c
  stable/7/sys/ia64/ia64/pmap.c
  stable/7/sys/kern/kern_proc.c
  stable/7/sys/sparc64/sparc64/pmap.c
  stable/7/sys/sys/user.h
  stable/7/sys/vm/vm.h
  stable/7/sys/vm/vm_fault.c
  stable/7/sys/vm/vm_map.c
  stable/7/sys/vm/vm_meter.c
  stable/7/sys/vm/vm_object.c
  stable/7/sys/vm/vm_object.h
  stable/7/sys/vm/vm_page.c
  stable/7/sys/vm/vm_pageout.c
  stable/7/sys/vm/vm_pager.c
  stable/7/sys/vm/vm_pager.h
  stable/7/usr.bin/procstat/   (props changed)
  stable/7/usr.bin/procstat/procstat_vm.c

Modified: stable/7/sys/amd64/amd64/pmap.c
==============================================================================
--- stable/7/sys/amd64/amd64/pmap.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/amd64/amd64/pmap.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -3350,7 +3350,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs
 	int pat_mode;
 
 	VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
-	KASSERT(object->type == OBJT_DEVICE,
+	KASSERT(object->type == OBJT_DEVICE || object->type == OBJT_SG,
 	    ("pmap_object_init_pt: non-device object"));
 	if ((addr & (NBPDR - 1)) == 0 && (size & (NBPDR - 1)) == 0) {
 		if (!vm_object_populate(object, pindex, pindex + atop(size)))
@@ -4592,7 +4592,8 @@ vm_offset_t
 pmap_addr_hint(vm_object_t obj, vm_offset_t addr, vm_size_t size)
 {
 
-	if ((obj == NULL) || (size < NBPDR) || (obj->type != OBJT_DEVICE)) {
+	if ((obj == NULL) || (size < NBPDR) ||
+	    (obj->type != OBJT_DEVICE && obj->type != OBJT_SG)) {
 		return addr;
 	}
 

Modified: stable/7/sys/arm/arm/pmap.c
==============================================================================
--- stable/7/sys/arm/arm/pmap.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/arm/arm/pmap.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -3071,7 +3071,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs
 {
 
 	VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
-	KASSERT(object->type == OBJT_DEVICE,
+	KASSERT(object->type == OBJT_DEVICE || object->type == OBJT_SG,
 	    ("pmap_object_init_pt: non-device object"));
 }
 

Modified: stable/7/sys/conf/files
==============================================================================
--- stable/7/sys/conf/files	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/conf/files	Mon Sep 14 17:34:49 2009	(r197197)
@@ -2210,6 +2210,7 @@ vm/default_pager.c		standard
 vm/device_pager.c		standard
 vm/phys_pager.c			standard
 vm/redzone.c			optional DEBUG_REDZONE
+vm/sg_pager.c			standard
 vm/swap_pager.c			standard
 vm/uma_core.c			standard
 vm/uma_dbg.c			standard

Modified: stable/7/sys/fs/procfs/procfs_map.c
==============================================================================
--- stable/7/sys/fs/procfs/procfs_map.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/fs/procfs/procfs_map.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -177,6 +177,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
 				type = "swap";
 				vp = NULL;
 				break;
+			case OBJT_SG:
 			case OBJT_DEVICE:
 				type = "device";
 				vp = NULL;

Modified: stable/7/sys/i386/i386/pmap.c
==============================================================================
--- stable/7/sys/i386/i386/pmap.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/i386/i386/pmap.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -3474,7 +3474,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs
 	int pat_mode;
 
 	VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
-	KASSERT(object->type == OBJT_DEVICE,
+	KASSERT(object->type == OBJT_DEVICE || object->type == OBJT_SG,
 	    ("pmap_object_init_pt: non-device object"));
 	if (pseflag && 
 	    (addr & (NBPDR - 1)) == 0 && (size & (NBPDR - 1)) == 0) {
@@ -4712,7 +4712,8 @@ vm_offset_t
 pmap_addr_hint(vm_object_t obj, vm_offset_t addr, vm_size_t size)
 {
 
-	if ((obj == NULL) || (size < NBPDR) || (obj->type != OBJT_DEVICE)) {
+	if ((obj == NULL) || (size < NBPDR) ||
+	    (obj->type != OBJT_DEVICE && obj->type != OBJT_SG)) {
 		return addr;
 	}
 

Modified: stable/7/sys/ia64/ia64/pmap.c
==============================================================================
--- stable/7/sys/ia64/ia64/pmap.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/ia64/ia64/pmap.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -1737,7 +1737,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offs
 {
 
 	VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
-	KASSERT(object->type == OBJT_DEVICE,
+	KASSERT(object->type == OBJT_DEVICE || object->type == OBJT_SG,
 	    ("pmap_object_init_pt: non-device object"));
 }
 

Modified: stable/7/sys/kern/kern_proc.c
==============================================================================
--- stable/7/sys/kern/kern_proc.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/kern/kern_proc.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -1488,6 +1488,9 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_A
 			case OBJT_DEAD:
 				kve->kve_type = KVME_TYPE_DEAD;
 				break;
+			case OBJT_SG:
+				kve->kve_type = KVME_TYPE_SG;
+				break;
 			default:
 				kve->kve_type = KVME_TYPE_UNKNOWN;
 				break;
@@ -1659,6 +1662,9 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR
 			case OBJT_DEAD:
 				kve->kve_type = KVME_TYPE_DEAD;
 				break;
+			case OBJT_SG:
+				kve->kve_type = KVME_TYPE_SG;
+				break;
 			default:
 				kve->kve_type = KVME_TYPE_UNKNOWN;
 				break;

Modified: stable/7/sys/sparc64/sparc64/pmap.c
==============================================================================
--- stable/7/sys/sparc64/sparc64/pmap.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/sparc64/sparc64/pmap.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -1495,7 +1495,7 @@ pmap_object_init_pt(pmap_t pm, vm_offset
 {
 
 	VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
-	KASSERT(object->type == OBJT_DEVICE,
+	KASSERT(object->type == OBJT_DEVICE || object->type == OBJT_SG,
 	    ("pmap_object_init_pt: non-device object"));
 }
 

Modified: stable/7/sys/sys/user.h
==============================================================================
--- stable/7/sys/sys/user.h	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/sys/user.h	Mon Sep 14 17:34:49 2009	(r197197)
@@ -334,6 +334,7 @@ struct kinfo_file {
 #define	KVME_TYPE_DEVICE	4
 #define	KVME_TYPE_PHYS		5
 #define	KVME_TYPE_DEAD		6
+#define	KVME_TYPE_SG		7
 #define	KVME_TYPE_UNKNOWN	255
 
 #define	KVME_PROT_READ		0x00000001

Copied and modified: stable/7/sys/vm/sg_pager.c (from r195840, head/sys/vm/sg_pager.c)
==============================================================================
--- head/sys/vm/sg_pager.c	Fri Jul 24 13:50:29 2009	(r195840, copy source)
+++ stable/7/sys/vm/sg_pager.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/sglist.h>
+#include <sys/systm.h>
 #include <vm/vm.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
@@ -45,7 +46,7 @@ __FBSDID("$FreeBSD$");
 
 static void sg_pager_init(void);
 static vm_object_t sg_pager_alloc(void *, vm_ooffset_t, vm_prot_t,
-    vm_ooffset_t, struct ucred *);
+    vm_ooffset_t);
 static void sg_pager_dealloc(vm_object_t);
 static int sg_pager_getpages(vm_object_t, vm_page_t *, int, int);
 static void sg_pager_putpages(vm_object_t, vm_page_t *, int, 
@@ -78,7 +79,7 @@ sg_pager_init(void)
 
 static vm_object_t
 sg_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
-    vm_ooffset_t foff, struct ucred *cred)
+    vm_ooffset_t foff)
 {
 	struct sglist *sg;
 	vm_object_t object;
@@ -193,21 +194,18 @@ sg_pager_getpages(vm_object_t object, vm
 	    ("backing page for SG is fake"));
 
 	/* Construct a new fake page. */
-	printf("SG: getting fake page for paddr %lx\n", paddr);
 	page = sg_pager_getfake(paddr, memattr);
 	VM_OBJECT_LOCK(object);
 	TAILQ_INSERT_TAIL(&object->un_pager.sgp.sgp_pglist, page, pageq);
 
 	/* Free the original pages and insert this fake page into the object. */
 	vm_page_lock_queues();
-	for (i = 0; i < count; i++) {
-		printf("SG: freeing VM page %p\n", m[i]);
+	for (i = 0; i < count; i++)
 		vm_page_free(m[i]);
-	}
 	vm_page_unlock_queues();
-	printf("SG: Inserting new fake page\n");
 	vm_page_insert(page, object, offset);
 	m[reqpage] = page;
+	page->valid = VM_PAGE_BITS_ALL;
 
 	return (VM_PAGER_OK);
 }

Modified: stable/7/sys/vm/vm.h
==============================================================================
--- stable/7/sys/vm/vm.h	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm.h	Mon Sep 14 17:34:49 2009	(r197197)
@@ -89,7 +89,7 @@ typedef u_char vm_prot_t;	/* protection 
 #define	VM_PROT_DEFAULT		VM_PROT_ALL
 
 enum obj_type { OBJT_DEFAULT, OBJT_SWAP, OBJT_VNODE, OBJT_DEVICE, OBJT_PHYS,
-		OBJT_DEAD };
+		OBJT_DEAD, OBJT_SG };
 typedef u_char objtype_t;
 
 union vm_map_object;

Modified: stable/7/sys/vm/vm_fault.c
==============================================================================
--- stable/7/sys/vm/vm_fault.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_fault.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -485,7 +485,8 @@ readrest:
 			    (fs.first_object == fs.object ||
 			     (is_first_object_locked = VM_OBJECT_TRYLOCK(fs.first_object))) &&
 			    fs.first_object->type != OBJT_DEVICE &&
-			    fs.first_object->type != OBJT_PHYS) {
+			    fs.first_object->type != OBJT_PHYS &&
+			    fs.first_object->type != OBJT_SG) {
 				vm_pindex_t firstpindex, tmppindex;
 
 				if (fs.first_pindex < 2 * VM_FAULT_READ)

Modified: stable/7/sys/vm/vm_map.c
==============================================================================
--- stable/7/sys/vm/vm_map.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_map.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -1478,7 +1478,7 @@ vm_map_pmap_enter(vm_map_t map, vm_offse
 	if ((prot & (VM_PROT_READ | VM_PROT_EXECUTE)) == 0 || object == NULL)
 		return;
 	VM_OBJECT_LOCK(object);
-	if (object->type == OBJT_DEVICE) {
+	if (object->type == OBJT_DEVICE || object->type == OBJT_SG) {
 		pmap_object_init_pt(map->pmap, addr, object, pindex, size);
 		goto unlock_return;
 	}
@@ -1954,7 +1954,8 @@ done:
 				 */
 				vm_fault_unwire(map, entry->start, entry->end,
 				    entry->object.vm_object != NULL &&
-				    entry->object.vm_object->type == OBJT_DEVICE);
+				    (entry->object.vm_object->type == OBJT_DEVICE ||
+				    entry->object.vm_object->type == OBJT_SG));
 			}
 		}
 		KASSERT(entry->eflags & MAP_ENTRY_IN_TRANSITION,
@@ -2073,7 +2074,8 @@ vm_map_wire(vm_map_t map, vm_offset_t st
 			saved_start = entry->start;
 			saved_end = entry->end;
 			fictitious = entry->object.vm_object != NULL &&
-			    entry->object.vm_object->type == OBJT_DEVICE;
+			    (entry->object.vm_object->type == OBJT_DEVICE ||
+			    entry->object.vm_object->type == OBJT_SG);
 			/*
 			 * Release the map lock, relying on the in-transition
 			 * mark.
@@ -2169,7 +2171,8 @@ done:
 				 */
 				vm_fault_unwire(map, entry->start, entry->end,
 				    entry->object.vm_object != NULL &&
-				    entry->object.vm_object->type == OBJT_DEVICE);
+				    (entry->object.vm_object->type == OBJT_DEVICE ||
+				    entry->object.vm_object->type == OBJT_SG));
 			}
 		}
 	next_entry_done:
@@ -2294,7 +2297,8 @@ vm_map_entry_unwire(vm_map_t map, vm_map
 {
 	vm_fault_unwire(map, entry->start, entry->end,
 	    entry->object.vm_object != NULL &&
-	    entry->object.vm_object->type == OBJT_DEVICE);
+	    (entry->object.vm_object->type == OBJT_DEVICE ||
+	    entry->object.vm_object->type == OBJT_SG));
 	entry->wired_count = 0;
 }
 

Modified: stable/7/sys/vm/vm_meter.c
==============================================================================
--- stable/7/sys/vm/vm_meter.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_meter.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -211,7 +211,7 @@ vmtotal(SYSCTL_HANDLER_ARGS)
 		 * synchronization should not impair the accuracy of
 		 * the reported statistics. 
 		 */
-		if (object->type == OBJT_DEVICE) {
+		if (object->type == OBJT_DEVICE || object->type == OBJT_SG) {
 			/*
 			 * Devices, like /dev/mem, will badly skew our totals.
 			 */

Modified: stable/7/sys/vm/vm_object.c
==============================================================================
--- stable/7/sys/vm/vm_object.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_object.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -306,6 +306,7 @@ vm_object_set_memattr(vm_object_t object
 	case OBJT_DEFAULT:
 	case OBJT_DEVICE:
 	case OBJT_PHYS:
+	case OBJT_SG:
 	case OBJT_SWAP:
 	case OBJT_VNODE:
 		if (!TAILQ_EMPTY(&object->memq))

Modified: stable/7/sys/vm/vm_object.h
==============================================================================
--- stable/7/sys/vm/vm_object.h	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_object.h	Mon Sep 14 17:34:49 2009	(r197197)
@@ -124,6 +124,15 @@ struct vm_object {
 		} devp;
 
 		/*
+		 * SG pager
+		 *
+		 *	sgp_pglist - list of allocated pages
+		 */
+		struct {
+			TAILQ_HEAD(, vm_page) sgp_pglist;
+		} sgp;
+
+		/*
 		 * Swap pager
 		 *
 		 *	swp_bcount - number of swap 'swblock' metablocks, each

Modified: stable/7/sys/vm/vm_page.c
==============================================================================
--- stable/7/sys/vm/vm_page.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_page.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -1149,7 +1149,7 @@ vm_page_alloc(vm_object_t object, vm_pin
 	if (object != NULL) {
 		/* Ignore device objects; the pager sets "memattr" for them. */
 		if (object->memattr != VM_MEMATTR_DEFAULT &&
-		    object->type != OBJT_DEVICE)
+		    object->type != OBJT_DEVICE && object->type != OBJT_SG)
 			pmap_page_set_memattr(m, object->memattr);
 		vm_page_insert(m, object, pindex);
 	} else

Modified: stable/7/sys/vm/vm_pageout.c
==============================================================================
--- stable/7/sys/vm/vm_pageout.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_pageout.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -516,7 +516,9 @@ vm_pageout_object_deactivate_pages(pmap,
 	int actcount, rcount, remove_mode;
 
 	VM_OBJECT_LOCK_ASSERT(first_object, MA_OWNED);
-	if (first_object->type == OBJT_DEVICE || first_object->type == OBJT_PHYS)
+	if (first_object->type == OBJT_DEVICE ||
+	    first_object->type == OBJT_SG ||
+	    first_object->type == OBJT_PHYS)
 		return;
 	for (object = first_object;; object = backing_object) {
 		if (pmap_resident_count(pmap) <= desired)

Modified: stable/7/sys/vm/vm_pager.c
==============================================================================
--- stable/7/sys/vm/vm_pager.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_pager.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -160,7 +160,8 @@ struct pagerops *pagertab[] = {
 	&vnodepagerops,		/* OBJT_VNODE */
 	&devicepagerops,	/* OBJT_DEVICE */
 	&physpagerops,		/* OBJT_PHYS */
-	&deadpagerops		/* OBJT_DEAD */
+	&deadpagerops,		/* OBJT_DEAD */
+	&sgpagerops		/* OBJT_SG */
 };
 
 static const int npagers = sizeof(pagertab) / sizeof(pagertab[0]);

Modified: stable/7/sys/vm/vm_pager.h
==============================================================================
--- stable/7/sys/vm/vm_pager.h	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/sys/vm/vm_pager.h	Mon Sep 14 17:34:49 2009	(r197197)
@@ -71,6 +71,7 @@ extern struct pagerops swappagerops;
 extern struct pagerops vnodepagerops;
 extern struct pagerops devicepagerops;
 extern struct pagerops physpagerops;
+extern struct pagerops sgpagerops;
 
 /*
  * get/put return values

Modified: stable/7/usr.bin/procstat/procstat_vm.c
==============================================================================
--- stable/7/usr.bin/procstat/procstat_vm.c	Mon Sep 14 16:52:38 2009	(r197196)
+++ stable/7/usr.bin/procstat/procstat_vm.c	Mon Sep 14 17:34:49 2009	(r197197)
@@ -93,6 +93,9 @@ procstat_vm(pid_t pid, struct kinfo_proc
 		case KVME_TYPE_DEAD:
 			str = "dd";
 			break;
+		case KVME_TYPE_SG:
+			str = "sg";
+			break;
 		case KVME_TYPE_UNKNOWN:
 		default:
 			str = "??";



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