From owner-svn-src-stable-11@freebsd.org Sat Jan 7 11:48:45 2017 Return-Path: Delivered-To: svn-src-stable-11@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 CF477CA4DB8; Sat, 7 Jan 2017 11:48:45 +0000 (UTC) (envelope-from kib@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 785AD1ECE; Sat, 7 Jan 2017 11:48:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v07BmiCP058511; Sat, 7 Jan 2017 11:48:44 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v07Bmisg058510; Sat, 7 Jan 2017 11:48:44 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201701071148.v07Bmisg058510@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 7 Jan 2017 11:48:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r311643 - stable/11/sys/vm X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jan 2017 11:48:45 -0000 Author: kib Date: Sat Jan 7 11:48:44 2017 New Revision: 311643 URL: https://svnweb.freebsd.org/changeset/base/311643 Log: MFC r310496: Fix argument type and microoptimize swp_pager_meta_free(). Modified: stable/11/sys/vm/swap_pager.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/swap_pager.c ============================================================================== --- stable/11/sys/vm/swap_pager.c Sat Jan 7 11:44:41 2017 (r311642) +++ stable/11/sys/vm/swap_pager.c Sat Jan 7 11:48:44 2017 (r311643) @@ -410,7 +410,7 @@ static daddr_t swp_pager_getswapspace(in */ static struct swblock **swp_pager_hash(vm_object_t object, vm_pindex_t index); static void swp_pager_meta_build(vm_object_t, vm_pindex_t, daddr_t); -static void swp_pager_meta_free(vm_object_t, vm_pindex_t, daddr_t); +static void swp_pager_meta_free(vm_object_t, vm_pindex_t, vm_pindex_t); static void swp_pager_meta_free_all(vm_object_t); static daddr_t swp_pager_meta_ctl(vm_object_t, vm_pindex_t, int); @@ -1866,42 +1866,42 @@ done: * with resident pages. */ static void -swp_pager_meta_free(vm_object_t object, vm_pindex_t index, daddr_t count) +swp_pager_meta_free(vm_object_t object, vm_pindex_t index, vm_pindex_t count) { + struct swblock **pswap, *swap; + vm_pindex_t c; + daddr_t v; + int n, sidx; VM_OBJECT_ASSERT_LOCKED(object); - if (object->type != OBJT_SWAP) + if (object->type != OBJT_SWAP || count == 0) return; - while (count > 0) { - struct swblock **pswap; - struct swblock *swap; - - mtx_lock(&swhash_mtx); + mtx_lock(&swhash_mtx); + for (c = 0; c < count;) { pswap = swp_pager_hash(object, index); - - if ((swap = *pswap) != NULL) { - daddr_t v = swap->swb_pages[index & SWAP_META_MASK]; - - if (v != SWAPBLK_NONE) { - swp_pager_freeswapspace(v, 1); - swap->swb_pages[index & SWAP_META_MASK] = - SWAPBLK_NONE; - if (--swap->swb_count == 0) { - *pswap = swap->swb_hnext; - uma_zfree(swap_zone, swap); - --object->un_pager.swp.swp_bcount; - } + sidx = index & SWAP_META_MASK; + n = SWAP_META_PAGES - sidx; + index += n; + if ((swap = *pswap) == NULL) { + c += n; + continue; + } + for (; c < count && sidx < SWAP_META_PAGES; ++c, ++sidx) { + if ((v = swap->swb_pages[sidx]) == SWAPBLK_NONE) + continue; + swp_pager_freeswapspace(v, 1); + swap->swb_pages[sidx] = SWAPBLK_NONE; + if (--swap->swb_count == 0) { + *pswap = swap->swb_hnext; + uma_zfree(swap_zone, swap); + --object->un_pager.swp.swp_bcount; + c += SWAP_META_PAGES - sidx; + break; } - --count; - ++index; - } else { - int n = SWAP_META_PAGES - (index & SWAP_META_MASK); - count -= n; - index += n; } - mtx_unlock(&swhash_mtx); } + mtx_unlock(&swhash_mtx); } /*