Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 18 Jul 2009 01:50:05 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r195749 - in head/sys: amd64/amd64 i386/i386 vm
Message-ID:  <200907180150.n6I1o5i4087743@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Sat Jul 18 01:50:05 2009
New Revision: 195749
URL: http://svn.freebsd.org/changeset/base/195749

Log:
  An addendum to r195649, "Add support to the virtual memory system for
  configuring machine-dependent memory attributes...":
  
  Don't set the memory attribute for a "real" page that is allocated to
  a device object in vm_page_alloc().  It is a pointless act, because
  the device pager replaces this "real" page with a "fake" page and sets
  the memory attribute on that "fake" page.
  
  Eliminate pointless code from pmap_cache_bits() on amd64.
  
  Employ the "Self Snoop" feature supported by some x86 processors to
  avoid cache flushes in the pmap.
  
  Approved by:	re (kib)

Modified:
  head/sys/amd64/amd64/pmap.c
  head/sys/i386/i386/pmap.c
  head/sys/vm/vm_page.c

Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c	Fri Jul 17 21:48:08 2009	(r195748)
+++ head/sys/amd64/amd64/pmap.c	Sat Jul 18 01:50:05 2009	(r195749)
@@ -752,21 +752,6 @@ pmap_cache_bits(int mode, boolean_t is_p
 	/* The PAT bit is different for PTE's and PDE's. */
 	pat_flag = is_pde ? PG_PDE_PAT : PG_PTE_PAT;
 
-	/* If we don't support PAT, map extended modes to older ones. */
-	if (!(cpu_feature & CPUID_PAT)) {
-		switch (mode) {
-		case PAT_UNCACHEABLE:
-		case PAT_WRITE_THROUGH:
-		case PAT_WRITE_BACK:
-			break;
-		case PAT_UNCACHED:
-		case PAT_WRITE_COMBINING:
-		case PAT_WRITE_PROTECTED:
-			mode = PAT_UNCACHEABLE;
-			break;
-		}
-	}
-
 	/* Map the caching mode to a PAT index. */
 	switch (mode) {
 	case PAT_UNCACHEABLE:
@@ -4295,7 +4280,9 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_
 		pa += PAGE_SIZE;
 	}
 	pmap_invalidate_range(kernel_pmap, va, tmpva);
-	pmap_invalidate_cache();
+	/* If "Self Snoop" is supported, do nothing. */
+	if (!(cpu_feature & CPUID_SS))
+		pmap_invalidate_cache();
 	return ((void *)(va + offset));
 }
 
@@ -4634,7 +4621,9 @@ pmap_change_attr_locked(vm_offset_t va, 
 	 */
 	if (changed) {
 		pmap_invalidate_range(kernel_pmap, base, tmpva);
-		pmap_invalidate_cache();
+		/* If "Self Snoop" is supported, do nothing. */
+		if (!(cpu_feature & CPUID_SS))
+			pmap_invalidate_cache();
 	}
 	return (error);
 }

Modified: head/sys/i386/i386/pmap.c
==============================================================================
--- head/sys/i386/i386/pmap.c	Fri Jul 17 21:48:08 2009	(r195748)
+++ head/sys/i386/i386/pmap.c	Sat Jul 18 01:50:05 2009	(r195749)
@@ -4420,7 +4420,9 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_
 		pa += PAGE_SIZE;
 	}
 	pmap_invalidate_range(kernel_pmap, va, tmpva);
-	pmap_invalidate_cache();
+	/* If "Self Snoop" is supported, do nothing. */
+	if (!(cpu_feature & CPUID_SS))
+		pmap_invalidate_cache();
 	return ((void *)(va + offset));
 }
 
@@ -4467,7 +4469,9 @@ pmap_page_set_memattr(vm_page_t m, vm_me
 	 * Flush CPU caches to make sure any data isn't cached that shouldn't
 	 * be, etc.
 	 */    
-	pmap_invalidate_cache();
+	/* If "Self Snoop" is supported, do nothing. */
+	if (!(cpu_feature & CPUID_SS))
+		pmap_invalidate_cache();
 }
 
 int
@@ -4526,7 +4530,9 @@ pmap_change_attr(vm_offset_t va, vm_size
 	 * be, etc.
 	 */    
 	pmap_invalidate_range(kernel_pmap, base, tmpva);
-	pmap_invalidate_cache();
+	/* If "Self Snoop" is supported, do nothing. */
+	if (!(cpu_feature & CPUID_SS))
+		pmap_invalidate_cache();
 	return (0);
 }
 

Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c	Fri Jul 17 21:48:08 2009	(r195748)
+++ head/sys/vm/vm_page.c	Sat Jul 18 01:50:05 2009	(r195749)
@@ -1161,7 +1161,9 @@ vm_page_alloc(vm_object_t object, vm_pin
 	mtx_unlock(&vm_page_queue_free_mtx);
 
 	if (object != NULL) {
-		if (object->memattr != VM_MEMATTR_DEFAULT)
+		/* Ignore device objects; the pager sets "memattr" for them. */
+		if (object->memattr != VM_MEMATTR_DEFAULT &&
+		    object->type != OBJT_DEVICE)
 			pmap_page_set_memattr(m, object->memattr);
 		vm_page_insert(m, object, pindex);
 	} else



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