From owner-svn-src-head@freebsd.org Sun Mar 19 19:52:48 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 AF09DD13A94; Sun, 19 Mar 2017 19:52:48 +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 mx1.freebsd.org (Postfix) with ESMTPS id 6254812DC; Sun, 19 Mar 2017 19:52:48 +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 v2JJqleq001386; Sun, 19 Mar 2017 19:52:47 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2JJqlQl001385; Sun, 19 Mar 2017 19:52:47 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201703191952.v2JJqlQl001385@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Sun, 19 Mar 2017 19:52:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315580 - head/sys/vm X-SVN-Group: head 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: Sun, 19 Mar 2017 19:52:48 -0000 Author: alc Date: Sun Mar 19 19:52:47 2017 New Revision: 315580 URL: https://svnweb.freebsd.org/changeset/base/315580 Log: Two changes to vm_fault_populate(): Simplify the logic for clipping the range returned by the pager to fit within the map entry. Use atop() rather than OFF_TO_IDX() on addresses. Reviewed by: kib MFC after: 1 week Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Mar 19 19:11:40 2017 (r315579) +++ head/sys/vm/vm_fault.c Sun Mar 19 19:52:47 2017 (r315580) @@ -352,8 +352,7 @@ vm_fault_populate(struct faultstate *fs, MPASS(fs->lookup_still_valid); pager_first = OFF_TO_IDX(fs->entry->offset); - pager_last = OFF_TO_IDX(fs->entry->offset + fs->entry->end - - fs->entry->start) - 1; + pager_last = pager_first + atop(fs->entry->end - fs->entry->start) - 1; unlock_map(fs); unlock_vp(fs); @@ -404,18 +403,20 @@ vm_fault_populate(struct faultstate *fs, * In case the pager expanded the range, clip it to fit into * the map entry. */ - map_first = MAX(OFF_TO_IDX(fs->entry->offset), pager_first); - if (map_first > pager_first) + map_first = OFF_TO_IDX(fs->entry->offset); + if (map_first > pager_first) { vm_fault_populate_cleanup(fs->first_object, pager_first, map_first - 1); - map_last = MIN(OFF_TO_IDX(fs->entry->end - fs->entry->start + - fs->entry->offset) - 1, pager_last); - if (map_last < pager_last) + pager_first = map_first; + } + map_last = map_first + atop(fs->entry->end - fs->entry->start) - 1; + if (map_last < pager_last) { vm_fault_populate_cleanup(fs->first_object, map_last + 1, pager_last); - - for (pidx = map_first, m = vm_page_lookup(fs->first_object, pidx); - pidx <= map_last; pidx++, m = vm_page_next(m)) { + pager_last = map_last; + } + for (pidx = pager_first, m = vm_page_lookup(fs->first_object, pidx); + pidx <= pager_last; pidx++, m = vm_page_next(m)) { vm_fault_populate_check_page(m); vm_fault_dirty(fs->entry, m, prot, fault_type, fault_flags, true);