svn commit: r190275 - in stable/7/sys: amd64/amd64 amd64/include i386/i386 i386/include

Alan Cox alc at FreeBSD.org
Sun Mar 22 13:46:40 PDT 2009


Author: alc
Date: Sun Mar 22 20:46:37 2009
New Revision: 190275
URL: http://svn.freebsd.org/changeset/base/190275

Log:
  MFC r188932, r189785, r189795, and r190272
    Optimize free_pv_entry(); specifically, avoid repeated TAILQ_REMOVE()s.
  
    Update the pmap's resident page count when a page table page is freed in
    pmap_remove_pde() and pmap_remove_pages().
  
    Update stale comments.  The alternate address space mapping was eliminated
    when PAE support was added to i386.  The direct mapping exists on amd64.

Modified:
  stable/7/sys/amd64/amd64/pmap.c
  stable/7/sys/amd64/include/pmap.h
  stable/7/sys/i386/i386/pmap.c
  stable/7/sys/i386/include/pmap.h

Modified: stable/7/sys/amd64/amd64/pmap.c
==============================================================================
--- stable/7/sys/amd64/amd64/pmap.c	Sun Mar 22 20:36:37 2009	(r190274)
+++ stable/7/sys/amd64/amd64/pmap.c	Sun Mar 22 20:46:37 2009	(r190275)
@@ -1905,15 +1905,15 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
 	pc->pc_map[field] |= 1ul << bit;
 	/* move to head of list */
 	TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
-	TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
 	if (pc->pc_map[0] != PC_FREE0 || pc->pc_map[1] != PC_FREE1 ||
-	    pc->pc_map[2] != PC_FREE2)
+	    pc->pc_map[2] != PC_FREE2) {
+		TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
 		return;
+	}
 	PV_STAT(pv_entry_spare -= _NPCPV);
 	PV_STAT(pc_chunk_count--);
 	PV_STAT(pc_chunk_frees++);
 	/* entire chunk is free, return it */
-	TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
 	m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc));
 	dump_drop_page(m->phys_addr);
 	vm_page_unwire(m, 0);
@@ -2325,6 +2325,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t 
 		mpte = pmap_lookup_pt_page(pmap, sva);
 		if (mpte != NULL) {
 			pmap_remove_pt_page(pmap, mpte);
+			pmap->pm_stats.resident_count--;
 			KASSERT(mpte->wire_count == NPTEPG,
 			    ("pmap_remove_pde: pte page wire count error"));
 			mpte->wire_count = 0;
@@ -3797,6 +3798,7 @@ pmap_remove_pages(pmap_t pmap)
 					mpte = pmap_lookup_pt_page(pmap, pv->pv_va);
 					if (mpte != NULL) {
 						pmap_remove_pt_page(pmap, mpte);
+						pmap->pm_stats.resident_count--;
 						KASSERT(mpte->wire_count == NPTEPG,
 						    ("pmap_remove_pages: pte page wire count error"));
 						mpte->wire_count = 0;

Modified: stable/7/sys/amd64/include/pmap.h
==============================================================================
--- stable/7/sys/amd64/include/pmap.h	Sun Mar 22 20:36:37 2009	(r190274)
+++ stable/7/sys/amd64/include/pmap.h	Sun Mar 22 20:46:37 2009	(r190275)
@@ -156,13 +156,7 @@ typedef u_int64_t pml4_entry_t;
 #define	PDESHIFT	(3)
 
 /*
- * Address of current and alternate address space page table maps
- * and directories.
- * XXX it might be saner to just direct map all of physical memory
- * into the kernel using 2MB pages.  We have enough space to do
- * it (2^47 bits of KVM, while current max physical addressability
- * is 2^40 physical bits).  Then we can get rid of the evil hole
- * in the page tables and the evil overlapping.
+ * Address of current address space page table maps and directories.
  */
 #ifdef _KERNEL
 #define	addr_PTmap	(KVADDR(PML4PML4I, 0, 0, 0))

Modified: stable/7/sys/i386/i386/pmap.c
==============================================================================
--- stable/7/sys/i386/i386/pmap.c	Sun Mar 22 20:36:37 2009	(r190274)
+++ stable/7/sys/i386/i386/pmap.c	Sun Mar 22 20:46:37 2009	(r190275)
@@ -1973,15 +1973,15 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv
 	pc->pc_map[field] |= 1ul << bit;
 	/* move to head of list */
 	TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
-	TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
 	for (idx = 0; idx < _NPCM; idx++)
-		if (pc->pc_map[idx] != pc_freemask[idx])
+		if (pc->pc_map[idx] != pc_freemask[idx]) {
+			TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
 			return;
+		}
 	PV_STAT(pv_entry_spare -= _NPCPV);
 	PV_STAT(pc_chunk_count--);
 	PV_STAT(pc_chunk_frees++);
 	/* entire chunk is free, return it */
-	TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
 	m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc));
 	pmap_qremove((vm_offset_t)pc, 1);
 	vm_page_unwire(m, 0);
@@ -2431,6 +2431,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t 
 		mpte = pmap_lookup_pt_page(pmap, sva);
 		if (mpte != NULL) {
 			pmap_remove_pt_page(pmap, mpte);
+			pmap->pm_stats.resident_count--;
 			KASSERT(mpte->wire_count == NPTEPG,
 			    ("pmap_remove_pde: pte page wire count error"));
 			mpte->wire_count = 0;
@@ -3935,6 +3936,7 @@ pmap_remove_pages(pmap_t pmap)
 					mpte = pmap_lookup_pt_page(pmap, pv->pv_va);
 					if (mpte != NULL) {
 						pmap_remove_pt_page(pmap, mpte);
+						pmap->pm_stats.resident_count--;
 						KASSERT(mpte->wire_count == NPTEPG,
 						    ("pmap_remove_pages: pte page wire count error"));
 						mpte->wire_count = 0;

Modified: stable/7/sys/i386/include/pmap.h
==============================================================================
--- stable/7/sys/i386/include/pmap.h	Sun Mar 22 20:36:37 2009	(r190274)
+++ stable/7/sys/i386/include/pmap.h	Sun Mar 22 20:46:37 2009	(r190275)
@@ -174,8 +174,7 @@ typedef uint32_t pt_entry_t;
 #endif
 
 /*
- * Address of current and alternate address space page table maps
- * and directories.
+ * Address of current address space page table maps and directories.
  */
 #ifdef _KERNEL
 extern pt_entry_t PTmap[];


More information about the svn-src-all mailing list