From owner-svn-src-head@freebsd.org Mon Jan 1 19:27:34 2018 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 A1425EB8BBB; Mon, 1 Jan 2018 19:27:34 +0000 (UTC) (envelope-from kib@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 6C0B079208; Mon, 1 Jan 2018 19:27:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w01JRXrQ005676; Mon, 1 Jan 2018 19:27:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w01JRXxp005675; Mon, 1 Jan 2018 19:27:33 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801011927.w01JRXxp005675@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 1 Jan 2018 19:27:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327468 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 327468 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Mon, 01 Jan 2018 19:27:34 -0000 Author: kib Date: Mon Jan 1 19:27:33 2018 New Revision: 327468 URL: https://svnweb.freebsd.org/changeset/base/327468 Log: Do not let vm_daemon run unbounded. On a load where single anonymous object consumes almost all memory on the large system, swapout code executes the iteration over the corresponding object page queue for long time, owning the map and object locks. This blocks pagedaemon which tries to lock the object, and blocks other threads in the process in vm_fault() waiting for the map lock. Handle the issue by terminating the deactivation loop if we executed too long and by yielding at the top level in vm_daemon. Reported by: peterj, pho Reviewed by: alc Tested by: pho (as part of the larger patch) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D13671 Modified: head/sys/vm/vm_swapout.c Modified: head/sys/vm/vm_swapout.c ============================================================================== --- head/sys/vm/vm_swapout.c Mon Jan 1 19:04:40 2018 (r327467) +++ head/sys/vm/vm_swapout.c Mon Jan 1 19:27:33 2018 (r327468) @@ -203,6 +203,8 @@ vm_swapout_object_deactivate_pages(pmap_t pmap, vm_obj TAILQ_FOREACH(p, &object->memq, listq) { if (pmap_resident_count(pmap) <= desired) goto unlock_return; + if (should_yield()) + goto unlock_return; if (vm_page_busied(p)) continue; VM_CNT_INC(v_pdpages); @@ -516,8 +518,10 @@ again: PRELE(p); } sx_sunlock(&allproc_lock); - if (tryagain != 0 && attempts <= 10) + if (tryagain != 0 && attempts <= 10) { + maybe_yield(); goto again; + } } }