From owner-svn-src-head@freebsd.org Wed Sep 23 07:17:37 2015 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 ACC7FA06A5A for ; Wed, 23 Sep 2015 07:17:37 +0000 (UTC) (envelope-from scott4long@yahoo.com) Received: from nm45-vm1.bullet.mail.gq1.yahoo.com (nm45-vm1.bullet.mail.gq1.yahoo.com [67.195.87.87]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8148B1828 for ; Wed, 23 Sep 2015 07:17:37 +0000 (UTC) (envelope-from scott4long@yahoo.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1442992650; bh=j1PCYCUG//Nq4/2uNTilttYwHpQIJ3hKr4bUssn86pw=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From:Subject; b=n6JKPh6Pql8inAZ3uggH625Zn95gVO83hjVdF7RgDo7ojMD2vFG5OwMXBdSjvE6u1rFL1WKoMJhmTk2btckFocvJqwoQiYMjfqLfY+yUfYD0m1oPdFn0AQ++1k68wUfEuqkDLePmOuunl3SNL6s59tYmMDtZspL+5Esx9ZViotcbHz5RzZnlthw2yVZ0zRj66GmX/iRhjaYL80V38CIPdAdxnxBDwtLQ47Bugc2CnLfJArc9Xfib9Kvp6dl1n9VYGWYqQATMERfW/NdaFsg+CRi+uhBJYm34M5jwgAwfFq/DLlDJtuIshPYM6MaVMnJAoKXyD3g86FkW0G+OKpuLaw== Received: from [127.0.0.1] by nm45.bullet.mail.gq1.yahoo.com with NNFMP; 23 Sep 2015 07:17:30 -0000 Received: from [98.137.12.56] by nm45.bullet.mail.gq1.yahoo.com with NNFMP; 23 Sep 2015 07:14:48 -0000 Received: from [208.71.42.202] by tm1.bullet.mail.gq1.yahoo.com with NNFMP; 23 Sep 2015 07:14:48 -0000 Received: from [127.0.0.1] by smtp213.mail.gq1.yahoo.com with NNFMP; 23 Sep 2015 07:14:48 -0000 X-Yahoo-Newman-Id: 109284.35164.bm@smtp213.mail.gq1.yahoo.com X-Yahoo-Newman-Property: ymail-4 X-YMail-OSG: UaM8eS8VM1lvACUJwgSJEp2pkR4wKTGlLMuW5aiDorEo4R0 3aLqmyAUpLX7BqwS2mYYy1TSt53jlZaq.6JeVUcNyJK5Yz0ZsZlvJAiLZ.nR _bQ6d79XIIuiHVij.8.Z2bIuBkdgAUk.UxYQEys08fXm40tAEdSSeyqH1SzD hF5XZAR15yW.ar33eoOK_0XFk9CcSMaFz0mP1huMvEfSnvkvaRYiB4p21i69 Z7QYTrRUJActYG_lAxfgJHazQcLTqOITejZ.y224TW2PQU4psWA2pUZb5X2S 6LOR5EBJkxrqZi5lzXim0pqCcEmYzi0bO3E_M1UR3CwFdZGnKRdTyplnpydn ujnVC7FzFlgsmi5rDyeT60eUJo185UMcwiCSw._7MtTWoXhFJLHos6T.m1hK Rb4qbTQdIt9LS0spH5FNo1vzJUwH5.dQwHDwTZ8tZjpTol9pejASTvNUQktJ 6ytBP6R_3pwd86L_eMMkitIp6frwBhGZ58fZ9hlgbOq1ZOksj1xisLWnlqGP a6TThHp5dMvUUFcf4DhmNPlBC_lmwPyRVzmG2_Xh.0QbA6Md8pv3DMQ-- X-Yahoo-SMTP: clhABp.swBB7fs.LwIJpv3jkWgo2NU8- Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: svn commit: r288122 - in head/sys: kern vm From: Scott Long In-Reply-To: <201509221816.t8MIGqxV069276@repo.freebsd.org> Date: Wed, 23 Sep 2015 00:14:45 -0700 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <04359280-61C0-4A59-AF04-54FA3D4F98C3@yahoo.com> References: <201509221816.t8MIGqxV069276@repo.freebsd.org> To: Alan Cox X-Mailer: Apple Mail (2.2104) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 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: Wed, 23 Sep 2015 07:17:37 -0000 It should be noted that Netflix has been running with an earlier version = of this patch for nearly 10 months. Scott > On Sep 22, 2015, at 11:16 AM, Alan Cox wrote: >=20 > Author: alc > Date: Tue Sep 22 18:16:52 2015 > New Revision: 288122 > URL: https://svnweb.freebsd.org/changeset/base/288122 >=20 > Log: > Change vm_page_unwire() such that it (1) accepts PQ_NONE as the = specified > queue and (2) returns a Boolean indicating whether the page's wire = count > transitioned to zero. >=20 > Exploit this change in vfs_vmio_release() to avoid pointlessly = enqueueing > a page that is about to be freed. >=20 > (An earlier version of this change was developed by attilio@ and = kmacy@. > Any errors in this version are my own.) >=20 > Reviewed by: kib > Sponsored by: EMC / Isilon Storage Division >=20 > Modified: > head/sys/kern/vfs_bio.c > head/sys/vm/vm_page.c > head/sys/vm/vm_page.h >=20 > Modified: head/sys/kern/vfs_bio.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/kern/vfs_bio.c Tue Sep 22 17:34:51 2015 = (r288121) > +++ head/sys/kern/vfs_bio.c Tue Sep 22 18:16:52 2015 = (r288122) > @@ -2076,6 +2076,7 @@ vfs_vmio_release(struct buf *bp) > vm_object_t obj; > vm_page_t m; > int i; > + bool freed; >=20 > if (buf_mapped(bp)) { > BUF_CHECK_MAPPED(bp); > @@ -2088,23 +2089,28 @@ vfs_vmio_release(struct buf *bp) > for (i =3D 0; i < bp->b_npages; i++) { > m =3D bp->b_pages[i]; > bp->b_pages[i] =3D NULL; > - /* > - * In order to keep page LRU ordering consistent, put > - * everything on the inactive queue. > - */ > vm_page_lock(m); > - vm_page_unwire(m, PQ_INACTIVE); > - > - /* > - * Might as well free the page if we can and it has > - * no valid data. We also free the page if the > - * buffer was used for direct I/O > - */ > - if ((bp->b_flags & B_ASYNC) =3D=3D 0 && !m->valid) { > - if (m->wire_count =3D=3D 0 && = !vm_page_busied(m)) > - vm_page_free(m); > - } else if (bp->b_flags & B_DIRECT) > - vm_page_try_to_free(m); > + if (vm_page_unwire(m, PQ_NONE)) { > + /* > + * Determine if the page should be freed before = adding > + * it to the inactive queue. > + */ > + if ((bp->b_flags & B_ASYNC) =3D=3D 0 && m->valid = =3D=3D 0) { > + freed =3D !vm_page_busied(m); > + if (freed) > + vm_page_free(m); > + } else if ((bp->b_flags & B_DIRECT) !=3D 0) > + freed =3D vm_page_try_to_free(m); > + else > + freed =3D false; > + if (!freed) { > + /* > + * In order to maintain LRU page = ordering, put > + * the page at the tail of the inactive = queue. > + */ > + vm_page_deactivate(m); > + } > + } > vm_page_unlock(m); > } > if (obj !=3D NULL) >=20 > Modified: head/sys/vm/vm_page.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/vm/vm_page.c Tue Sep 22 17:34:51 2015 = (r288121) > +++ head/sys/vm/vm_page.c Tue Sep 22 18:16:52 2015 = (r288122) > @@ -2476,42 +2476,46 @@ vm_page_wire(vm_page_t m) > /* > * vm_page_unwire: > * > - * Release one wiring of the specified page, potentially enabling it = to be > - * paged again. If paging is enabled, then the value of the = parameter > - * "queue" determines the queue to which the page is added. > - * > - * However, unless the page belongs to an object, it is not enqueued = because > - * it cannot be paged out. > + * Release one wiring of the specified page, potentially allowing it = to be > + * paged out. Returns TRUE if the number of wirings transitions to = zero and > + * FALSE otherwise. > + * > + * Only managed pages belonging to an object can be paged out. If = the number > + * of wirings transitions to zero and the page is eligible for page = out, then > + * the page is added to the specified paging queue (unless PQ_NONE is > + * specified). > * > * If a page is fictitious, then its wire count must always be one. > * > * A managed page must be locked. > */ > -void > +boolean_t > vm_page_unwire(vm_page_t m, uint8_t queue) > { >=20 > - KASSERT(queue < PQ_COUNT, > + KASSERT(queue < PQ_COUNT || queue =3D=3D PQ_NONE, > ("vm_page_unwire: invalid queue %u request for page %p", > queue, m)); > if ((m->oflags & VPO_UNMANAGED) =3D=3D 0) > - vm_page_lock_assert(m, MA_OWNED); > + vm_page_assert_locked(m); > if ((m->flags & PG_FICTITIOUS) !=3D 0) { > KASSERT(m->wire_count =3D=3D 1, > ("vm_page_unwire: fictitious page %p's wire count isn't = one", m)); > - return; > + return (FALSE); > } > if (m->wire_count > 0) { > m->wire_count--; > if (m->wire_count =3D=3D 0) { > atomic_subtract_int(&vm_cnt.v_wire_count, 1); > - if ((m->oflags & VPO_UNMANAGED) !=3D 0 || > - m->object =3D=3D NULL) > - return; > - if (queue =3D=3D PQ_INACTIVE) > - m->flags &=3D ~PG_WINATCFLS; > - vm_page_enqueue(queue, m); > - } > + if ((m->oflags & VPO_UNMANAGED) =3D=3D 0 && > + m->object !=3D NULL && queue !=3D PQ_NONE) { > + if (queue =3D=3D PQ_INACTIVE) > + m->flags &=3D ~PG_WINATCFLS; > + vm_page_enqueue(queue, m); > + } > + return (TRUE); > + } else > + return (FALSE); > } else > panic("vm_page_unwire: page %p's wire count is zero", = m); > } >=20 > Modified: head/sys/vm/vm_page.h > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/vm/vm_page.h Tue Sep 22 17:34:51 2015 = (r288121) > +++ head/sys/vm/vm_page.h Tue Sep 22 18:16:52 2015 = (r288122) > @@ -480,7 +480,7 @@ vm_offset_t vm_page_startup(vm_offset_t=20 > void vm_page_sunbusy(vm_page_t m); > int vm_page_trysbusy(vm_page_t m); > void vm_page_unhold_pages(vm_page_t *ma, int count); > -void vm_page_unwire (vm_page_t m, uint8_t queue); > +boolean_t vm_page_unwire(vm_page_t m, uint8_t queue); > void vm_page_updatefake(vm_page_t m, vm_paddr_t paddr, vm_memattr_t = memattr); > void vm_page_wire (vm_page_t); > void vm_page_xunbusy_hard(vm_page_t m); >=20