From owner-freebsd-stable@FreeBSD.ORG Wed Apr 25 14:47:03 2007 Return-Path: X-Original-To: freebsd-stable@FreeBSD.ORG Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 57B6316A400 for ; Wed, 25 Apr 2007 14:47:03 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.freebsd.org (Postfix) with ESMTP id E341A13C468 for ; Wed, 25 Apr 2007 14:47:02 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (ixstoj@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id l3PEkuGH062064; Wed, 25 Apr 2007 16:47:01 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id l3PEkuS4062063; Wed, 25 Apr 2007 16:46:56 +0200 (CEST) (envelope-from olli) Date: Wed, 25 Apr 2007 16:46:56 +0200 (CEST) Message-Id: <200704251446.l3PEkuS4062063@lurza.secnetix.de> From: Oliver Fromme To: freebsd-stable@FreeBSD.ORG, harry@schmalzbauer.de In-Reply-To: <200704240932.06435.harry@schmalzbauer.de> X-Newsgroups: list.freebsd-stable User-Agent: tin/1.8.2-20060425 ("Shillay") (UNIX) (FreeBSD/4.11-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Wed, 25 Apr 2007 16:47:01 +0200 (CEST) Cc: Subject: Re: question: +swap_pager_getswapspace(16): failed X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-stable@FreeBSD.ORG, harry@schmalzbauer.de List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2007 14:47:03 -0000 Harald Schmalzbauer wrote: > I have a little understanding problem: > My box has 128MB memory, far enough for the task. Are you sure? I see you're running perl scripts. Those can easily (and sometimes unexpectedly) eat a lot of memory. > After a few days I always see some processes dying because: > > +swap_pager_getswapspace(2): failed > +pid 48211 (perl5.8.8), uid 58, was killed: out of swap space AFAIK, the kernel selects the largest process for killing when it runs out of swap. So your perl was probably quite large. > Why won't for example the 21MB Buf get freed before more swap space gets > requested than available (swap is very low, it's FlashDisk!)? > Is there a way to find out what process is swapped? There's a difference between swapped and paged. Swapped means that a process has been _completely_ moved to swap space. Such processes had a "W" flag in the state column of ps(1). In contrast to that, paging happens on pages, not on processes. Note that pages are not uniquely assigned to one process, but they can be shared between processes, so it's difficult (or even impossible) to give clear numbers on the amount of paging per process. > Thanks for any hints. My only way to circumvent this problem is to reboot the > machine daily. I've also set up machines with limited RAM and without hard disk for swapping. I never swap onto flash memory, because flash has a limited number of write cycles (it suffers from certain wear). If you have another server within short network distance, you should consider remote swapping via NFS. It's not as slow as it sounds (depending on the speed of the network and the server), and at least it's better than nothing. Otherwise, don't swap (or page) at all. The folowing sysctl will optimize your system for that case: vm.swap_enabled=0 vm.swap_idle_enabled=0 vm.defer_swapspace_pageouts=1 vm.disable_swapspace_pageouts=1 kern.ipc.shm_use_phys=1 You should also build a custom kernel that contains "options NO_SWAPPING". Also make sure that you remove everything from your kernel that you don't need, so more memory is availale for userland. In particular, remove "options UFS_DIRHASH", because the dirhash code can eat quite a lot of memory. And of course you should not run any processes that you don't really need. But I guess you already know that. It might also help to set the "R" malloc flag: # ln -s R /etc/malloc.conf It can reduce memory fragmentation for processes that do a lot of small (re)allocations. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "C++ is to C as Lung Cancer is to Lung." -- Thomas Funke