From owner-svn-src-user@freebsd.org Fri Aug 19 04:21:18 2016 Return-Path: Delivered-To: svn-src-user@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 43ACABBD3E6 for ; Fri, 19 Aug 2016 04:21:18 +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 EED7713BA; Fri, 19 Aug 2016 04:21:17 +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 u7J4LHxT022807; Fri, 19 Aug 2016 04:21:17 GMT (envelope-from alc@FreeBSD.org) Received: (from alc@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7J4LHdc022806; Fri, 19 Aug 2016 04:21:17 GMT (envelope-from alc@FreeBSD.org) Message-Id: <201608190421.u7J4LHdc022806@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: alc set sender to alc@FreeBSD.org using -f From: Alan Cox Date: Fri, 19 Aug 2016 04:21:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r304442 - user/alc/PQ_LAUNDRY/sys/vm X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2016 04:21:18 -0000 Author: alc Date: Fri Aug 19 04:21:16 2016 New Revision: 304442 URL: https://svnweb.freebsd.org/changeset/base/304442 Log: Replace the constant "bkgrd_launder_ratio" by a slowly growing function of the number of wakeups since the last laundering. Discussed with: markj Modified: user/alc/PQ_LAUNDRY/sys/vm/vm_pageout.c Modified: user/alc/PQ_LAUNDRY/sys/vm/vm_pageout.c ============================================================================== --- user/alc/PQ_LAUNDRY/sys/vm/vm_pageout.c Fri Aug 19 03:32:04 2016 (r304441) +++ user/alc/PQ_LAUNDRY/sys/vm/vm_pageout.c Fri Aug 19 04:21:16 2016 (r304442) @@ -231,11 +231,6 @@ SYSCTL_INT(_vm, OID_AUTO, act_scan_laund CTLFLAG_RW, &act_scan_laundry_weight, 0, "weight given to clean vs. dirty pages in active queue scans"); -static u_int bkgrd_launder_ratio = 50; -SYSCTL_UINT(_vm, OID_AUTO, bkgrd_launder_ratio, - CTLFLAG_RW, &bkgrd_launder_ratio, 0, - "ratio of clean to dirty inactive pages needed to trigger laundering"); - static u_int bkgrd_launder_max = 2048; SYSCTL_UINT(_vm, OID_AUTO, bkgrd_launder_max, CTLFLAG_RW, &bkgrd_launder_max, 0, @@ -248,6 +243,7 @@ int vm_page_max_wired; /* XXX max # of SYSCTL_INT(_vm, OID_AUTO, max_wired, CTLFLAG_RW, &vm_page_max_wired, 0, "System-wide limit to wired page count"); +static u_int isqrt(u_int num); static boolean_t vm_pageout_fallback_object_lock(vm_page_t, vm_page_t *); static int vm_pageout_launder(struct vm_domain *vmd, int launder, bool shortfall); @@ -1067,6 +1063,30 @@ relock_queue: } /* + * Compute the integer square root. + */ +static u_int +isqrt(u_int num) +{ + u_int bit, root, tmp; + + bit = 1u << ((NBBY * sizeof(u_int)) - 2); + while (bit > num) + bit >>= 2; + root = 0; + while (bit != 0) { + tmp = root + bit; + root >>= 1; + if (num >= tmp) { + num -= tmp; + root += bit; + } + bit >>= 2; + } + return (root); +} + +/* * Perform the work of the laundry thread: periodically wake up and determine * whether any pages need to be laundered. If so, determine the number of pages * that need to be laundered, and launder them. @@ -1143,11 +1163,15 @@ vm_pageout_laundry_worker(void *arg) * recently been woken up, or * 2. we haven't yet reached the target of the current * background laundering run. + * + * The background laundering threshold is not a constant. + * Instead, it is a slowly growing function of the number of + * page daemon wakeups since the last laundering. */ ninact = vm_cnt.v_inactive_count + vm_cnt.v_free_count; nlaundry = vm_cnt.v_laundry_count; if (target == 0 && wakeups != gen && - nlaundry * bkgrd_launder_ratio >= ninact) { + nlaundry * isqrt(wakeups - gen) >= ninact) { gen = wakeups; /*