From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 6 12:38:13 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D8005F26 for ; Wed, 6 Aug 2014 12:38:13 +0000 (UTC) Received: from albert.catwhisker.org (mx.catwhisker.org [198.144.209.73]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9560E22D9 for ; Wed, 6 Aug 2014 12:38:13 +0000 (UTC) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.14.9/8.14.9) with ESMTP id s76CcCpv023215; Wed, 6 Aug 2014 05:38:12 -0700 (PDT) (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.14.9/8.14.9/Submit) id s76CcB5u023214; Wed, 6 Aug 2014 05:38:11 -0700 (PDT) (envelope-from david) Date: Wed, 6 Aug 2014 05:38:11 -0700 From: David Wolfskill To: Stefan Parvu Subject: Re: memory utilization questions Message-ID: <20140806123811.GB1228@albert.catwhisker.org> Mail-Followup-To: David Wolfskill , Stefan Parvu , freebsd-hackers@freebsd.org References: <20140806145314.643dcc34a360f8284083930e@systemdatarecorder.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w8QetmdSDwT395M8" Content-Disposition: inline In-Reply-To: <20140806145314.643dcc34a360f8284083930e@systemdatarecorder.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Aug 2014 12:38:14 -0000 --w8QetmdSDwT395M8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 06, 2014 at 02:53:14PM +0300, Stefan Parvu wrote: >=20 > Im planning to calculate real used, free memory. Can anyone confirm if th= ese > are correct: >=20 > 1. real used memory >=20 > usedmem =3D totalmem - freemem, >=20 > totalmem =3D vm.stats.vm.v_page_count x page_size > freemem =3D vm.stats.vm.v_free_count x page_size >=20 >=20 > 2. real free memory >=20 > realfree =3D inactive + cache + free ? >=20 > inactive =3D vm.stats.vm.v_inactive_count x page_size > cache =3D vm.stats.vm.v_cache_count x page_size > free =3D vm.stats.vm.v_free_count x page_size > ... In what I have: * I assume(!) that page size is invariant during any interval I care about. * I do the calulations in KB (1024B), so I get the hw.pagesize OID & integer-divide that by 1024 to get a page_to_kb factor (e.g., for 4K pagesize, the factor is 4). * Other OIDs: vm.stats.vm.v_active_count, vm.stats.vm.v_inactive_count, vm.stats.vm.v_wire_count, vm.stats.vm.v_cache_count, vm.stats.vm.v_free_count; I multiply each of these by the "page_to_kb factor" determined above (to get results in KB). * Another OID: vfs.bufspace; I integer-divide this by 1024 (to get results in KB), as it seems to be in bytes vs. pages. * Correspondence between names as used by top(1) vs. OID: Active: vm.stats.vm.v_active_count Inact: vm.stats.vm.v_inactive_count Wired: vm.stats.vm.v_wire_count Cache: vm.stats.vm.v_cache_count Buf: vfs.bufspace Free: vm.stats.vm.v_free_count Peace, david --=20 David H. Wolfskill david@catwhisker.org Taliban: Evil cowards with guns afraid of truth from a 14-year old girl. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --w8QetmdSDwT395M8 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJT4iGyXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4RThEMDY4QTIxMjc1MDZFRDIzODYzRTc4 QTY3RjlDOERFRjQxOTNCAAoJEIpn+cje9Bk7gTcQAISqsRdBbeUlTRSSTQxkOIjc ZriNv0WQcGez8bh2S1BL492zCPs+bJn19hCaPbFTwR3GLJJE0PKLl1nC9cXgc3pg ofkeKfcvsxg+UKMSmwi5gaza7wPtpQkSwHrSERBttLueu73fEVRSiecJNKFs/ka+ cefmHNXDfgepaLWgvM62XkBSy9rJfKakyxBaIabkJZ+s63g8RbbKtvpOv9T3x8GB RHIPPFsZjelINe1lNQQ6GT6LSW73Kp+0igoHTyifBN7G+LeAwycF3nAU6LewnH+K GnitAE10SFzKZtRG6M8N7nIT0UKI60jIHKw4DkWWTwXIDPdNIZLxTrih/CYyGePH WWrji/twlNLolKlJSyDyKlJdRhXRAKtZY4/WEwGQAdvOxTkEoyqFDTD4Kv8UH7wL +FiY+tBBjUIk7M23IQwKjXv06uXDmZtDh67c67v1b/FbM4PD/nXi3QzanjaPFjiq d6iqQKK3Tm4abTE9tPdNgY1QnN2li883m2Ok7g7PYZsFKMk2IwCj+YaC1oK27HL5 4ofkHb5CbZKaDmhZ+buGmDhh8yIRug8FmEsZJ3l24S4NkT3lcGdE1xJu7HKrDpQZ UfIhj0WLyrLURVLVISnahQesTzIhsE1xC88gJwbNiP2tUpL4GtmpRCN7FyuHL87w eXK3enzdUtNI93WBJNnx =zp6l -----END PGP SIGNATURE----- --w8QetmdSDwT395M8--