From owner-freebsd-stable@FreeBSD.ORG Wed Dec 15 11:16:47 2010 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B9B5106564A for ; Wed, 15 Dec 2010 11:16:47 +0000 (UTC) (envelope-from mamalos@eng.auth.gr) Received: from vergina.eng.auth.gr (vergina.eng.auth.gr [155.207.18.1]) by mx1.freebsd.org (Postfix) with ESMTP id 8EA7C8FC14 for ; Wed, 15 Dec 2010 11:16:46 +0000 (UTC) Received: from mamalacation.ee.auth.gr (mamalacation.ee.auth.gr [155.207.33.29]) by vergina.eng.auth.gr (8.14.3/8.14.3) with ESMTP id oBFB46If067854 for ; Wed, 15 Dec 2010 13:04:07 +0200 (EET) (envelope-from mamalos@eng.auth.gr) Message-ID: <4D08A0A1.40205@eng.auth.gr> Date: Wed, 15 Dec 2010 13:04:01 +0200 From: George Mamalakis User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.12) Gecko/20101103 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: stable@freebsd.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: vm.swap_reserved toooooo large? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2010 11:16:47 -0000 Dear all, I was testing a program that would exhaust all my memory (in C++), and when this would happen, it would call set_new_handler() along with one of my functions that would inform the user about the lack of memory and then it would exit the program. Instead, the program was force-killed by the kernel (signal 9) and I was informed that: "swap zone exhausted, increase kern.maxswzone" on my main console. So far so good. In two other consoles I was running top -P, and vmvstat 5, and their output was: # top -P last pid: 1776; load averages: 1.71, 0.72, 0.40 up 0+00:24:29 12:24:39 34 processes: 2 running, 32 sleeping CPU 0: 2.6% user, 0.0% nice, 88.3% system, 0.0% interrupt, 9.0% idle CPU 1: 0.0% user, 0.0% nice, 39.1% system, 0.0% interrupt, 60.9% idle CPU 2: 0.0% user, 0.0% nice, 2.6% system, 1.5% interrupt, 95.9% idle CPU 3: 0.4% user, 0.0% nice, 89.8% system, 0.0% interrupt, 9.8% idle Mem: 2629M Active, 221M Inact, 966M Wired, 82M Cache, 7280K Buf, 16M Free Swap: 4096M Total, 1821M Used, 2275M Free, 44% Inuse, 196K In, 30M Out FreeBSD/amd64 (example.com) (ttyv2)ATE C TIME WCPU COMMAND 1771 mamalos 1 117 0 573G 3566M CPU1 1 1:48 94.38% memory login: oot 1 44 0 11544K 1176K select 0 0:17 0.29% hald-addon 1535 root 1 44 0 16552K 1436K swread 2 0:03 0.20% hald-addon 1772 mamalos 1 44 0 9364K 2032K CPU3 0 0:02 0.00% top 790 root 1 46 0 8068K 812K select 3 0:01 0.00% moused 1514 root 1 44 0 21696K 1596K wait 0 0:00 0.00% login 1711 mamalos 1 45 0 10148K 0K wait 1 0:00 0.00% 1021 root 1 44 0 7044K 864K zio->i 2 0:00 0.00% syslogd 829 root 1 64 0 3204K 16K select 2 0:00 0.00% devd 1568 root 1 47 0 10148K 964K ttyin 1 0:00 0.00% bash 1530 root 1 44 0 17872K 1108K swread 2 0:00 0.00% hald-runne 1513 root 1 44 0 21696K 0K wait 0 0:00 0.00% 1680 mamalos 1 44 0 10148K 0K wait 3 0:00 0.00% 1512 root 1 44 0 21696K 0K wait 0 0:00 0.00% 1511 root 1 44 0 21696K 0K wait 0 0:00 0.00% and: # vmstat 5 procs memory page disks faults cpu r b w avm fre flt re pi po fr sr ad4 cd0 in sy cs us sy id 1 0 9 565G 133M 1761 3 4 156 901 13078 0 0 173 1693 1581 0 7i 92 when the program was shut. As you can see (in vmstat's output) avm equals to 565G of memory(?!?!?!), and top shows that the first process (it's called memory) has a size of 573G! moreover, on another terminal I run: # sysctl -a | grep -i swap vm.swap_enabled: 1 vm.nswapdev: 1 vm.swap_async_max: 4 vm.swap_reserved: 544762376192 vm.swap_total: 4294967296 vm.swap_idle_threshold2: 10 vm.swap_idle_threshold1: 2 vm.stats.vm.v_swappgsout: 795224 vm.stats.vm.v_swappgsin: 1188 vm.stats.vm.v_swapout: 200045 vm.stats.vm.v_swapin: 606 vm.disable_swapspace_pageouts: 0 vm.defer_swapspace_pageouts: 0 vm.swap_idle_enabled: 0 where one can see that vm.swap_reserved is equal to 507G whereas the total size (vm.swap_total) is 4G.(?!?!?) As far as my system is concerned: $ uname -a FreeBSD example.com 8.1-STABLE FreeBSD 8.1-STABLE #1: Fri Nov 5 17:27:37 EET 2010 root@:/mnt/obj/mnt/src/sys/GENERIC amd64 and I use zfs on one of my filesystems. So: $ cat /boot/loader.conf zfs_load="YES" vfs.zfs.prefetch_disable=0 nvidia_load="YES" kern.maxfiles="35000" kern.ipc.shmall="65536" atapicam_load=YES snd_hda_load=YES I had noticed in the past that at some moments vmstat would show more memory than what my total memory was, but never sooo much. Is this a bug or am I missing something very fundamental? Thank you all for your time in advance. -- George Mamalakis IT Officer Electrical and Computer Engineer (Aristotle Un. of Thessaloniki), MSc (Imperial College of London) Department of Electrical and Computer Engineering Faculty of Engineering Aristotle University of Thessaloniki phone number : +30 (2310) 994379