From owner-svn-src-all@FreeBSD.ORG Sun Oct 12 18:53:46 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 19BBFB1B; Sun, 12 Oct 2014 18:53:46 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 05C9EA9F; Sun, 12 Oct 2014 18:53:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9CIrjNh011618; Sun, 12 Oct 2014 18:53:45 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9CIrjF5011617; Sun, 12 Oct 2014 18:53:45 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201410121853.s9CIrjF5011617@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Sun, 12 Oct 2014 18:53:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r273007 - releng/10.1/sys/vm X-SVN-Group: releng 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.18-1 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: Sun, 12 Oct 2014 18:53:46 -0000 Author: alc Date: Sun Oct 12 18:53:45 2014 New Revision: 273007 URL: https://svnweb.freebsd.org/changeset/base/273007 Log: MFS: r272543 (r271351 on HEAD) Fix a boundary case error in vm_reserv_alloc_contig(). Approved by: re (kib) Modified: releng/10.1/sys/vm/vm_reserv.c Directory Properties: releng/10.1/ (props changed) Modified: releng/10.1/sys/vm/vm_reserv.c ============================================================================== --- releng/10.1/sys/vm/vm_reserv.c Sun Oct 12 18:01:52 2014 (r273006) +++ releng/10.1/sys/vm/vm_reserv.c Sun Oct 12 18:53:45 2014 (r273007) @@ -299,7 +299,7 @@ vm_reserv_populate(vm_reserv_t rv) /* * Allocates a contiguous set of physical pages of the given size "npages" - * from an existing or newly-created reservation. All of the physical pages + * from existing or newly created reservations. All of the physical pages * must be at or above the given physical address "low" and below the given * physical address "high". The given value "alignment" determines the * alignment of the first physical page in the set. If the given value @@ -371,8 +371,8 @@ vm_reserv_alloc_contig(vm_object_t objec /* * Could at least one reservation fit between the first index to the - * left that can be used and the first index to the right that cannot - * be used? + * left that can be used ("leftcap") and the first index to the right + * that cannot be used ("rightcap")? */ first = pindex - VM_RESERV_INDEX(object, pindex); if (mpred != NULL) { @@ -394,6 +394,13 @@ vm_reserv_alloc_contig(vm_object_t objec if (first + maxpages > rightcap) { if (maxpages == VM_LEVEL_0_NPAGES) return (NULL); + + /* + * At least one reservation will fit between "leftcap" + * and "rightcap". However, a reservation for the + * last of the requested pages will not fit. Reduce + * the size of the upcoming allocation accordingly. + */ allocpages = minpages; } } @@ -417,16 +424,23 @@ vm_reserv_alloc_contig(vm_object_t objec } /* - * Allocate and populate the new reservations. The alignment and - * boundary specified for this allocation may be different from the - * alignment and boundary specified for the requested pages. For - * instance, the specified index may not be the first page within the - * first new reservation. + * Allocate the physical pages. The alignment and boundary specified + * for this allocation may be different from the alignment and + * boundary specified for the requested pages. For instance, the + * specified index may not be the first page within the first new + * reservation. */ m = vm_phys_alloc_contig(allocpages, low, high, ulmax(alignment, VM_LEVEL_0_SIZE), boundary > VM_LEVEL_0_SIZE ? boundary : 0); if (m == NULL) return (NULL); + + /* + * The allocated physical pages always begin at a reservation + * boundary, but they do not always end at a reservation boundary. + * Initialize every reservation that is completely covered by the + * allocated physical pages. + */ m_ret = NULL; index = VM_RESERV_INDEX(object, pindex); do { @@ -456,7 +470,7 @@ vm_reserv_alloc_contig(vm_object_t objec m += VM_LEVEL_0_NPAGES; first += VM_LEVEL_0_NPAGES; allocpages -= VM_LEVEL_0_NPAGES; - } while (allocpages > 0); + } while (allocpages >= VM_LEVEL_0_NPAGES); return (m_ret); /*