svn commit: r322275 - in stable/11/sys: amd64/amd64 i386/i386

Mark Johnston markj at FreeBSD.org
Tue Aug 8 19:53:08 UTC 2017


Author: markj
Date: Tue Aug  8 19:53:06 2017
New Revision: 322275
URL: https://svnweb.freebsd.org/changeset/base/322275

Log:
  MFC r321847:
  Batch updates to v_wire_count when freeing page table pages on x86.

Modified:
  stable/11/sys/amd64/amd64/pmap.c
  stable/11/sys/i386/i386/pmap.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/pmap.c
==============================================================================
--- stable/11/sys/amd64/amd64/pmap.c	Tue Aug  8 19:49:35 2017	(r322274)
+++ stable/11/sys/amd64/amd64/pmap.c	Tue Aug  8 19:53:06 2017	(r322275)
@@ -2200,12 +2200,14 @@ static __inline void
 pmap_free_zero_pages(struct spglist *free)
 {
 	vm_page_t m;
+	int count;
 
-	while ((m = SLIST_FIRST(free)) != NULL) {
+	for (count = 0; (m = SLIST_FIRST(free)) != NULL; count++) {
 		SLIST_REMOVE_HEAD(free, plinks.s.ss);
 		/* Preserve the page's PG_ZERO setting. */
 		vm_page_free_toq(m);
 	}
+	atomic_subtract_int(&vm_cnt.v_wire_count, count);
 }
 
 /*
@@ -2311,13 +2313,6 @@ _pmap_unwire_ptp(pmap_t pmap, vm_offset_t va, vm_page_
 		pmap_unwire_ptp(pmap, va, pdppg, free);
 	}
 
-	/*
-	 * This is a release store so that the ordinary store unmapping
-	 * the page table page is globally performed before TLB shoot-
-	 * down is begun.
-	 */
-	atomic_subtract_rel_int(&vm_cnt.v_wire_count, 1);
-
 	/* 
 	 * Put page on a list so that it is released after
 	 * *ALL* TLB shootdown is done
@@ -3001,7 +2996,6 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
 		SLIST_REMOVE_HEAD(&free, plinks.s.ss);
 		/* Recycle a freed page table page. */
 		m_pc->wire_count = 1;
-		atomic_add_int(&vm_cnt.v_wire_count, 1);
 	}
 	pmap_free_zero_pages(&free);
 	return (m_pc);
@@ -3666,7 +3660,6 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offse
 			    ("pmap_remove_pde: pte page wire count error"));
 			mpte->wire_count = 0;
 			pmap_add_delayed_free_list(mpte, free, FALSE);
-			atomic_subtract_int(&vm_cnt.v_wire_count, 1);
 		}
 	}
 	return (pmap_unuse_pt(pmap, sva, *pmap_pdpe(pmap, sva), free));
@@ -5531,7 +5524,6 @@ pmap_remove_pages(pmap_t pmap)
 						    ("pmap_remove_pages: pte page wire count error"));
 						mpte->wire_count = 0;
 						pmap_add_delayed_free_list(mpte, &free, FALSE);
-						atomic_subtract_int(&vm_cnt.v_wire_count, 1);
 					}
 				} else {
 					pmap_resident_count_dec(pmap, 1);

Modified: stable/11/sys/i386/i386/pmap.c
==============================================================================
--- stable/11/sys/i386/i386/pmap.c	Tue Aug  8 19:49:35 2017	(r322274)
+++ stable/11/sys/i386/i386/pmap.c	Tue Aug  8 19:53:06 2017	(r322275)
@@ -1709,12 +1709,14 @@ static __inline void
 pmap_free_zero_pages(struct spglist *free)
 {
 	vm_page_t m;
+	int count;
 
-	while ((m = SLIST_FIRST(free)) != NULL) {
+	for (count = 0; (m = SLIST_FIRST(free)) != NULL; count++) {
 		SLIST_REMOVE_HEAD(free, plinks.s.ss);
 		/* Preserve the page's PG_ZERO setting. */
 		vm_page_free_toq(m);
 	}
+	atomic_subtract_int(&vm_cnt.v_wire_count, count);
 }
 
 /*
@@ -1792,13 +1794,6 @@ _pmap_unwire_ptp(pmap_t pmap, vm_page_t m, struct spgl
 	--pmap->pm_stats.resident_count;
 
 	/*
-	 * This is a release store so that the ordinary store unmapping
-	 * the page table page is globally performed before TLB shoot-
-	 * down is begun.
-	 */
-	atomic_subtract_rel_int(&vm_cnt.v_wire_count, 1);
-
-	/*
 	 * Do an invltlb to make the invalidated mapping
 	 * take effect immediately.
 	 */
@@ -2061,11 +2056,11 @@ pmap_release(pmap_t pmap)
 		    ("pmap_release: got wrong ptd page"));
 #endif
 		m->wire_count--;
-		atomic_subtract_int(&vm_cnt.v_wire_count, 1);
 		vm_page_free_zero(m);
 	}
+	atomic_subtract_int(&vm_cnt.v_wire_count, NPGPTD);
 }
-

+
 static int
 kvm_size(SYSCTL_HANDLER_ARGS)
 {
@@ -2324,7 +2319,6 @@ out:
 		SLIST_REMOVE_HEAD(&free, plinks.s.ss);
 		/* Recycle a freed page table page. */
 		m_pc->wire_count = 1;
-		atomic_add_int(&vm_cnt.v_wire_count, 1);
 	}
 	pmap_free_zero_pages(&free);
 	return (m_pc);
@@ -2873,7 +2867,6 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offse
 			    ("pmap_remove_pde: pte page wire count error"));
 			mpte->wire_count = 0;
 			pmap_add_delayed_free_list(mpte, free, FALSE);
-			atomic_subtract_int(&vm_cnt.v_wire_count, 1);
 		}
 	}
 }
@@ -4617,7 +4610,6 @@ pmap_remove_pages(pmap_t pmap)
 						    ("pmap_remove_pages: pte page wire count error"));
 						mpte->wire_count = 0;
 						pmap_add_delayed_free_list(mpte, &free, FALSE);
-						atomic_subtract_int(&vm_cnt.v_wire_count, 1);
 					}
 				} else {
 					pmap->pm_stats.resident_count--;


More information about the svn-src-all mailing list