From owner-svn-src-head@freebsd.org Sun Jul 15 19:25:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF52E104C415; Sun, 15 Jul 2018 19:25:16 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C7CA94AE8; Sun, 15 Jul 2018 19:25:16 +0000 (UTC) (envelope-from alc@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 67392122BB; Sun, 15 Jul 2018 19:25:16 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6FJPGB0050257; Sun, 15 Jul 2018 19:25:16 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6FJPGKq050256; Sun, 15 Jul 2018 19:25:16 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201807151925.w6FJPGKq050256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Sun, 15 Jul 2018 19:25:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336314 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: alc X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 336314 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.27 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: Sun, 15 Jul 2018 19:25:17 -0000 Author: alc Date: Sun Jul 15 19:25:15 2018 New Revision: 336314 URL: https://svnweb.freebsd.org/changeset/base/336314 Log: Test PGA_REFERENCED after calling pmap_ts_referenced(), rather than before, so that a reference from a concurrently destroyed mapping is observed during the current scan. Reviewed by: kib, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D16277 Modified: head/sys/vm/vm_pageout.c Modified: head/sys/vm/vm_pageout.c ============================================================================== --- head/sys/vm/vm_pageout.c Sun Jul 15 19:04:23 2018 (r336313) +++ head/sys/vm/vm_pageout.c Sun Jul 15 19:25:15 2018 (r336314) @@ -793,18 +793,22 @@ recheck: * If the page has been referenced and the object is not dead, * reactivate or requeue the page depending on whether the * object is mapped. + * + * Test PGA_REFERENCED after calling pmap_ts_referenced() so + * that a reference from a concurrently destroyed mapping is + * observed here and now. */ - if ((m->aflags & PGA_REFERENCED) != 0) { - vm_page_aflag_clear(m, PGA_REFERENCED); - act_delta = 1; - } else - act_delta = 0; if (object->ref_count != 0) - act_delta += pmap_ts_referenced(m); + act_delta = pmap_ts_referenced(m); else { KASSERT(!pmap_page_is_mapped(m), ("page %p is mapped", m)); + act_delta = 0; } + if ((m->aflags & PGA_REFERENCED) != 0) { + vm_page_aflag_clear(m, PGA_REFERENCED); + act_delta++; + } if (act_delta != 0) { if (object->ref_count != 0) { VM_CNT_INC(v_reactivated); @@ -1215,14 +1219,11 @@ act_scan: /* * Check to see "how much" the page has been used. - */ - if ((m->aflags & PGA_REFERENCED) != 0) { - vm_page_aflag_clear(m, PGA_REFERENCED); - act_delta = 1; - } else - act_delta = 0; - - /* + * + * Test PGA_REFERENCED after calling pmap_ts_referenced() so + * that a reference from a concurrently destroyed mapping is + * observed here and now. + * * Perform an unsynchronized object ref count check. While * the page lock ensures that the page is not reallocated to * another object, in particular, one with unmanaged mappings @@ -1236,7 +1237,13 @@ act_scan: * worst, we will deactivate and reactivate the page. */ if (m->object->ref_count != 0) - act_delta += pmap_ts_referenced(m); + act_delta = pmap_ts_referenced(m); + else + act_delta = 0; + if ((m->aflags & PGA_REFERENCED) != 0) { + vm_page_aflag_clear(m, PGA_REFERENCED); + act_delta++; + } /* * Advance or decay the act_count based on recent usage. @@ -1482,17 +1489,21 @@ recheck: * If the page has been referenced and the object is not dead, * reactivate or requeue the page depending on whether the * object is mapped. + * + * Test PGA_REFERENCED after calling pmap_ts_referenced() so + * that a reference from a concurrently destroyed mapping is + * observed here and now. */ - if ((m->aflags & PGA_REFERENCED) != 0) { - vm_page_aflag_clear(m, PGA_REFERENCED); - act_delta = 1; - } else - act_delta = 0; - if (object->ref_count != 0) { - act_delta += pmap_ts_referenced(m); - } else { + if (object->ref_count != 0) + act_delta = pmap_ts_referenced(m); + else { KASSERT(!pmap_page_is_mapped(m), ("page %p is mapped", m)); + act_delta = 0; + } + if ((m->aflags & PGA_REFERENCED) != 0) { + vm_page_aflag_clear(m, PGA_REFERENCED); + act_delta++; } if (act_delta != 0) { if (object->ref_count != 0) {