From owner-svn-src-head@freebsd.org Tue Aug 1 05:26:32 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6CD2FDADC3B; Tue, 1 Aug 2017 05:26:32 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 284B764473; Tue, 1 Aug 2017 05:26:32 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v715QVRg047187; Tue, 1 Aug 2017 05:26:31 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v715QUDD047185; Tue, 1 Aug 2017 05:26:30 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201708010526.v715QUDD047185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 1 Aug 2017 05:26:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321847 - in head/sys: amd64/amd64 i386/i386 X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 321847 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Aug 2017 05:26:32 -0000 Author: markj Date: Tue Aug 1 05:26:30 2017 New Revision: 321847 URL: https://svnweb.freebsd.org/changeset/base/321847 Log: Batch updates to v_wire_count when freeing page table pages on x86. The removed release stores are not needed since stores are totally ordered on i386 and amd64. Reviewed by: alc, kib (previous revision) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11790 Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Tue Aug 1 05:26:20 2017 (r321846) +++ head/sys/amd64/amd64/pmap.c Tue Aug 1 05:26:30 2017 (r321847) @@ -2209,12 +2209,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); } /* @@ -2320,13 +2322,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 @@ -3010,7 +3005,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); @@ -3678,7 +3672,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)); @@ -5622,7 +5615,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: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Tue Aug 1 05:26:20 2017 (r321846) +++ head/sys/i386/i386/pmap.c Tue Aug 1 05:26:30 2017 (r321847) @@ -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); } } } @@ -4593,7 +4586,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--;