From owner-svn-src-head@freebsd.org Sat Mar 31 18:22:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1981AF75E98; Sat, 31 Mar 2018 18:22:32 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay114.isp.belgacom.be (mailrelay114.isp.belgacom.be [195.238.20.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 374B96FB21; Sat, 31 Mar 2018 18:22:29 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3AD9l1BRzwUtKbbSjXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?2uMeIJqq85mqBkHD//Il1AaPAd2Araocw8Pt8InYEVQa5piAtH1QOLdtbDQizf?= =?us-ascii?q?ssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1?= =?us-ascii?q?JuPoEYLOksi7ze+/94HdbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeu?= =?us-ascii?q?BWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbO?= =?us-ascii?q?SxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDtU7s6RSqt4LtqSB/wiS?= =?us-ascii?q?cIKTg58H3MisdtiK5XuQ+tqwBjz4LRZoyeKfhwcb7Hfd4CS2RPXthfWTFCDIy+?= =?us-ascii?q?YYsAAPYOM+lDoonhpVYCsQeyCRWwCO/xzDJDm3/43bc90+QkCQzIwg0gH9AKsH?= =?us-ascii?q?/Jstj1M6ASUfurw6nN1zrDaehW0ir65YjUcxAho/WMUKlwf8rL10YgCR7IgEie?= =?us-ascii?q?p4D/ODOVzOsNvnGd4uF9W+yvjGsnpBtwojip3soshJPJiZwLxV/f7iV23Zw5Jd?= =?us-ascii?q?qiSE50Z9OvDZhetzmCOoZ1X88uWX9ktSknxrEcp5K3YDYGxI46yxPfZfGKdZWD?= =?us-ascii?q?7Aj5W+aLOzh4gWpoeLe4hxmv70et0vb8Vsyo0FZSqSpFj8XMumgN1xPN7siHTe?= =?us-ascii?q?Nw/kS71jaL1gDT7/9LIVozlabBN54hw7wwlp4JvUvfGS/2n172g7GTdko+/Oio?= =?us-ascii?q?8P7rYrL8pp+TL4N0iwf+PboymsGnAuk0LxICU3aU9OihzrHv41H1TKtQgvErkq?= =?us-ascii?q?TUvojWJcEBqa64Bw9V3Jwj6xG6Dzq+zNQYnHsHLFZedRKJlYjmJU/BL+vjDfii?= =?us-ascii?q?mVisly1rx//eMr37HprNNmTDkKvmfbtl8E5c1gwzwclE55JOFr4NOfLzVVHru9?= =?us-ascii?q?PFFRI5PRa0zPj5B9pmzYMRRHiDAqiDMKPdqVWI/P4gI/GQZI8JvzbwM+Ml5+Do?= =?us-ascii?q?jXMggl8dZ7Wm0YINZ3C8GvRrOEuZYWDyjdgfCmgKpRcxQPbtiF2YXj5Zf2yyUL?= =?us-ascii?q?4k5jEnFIKmCp/ORpu3gLOdxSu0AppWZmVDClCNDXfoa5uLW+0XaC+JLM9hiCIL?= =?us-ascii?q?Wqa6RI86yB6irgj6y6BoLuDM4C0XqYrj1MRp5+3UjRwy8CZ7D96e02GPVGx0kH?= =?us-ascii?q?kISCEo069kukxy102P0a9ig/xXRpRv4KZsWx05fbzbz+phF9f0ElbEd82KSn6I?= =?us-ascii?q?WNirKwodCNUrzIldTVx6HoCejxLHlwGtBKQYkrWNH9Rg7qPe21DfPctw4U3qkq?= =?us-ascii?q?47gA91EYN0KWS6i/snpEDoDInTnhDczv7yeA=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AoDAAH0b9a/5nK8VFcHgEGDINCUw5vF?= =?us-ascii?q?ROMOowiAQGBczEBXZJTgXouhGEChCQiNRcBAgEBAQEBAQIBaiiCNyQBgkkBBSc?= =?us-ascii?q?THCMQCxQECSUPKh4GE4URC69RM4g6giYFiXSDXDSEb4VUApc6CIVRiFJli12JF?= =?us-ascii?q?YgNHQE2gVJNMAiCfYIgF44YPTCQBQEB?= X-IPAS-Result: =?us-ascii?q?A2AoDAAH0b9a/5nK8VFcHgEGDINCUw5vFROMOowiAQGBczE?= =?us-ascii?q?BXZJTgXouhGEChCQiNRcBAgEBAQEBAQIBaiiCNyQBgkkBBScTHCMQCxQECSUPK?= =?us-ascii?q?h4GE4URC69RM4g6giYFiXSDXDSEb4VUApc6CIVRiFJli12JFYgNHQE2gVJNMAi?= =?us-ascii?q?CfYIgF44YPTCQBQEB?= Received: from 153.202-241-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.241.202.153]) by relay.skynet.be with ESMTP; 31 Mar 2018 20:21:19 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id w2VILJ04001720; Sat, 31 Mar 2018 20:21:19 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Sat, 31 Mar 2018 20:21:18 +0200 From: Tijl Coosemans To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331732 - head/sys/vm Message-ID: <20180331202118.5401ed2a@kalimero.tijl.coosemans.org> In-Reply-To: <201803291427.w2TEReA3024929@repo.freebsd.org> References: <201803291427.w2TEReA3024929@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Sat, 31 Mar 2018 18:22:32 -0000 On Thu, 29 Mar 2018 14:27:40 +0000 (UTC) Mark Johnston wrote: > Author: markj > Date: Thu Mar 29 14:27:40 2018 > New Revision: 331732 > URL: https://svnweb.freebsd.org/changeset/base/331732 > > Log: > Fix the background laundering mechanism after r329882. > > Rather than using the number of inactive queue scans as a metric for > how many clean pages are being freed by the page daemon, have the > page daemon keep a running counter of the number of pages it has freed, > and have the laundry thread use that when computing the background > laundering threshold. > > Reviewed by: kib > Differential Revision: https://reviews.freebsd.org/D14884 > > Modified: > head/sys/vm/vm_pageout.c > head/sys/vm/vm_pagequeue.h > > Modified: head/sys/vm/vm_pageout.c > ============================================================================== > --- head/sys/vm/vm_pageout.c Thu Mar 29 13:55:23 2018 (r331731) > +++ head/sys/vm/vm_pageout.c Thu Mar 29 14:27:40 2018 (r331732) > @@ -943,8 +943,7 @@ vm_pageout_laundry_worker(void *arg) > { > struct vm_domain *vmd; > struct vm_pagequeue *pq; > - uint64_t nclean, ndirty; > - u_int inactq_scans, last_launder; > + uint64_t nclean, ndirty, nfreed; > int domain, last_target, launder, shortfall, shortfall_cycle, target; > bool in_shortfall; > > @@ -958,8 +957,7 @@ vm_pageout_laundry_worker(void *arg) > in_shortfall = false; > shortfall_cycle = 0; > target = 0; > - inactq_scans = 0; > - last_launder = 0; > + nfreed = 0; > > /* > * Calls to these handlers are serialized by the swap syscall lock. > @@ -1000,7 +998,6 @@ vm_pageout_laundry_worker(void *arg) > target = 0; > goto trybackground; > } > - last_launder = inactq_scans; > launder = target / shortfall_cycle--; > goto dolaundry; > > @@ -1009,24 +1006,23 @@ vm_pageout_laundry_worker(void *arg) > * meet the conditions to perform background laundering: > * > * 1. The ratio of dirty to clean inactive pages exceeds the > - * background laundering threshold and the pagedaemon has > - * been woken up to reclaim pages since our last > - * laundering, or > + * background laundering threshold, 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 scans since the last laundering. Thus, as the > - * ratio of dirty to clean inactive pages grows, the amount of > - * memory pressure required to trigger laundering decreases. > + * clean pages freed by the page daemon since the last > + * background laundering. Thus, as the ratio of dirty to > + * clean inactive pages grows, the amount of memory pressure > + * required to trigger laundering decreases. > */ > trybackground: > nclean = vmd->vmd_free_count + > vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt; > ndirty = vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt; > - if (target == 0 && inactq_scans != last_launder && > - ndirty * isqrt(inactq_scans - last_launder) >= nclean) { > + if (target == 0 && ndirty * isqrt(nfreed / > + (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { I'm seeing big processes being killed with an "out of swap space" message even though there's still plenty of swap available. It seems to be fixed by making this division round upwards: if (target == 0 && ndirty * isqrt((nfreed + (vmd->vmd_free_target - vmd->vmd_free_min) - 1) / (vmd->vmd_free_target - vmd->vmd_free_min)) >= nclean) { I don't know where this formula comes from, so I don't know if this change is correct.