From owner-svn-src-head@freebsd.org Thu Jan 23 05:23:37 2020 Return-Path: Delivered-To: svn-src-head@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 C2C9322CE36; Thu, 23 Jan 2020 05:23:37 +0000 (UTC) (envelope-from jeff@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 4839fd4jx3z47TB; Thu, 23 Jan 2020 05:23:37 +0000 (UTC) (envelope-from jeff@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 82FEF9A3A; Thu, 23 Jan 2020 05:23:37 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00N5Nbq0078487; Thu, 23 Jan 2020 05:23:37 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00N5NbbB078486; Thu, 23 Jan 2020 05:23:37 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <202001230523.00N5NbbB078486@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Thu, 23 Jan 2020 05:23:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357028 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 357028 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.29 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: Thu, 23 Jan 2020 05:23:37 -0000 Author: jeff Date: Thu Jan 23 05:23:37 2020 New Revision: 357028 URL: https://svnweb.freebsd.org/changeset/base/357028 Log: (fault 9/9) Move zero fill into a dedicated function to make the object lock state more clear. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23326 Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Thu Jan 23 05:22:02 2020 (r357027) +++ head/sys/vm/vm_fault.c Thu Jan 23 05:23:37 2020 (r357028) @@ -960,35 +960,8 @@ vm_fault_next(struct faultstate *fs) */ VM_OBJECT_ASSERT_WLOCKED(fs->object); next_object = fs->object->backing_object; - if (next_object == NULL) { - /* - * If there's no object left, fill the page in the top - * object with zeros. - */ - VM_OBJECT_WUNLOCK(fs->object); - if (fs->object != fs->first_object) { - vm_object_pip_wakeup(fs->object); - fs->object = fs->first_object; - fs->pindex = fs->first_pindex; - } - MPASS(fs->first_m != NULL); - MPASS(fs->m == NULL); - fs->m = fs->first_m; - fs->first_m = NULL; - - /* - * Zero the page if necessary and mark it valid. - */ - if ((fs->m->flags & PG_ZERO) == 0) { - pmap_zero_page(fs->m); - } else { - VM_CNT_INC(v_ozfod); - } - VM_CNT_INC(v_zfod); - vm_page_valid(fs->m); - + if (next_object == NULL) return (false); - } MPASS(fs->first_m != NULL); KASSERT(fs->object != next_object, ("object loop %p", next_object)); VM_OBJECT_WLOCK(next_object); @@ -1002,6 +975,36 @@ vm_fault_next(struct faultstate *fs) return (true); } +static void +vm_fault_zerofill(struct faultstate *fs) +{ + + /* + * If there's no object left, fill the page in the top + * object with zeros. + */ + if (fs->object != fs->first_object) { + vm_object_pip_wakeup(fs->object); + fs->object = fs->first_object; + fs->pindex = fs->first_pindex; + } + MPASS(fs->first_m != NULL); + MPASS(fs->m == NULL); + fs->m = fs->first_m; + fs->first_m = NULL; + + /* + * Zero the page if necessary and mark it valid. + */ + if ((fs->m->flags & PG_ZERO) == 0) { + pmap_zero_page(fs->m); + } else { + VM_CNT_INC(v_ozfod); + } + VM_CNT_INC(v_zfod); + vm_page_valid(fs->m); +} + /* * Allocate a page directly or via the object populate method. */ @@ -1407,11 +1410,13 @@ RetryFault: * traverse into a backing object or zero fill if none is * found. */ - if (!vm_fault_next(&fs)) { - /* Don't try to prefault neighboring pages. */ - faultcount = 1; - break; /* break to PAGE HAS BEEN FOUND. */ - } + if (vm_fault_next(&fs)) + continue; + VM_OBJECT_WUNLOCK(fs.object); + vm_fault_zerofill(&fs); + /* Don't try to prefault neighboring pages. */ + faultcount = 1; + break; /* break to PAGE HAS BEEN FOUND. */ } /*