From owner-freebsd-hackers@FreeBSD.ORG Tue Sep 7 14:29:44 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D190510656CA for ; Tue, 7 Sep 2010 14:29:44 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from argol.doit.wisc.edu (argol.doit.wisc.edu [144.92.197.212]) by mx1.freebsd.org (Postfix) with ESMTP id A1FB08FC12 for ; Tue, 7 Sep 2010 14:29:44 +0000 (UTC) MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_9Kg2DhUa2PtRVOyOKbWdzw)" Received: from avs-daemon.smtpauth3.wiscmail.wisc.edu by smtpauth3.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) id <0L8D00A4US9BW600@smtpauth3.wiscmail.wisc.edu> for freebsd-hackers@freebsd.org; Tue, 07 Sep 2010 09:29:35 -0500 (CDT) Received: from comporellon.tachypleus.net ([unknown] [76.210.68.10]) by smtpauth3.wiscmail.wisc.edu (Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30 2009)) with ESMTPSA id <0L8D0050WS969H70@smtpauth3.wiscmail.wisc.edu> for freebsd-hackers@freebsd.org; Tue, 07 Sep 2010 09:29:31 -0500 (CDT) Date: Tue, 07 Sep 2010 09:29:30 -0500 From: Nathan Whitehorn In-reply-to: <4C85B081.3040100@freebsd.org> To: freebsd-hackers@freebsd.org Message-id: <4C864C4A.2050600@freebsd.org> X-Spam-Report: AuthenticatedSender=yes, SenderIP=76.210.68.10 X-Spam-PmxInfo: Server=avs-11, Version=5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2010.9.7.141814, SenderIP=76.210.68.10 X-Enigmail-Version: 1.0.1 References: <4C8593E1.5080000@freebsd.org> <4C85B081.3040100@freebsd.org> User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.1.11) Gecko/20100729 Thunderbird/3.0.6 Subject: Re: PS3 livelock and pmap_remove() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2010 14:29:45 -0000 This is a multi-part message in MIME format. --Boundary_(ID_9Kg2DhUa2PtRVOyOKbWdzw) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT On 09/06/10 22:24, Nathan Whitehorn wrote: > On 09/06/10 20:22, Nathan Whitehorn wrote: > >> Now that my SLB allocation issue is solved, with help with Matthew and >> Alan, I have another VM puzzler. >> >> I have a simple program that tries to use all the memory on the system, >> which isn't very much on the PS3, so I use it to test swap as well. >> Shortly after it begins paging, the system locks up completely. I >> managed to duplicate this behavior on an emulator, and found out what it >> is actually doing. Somehow pmap_remove() is being called with arguments >> pmap_remove(userpmap, PAGE_SIZE, VM_MAXUSER_ADDRESS = USRSTACK). For >> powerpc64, VM_MAXUSER_ADDRESS is 0x7ffffffffffff000, so there are 10^15 >> pages to unmap in that range and it was busy taking until the end of >> time unmapping them all. >> >> Here's the trace from KDB: >> >> moea64_remove() >> pmap_remove() >> vm_daemon() >> fork_exit() >> fork_trampoline() >> ----end----- >> >> Does anyone have any idea why this is happening? >> >> >> > The culprit here is lines 703-706 of vm/vm_pageout.c: > > if (desired == 0 && nothingwired) { > pmap_remove(vm_map_pmap(map), vm_map_min(map), > vm_map_max(map)); > } > > It would be much better if it did this in sections, the way > vm_map_delete does. I'll take a crack at this, though any suggestions > for proper implementation would be appreciated. > -nathan > I've attached a patch that reimplements this by unmapping each map_entry separately, which solves the problem on PowerPC and I believe is functionally equivalent. My PS3 successfully completes a buildworld with this patch. Are there any objections to me committing it? -Nathan --Boundary_(ID_9Kg2DhUa2PtRVOyOKbWdzw) Content-type: text/plain; name=vm-pageout.diff Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=vm-pageout.diff Index: vm/vm_pageout.c =================================================================== --- vm/vm_pageout.c (revision 212277) +++ vm/vm_pageout.c (working copy) @@ -701,8 +701,11 @@ * table pages. */ if (desired == 0 && nothingwired) { - pmap_remove(vm_map_pmap(map), vm_map_min(map), - vm_map_max(map)); + tmpe = map->header.next; + while (tmpe != &map->header) { + pmap_remove(vm_map_pmap(map), tmpe->start, tmpe->end); + tmpe = tmpe->next; + } } vm_map_unlock(map); } --Boundary_(ID_9Kg2DhUa2PtRVOyOKbWdzw)--