From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 29 17:21:20 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D2571065672; Fri, 29 Jun 2012 17:21:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E9D88FC18; Fri, 29 Jun 2012 17:21:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5THLJmI058919; Fri, 29 Jun 2012 17:21:19 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5THLJ37058915; Fri, 29 Jun 2012 17:21:19 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201206291721.q5THLJ37058915@svn.freebsd.org> From: John Baldwin Date: Fri, 29 Jun 2012 17:21:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237805 - stable/9/sys/vm X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2012 17:21:20 -0000 Author: jhb Date: Fri Jun 29 17:21:19 2012 New Revision: 237805 URL: http://svn.freebsd.org/changeset/base/237805 Log: MFC 233191: Fix madvise(MADV_WILLNEED) to properly handle individual mappings larger than 4GB. Specifically, the inlined version of 'ptoa' of the the 'int' count of pages overflowed on 64-bit platforms. While here, change vm_object_madvise() to accept two vm_pindex_t parameters (start and end) rather than a (start, count) tuple to match other VM APIs as suggested by alc@. Modified: stable/9/sys/vm/vm_map.c stable/9/sys/vm/vm_object.c stable/9/sys/vm/vm_object.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/vm/vm_map.c ============================================================================== --- stable/9/sys/vm/vm_map.c Fri Jun 29 17:12:26 2012 (r237804) +++ stable/9/sys/vm/vm_map.c Fri Jun 29 17:21:19 2012 (r237805) @@ -2105,8 +2105,7 @@ vm_map_madvise( } vm_map_unlock(map); } else { - vm_pindex_t pindex; - int count; + vm_pindex_t pstart, pend; /* * madvise behaviors that are implemented in the underlying @@ -2124,30 +2123,29 @@ vm_map_madvise( if (current->eflags & MAP_ENTRY_IS_SUB_MAP) continue; - pindex = OFF_TO_IDX(current->offset); - count = atop(current->end - current->start); + pstart = OFF_TO_IDX(current->offset); + pend = pstart + atop(current->end - current->start); useStart = current->start; if (current->start < start) { - pindex += atop(start - current->start); - count -= atop(start - current->start); + pstart += atop(start - current->start); useStart = start; } if (current->end > end) - count -= atop(current->end - end); + pend -= atop(current->end - end); - if (count <= 0) + if (pstart >= pend) continue; - vm_object_madvise(current->object.vm_object, - pindex, count, behav); + vm_object_madvise(current->object.vm_object, pstart, + pend, behav); if (behav == MADV_WILLNEED) { vm_map_pmap_enter(map, useStart, current->protection, current->object.vm_object, - pindex, - (count << PAGE_SHIFT), + pstart, + ptoa(pend - pstart), MAP_PREFAULT_MADVISE ); } Modified: stable/9/sys/vm/vm_object.c ============================================================================== --- stable/9/sys/vm/vm_object.c Fri Jun 29 17:12:26 2012 (r237804) +++ stable/9/sys/vm/vm_object.c Fri Jun 29 17:21:19 2012 (r237805) @@ -1064,16 +1064,16 @@ vm_object_sync(vm_object_t object, vm_oo * without I/O. */ void -vm_object_madvise(vm_object_t object, vm_pindex_t pindex, int count, int advise) +vm_object_madvise(vm_object_t object, vm_pindex_t pindex, vm_pindex_t end, + int advise) { - vm_pindex_t end, tpindex; + vm_pindex_t tpindex; vm_object_t backing_object, tobject; vm_page_t m; if (object == NULL) return; VM_OBJECT_LOCK(object); - end = pindex + count; /* * Locate and adjust resident pages */ Modified: stable/9/sys/vm/vm_object.h ============================================================================== --- stable/9/sys/vm/vm_object.h Fri Jun 29 17:12:26 2012 (r237804) +++ stable/9/sys/vm/vm_object.h Fri Jun 29 17:21:19 2012 (r237805) @@ -226,6 +226,7 @@ void vm_object_destroy (vm_object_t); void vm_object_terminate (vm_object_t); void vm_object_set_writeable_dirty (vm_object_t); void vm_object_init (void); +void vm_object_madvise(vm_object_t, vm_pindex_t, vm_pindex_t, int); void vm_object_page_cache(vm_object_t object, vm_pindex_t start, vm_pindex_t end); boolean_t vm_object_page_clean(vm_object_t object, vm_ooffset_t start, @@ -241,7 +242,6 @@ void vm_object_shadow (vm_object_t *, vm void vm_object_split(vm_map_entry_t); boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t, boolean_t); -void vm_object_madvise (vm_object_t, vm_pindex_t, int, int); #endif /* _KERNEL */ #endif /* _VM_OBJECT_ */