From owner-svn-src-head@freebsd.org Thu Oct 1 16:40:00 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 DFEDEA0DC24; Thu, 1 Oct 2015 16:39:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB7AD1CFB; Thu, 1 Oct 2015 16:39:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id EB42FB913; Thu, 1 Oct 2015 12:39:57 -0400 (EDT) From: John Baldwin To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r288431 - in head/sys: kern sys vm Date: Thu, 01 Oct 2015 09:32:45 -0700 Message-ID: <1837187.vUDrWYExQX@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-PRERELEASE; KDE/4.14.3; amd64; ; ) In-Reply-To: <201509302306.t8UN6UwX043736@repo.freebsd.org> References: <201509302306.t8UN6UwX043736@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 01 Oct 2015 12:39:58 -0400 (EDT) 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: Thu, 01 Oct 2015 16:40:00 -0000 On Wednesday, September 30, 2015 11:06:30 PM Mark Johnston wrote: > Author: markj > Date: Wed Sep 30 23:06:29 2015 > New Revision: 288431 > URL: https://svnweb.freebsd.org/changeset/base/288431 > > Log: > As a step towards the elimination of PG_CACHED pages, rework the handling > of POSIX_FADV_DONTNEED so that it causes the backing pages to be moved to > the head of the inactive queue instead of being cached. > > This affects the implementation of POSIX_FADV_NOREUSE as well, since it > works by applying POSIX_FADV_DONTNEED to file ranges after they have been > read or written. At that point the corresponding buffers may still be > dirty, so the previous implementation would coalesce successive ranges and > apply POSIX_FADV_DONTNEED to the result, ensuring that pages backing the > dirty buffers would eventually be cached. To preserve this behaviour in an > efficient manner, this change adds a new buf flag, B_NOREUSE, which causes > the pages backing a VMIO buf to be placed at the head of the inactive queue > when the buf is released. POSIX_FADV_NOREUSE then works by setting this > flag in bufs that underlie the specified range. Putting these pages back on the inactive queue completely defeats the primary purpose of DONTNEED and NOREUSE. The primary purpose is to move the pages out of the VM object's tree of pages and into the free pool so that the application can instruct the VM to free memory more efficiently than relying on page daemon. The implementation used cache pages instead of free as a cheap optimization so that if an application did something dumb where it used DONTNEED and then turned around and read the file it would not have to go to disk if the pages had not yet been reused. In practice this didn't work out so well because PG_CACHE pages don't really work well. However, using PG_CACHE was secondary to the primary purpose of explicitly freeing memory that an application knew wasn't going to be reused and avoiding the need for pagedaemon to run at all. I think this should be freeing the pages instead of keeping them inactive. If an application uses DONTNEED or NOREUSE and then turns around and rereads the file, it generally deserves to have to go to disk for it. I'm pretty sure I had mentioned this to Alan before. I believe that the idea is that pagedaemon should be cheap enough that having it run anyway shouldn't be an issue, but I'm a bit skeptical of that. :) Lock contention is always possible and having DONTNEED/NOREUSE move pages to PG_CACHE avoided lock contention with pagedaemon during application page faults (since pagedaemon potentially never has to run). I believe that B_NOREUSE is definitely cleaner, btw. I had wanted to change NOREUSE to work that way but wasn't sure how to do it. -- John Baldwin