From owner-svn-src-all@freebsd.org Sat Dec 28 19:03:18 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C6DF1EE756; Sat, 28 Dec 2019 19:03:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47lY4P6sHbz4cjx; Sat, 28 Dec 2019 19:03:17 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E69695A53; Sat, 28 Dec 2019 19:03:17 +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 xBSJ3HPk064667; Sat, 28 Dec 2019 19:03:17 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBSJ3HZN064666; Sat, 28 Dec 2019 19:03:17 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201912281903.xBSJ3HZN064666@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sat, 28 Dec 2019 19:03:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356154 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 356154 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Dec 2019 19:03:18 -0000 Author: markj Date: Sat Dec 28 19:03:17 2019 New Revision: 356154 URL: https://svnweb.freebsd.org/changeset/base/356154 Log: Don't update per-page activation counts in the swapout code. This avoids duplicating the work of the page daemon's active queue scan. Moreover, this duplication was inconsistent: - PGA_REFERENCED is not counted in act_count unless pmap_ts_referenced() returned 0, but the page daemon always counts PGA_REFERENCED towards the activation count. - The swapout daemon always activates a referenced page, but the page daemon only does so when the containing object is mapped at least once. The main purpose of swapout_deactivate_pages() is to shrink the number of pages mapped into a given pmap. To do this without unmapping active pages, use the non-destructive pmap_is_referenced() instead of the destructive pmap_ts_referenced() and deactivate pages accordingly. This simplifies some future changes to the locking protocol for page queue state. Reviewed by: kib Discussed with: jeff Tested by: pho Sponsored by: Netflix, Intel Differential Revision: https://reviews.freebsd.org/D22674 Modified: head/sys/vm/vm_swapout.c Modified: head/sys/vm/vm_swapout.c ============================================================================== --- head/sys/vm/vm_swapout.c Sat Dec 28 18:08:26 2019 (r356153) +++ head/sys/vm/vm_swapout.c Sat Dec 28 19:03:17 2019 (r356154) @@ -173,51 +173,26 @@ static void vm_thread_swapout(struct thread *td); static void vm_swapout_object_deactivate_page(pmap_t pmap, vm_page_t m, bool unmap) { - int act_delta; - if (vm_page_tryxbusy(m) == 0) - return; - VM_CNT_INC(v_pdpages); - /* - * The page may acquire a wiring after this check. - * The page daemon handles wired pages, so there is - * no harm done if a wiring appears while we are - * attempting to deactivate the page. + * Ignore unreclaimable wired pages. Repeat the check after busying + * since a busy holder may wire the page. */ + if (vm_page_wired(m) || !vm_page_tryxbusy(m)) + return; + if (vm_page_wired(m) || !pmap_page_exists_quick(pmap, m)) { vm_page_xunbusy(m); return; } - act_delta = pmap_ts_referenced(m); - vm_page_lock(m); - if ((m->a.flags & PGA_REFERENCED) != 0) { - if (act_delta == 0) - act_delta = 1; - vm_page_aflag_clear(m, PGA_REFERENCED); + if (!pmap_is_referenced(m)) { + vm_page_lock(m); + if (!vm_page_active(m)) + (void)vm_page_try_remove_all(m); + else if (unmap && vm_page_try_remove_all(m)) + vm_page_deactivate(m); + vm_page_unlock(m); } - if (!vm_page_active(m) && act_delta != 0) { - vm_page_activate(m); - m->a.act_count += act_delta; - } else if (vm_page_active(m)) { - /* - * The page daemon does not requeue pages - * after modifying their activation count. - */ - if (act_delta == 0) { - m->a.act_count -= min(m->a.act_count, ACT_DECLINE); - if (unmap && m->a.act_count == 0) { - (void)vm_page_try_remove_all(m); - vm_page_deactivate(m); - } - } else { - vm_page_activate(m); - if (m->a.act_count < ACT_MAX - ACT_ADVANCE) - m->a.act_count += ACT_ADVANCE; - } - } else if (vm_page_inactive(m)) - (void)vm_page_try_remove_all(m); - vm_page_unlock(m); vm_page_xunbusy(m); }