From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 28 16:27:33 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0218F106573C for ; Thu, 28 Jun 2012 16:27:32 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 86D338FC0C; Thu, 28 Jun 2012 16:27:32 +0000 (UTC) Message-ID: <4FEC85F4.8010005@FreeBSD.org> Date: Thu, 28 Jun 2012 12:27:32 -0400 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:13.0) Gecko/20120626 Thunderbird/13.0.1 MIME-Version: 1.0 To: Andrew Boyer References: <201206280958.13859.jhb@freebsd.org> <20120628144630.GA50099@dragon.genyosha.net> <0262B234-1618-4072-92A9-7EC1D3AE596D@averesystems.com> In-Reply-To: <0262B234-1618-4072-92A9-7EC1D3AE596D@averesystems.com> X-Enigmail-Version: 1.4.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, Steve Rikli Subject: Re: distinguish between Maxmem, realmem, physmem 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: Thu, 28 Jun 2012 16:27:33 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2012-06-28 11:18:45 -0400, Andrew Boyer wrote: > On Jun 28, 2012, at 10:46 AM, Steve Rikli wrote: > >> On Thu, Jun 28, 2012 at 09:58:13AM -0400, John Baldwin wrote: >>> On Tuesday, June 26, 2012 3:41:10 pm Ping Chen wrote: >>>> >>>> I am a bit confused with all these variables defined in >>>> freebsd(especially in freebsd 6.1): Which one of this >>>> represents the real memory of a system? Say we bought a >>>> system with 4G ram, which one tells me the RAM is 4G? >>>> >>>> Accordign to source code: Maxmem ==> the highest page of >>>> phisycal address page : if I understand correctly, this is >>>> the highest page number of physical memory that is usable? >>>> >>>> realMem --> somehow get assigned by realmem = Maxmem: this >>>> is confuing, if they are the same, why bother a realmem >>>> variables >>> >>> I think realMem is legacy. >>> >>>> physmem --> the number of usage pages : this seems the right >>>> one extract the memory info, however, it seems system >>>> allocate portion of memory to messge buffer which makes this >>>> physmem < 4G (assume RAM is 4G) >>> >>> Correct. Note that the firmware can also take up part of RAM >>> as well (e.g. to hold ACPI tables). >> >> Given that, are the values for real & avail memory from 'dmesg' >> presented anywhere like sysctl? E.g. one of my small servers has >> these from dmesg: >> >> real memory = 1073741824 (1024 MB) avail memory = 1023852544 >> (976 MB) >> >> but the presumably equivalent sysctl values are different: >> >> hw.realmem: 1065287680 hw.physmem: 1047953408 >> >> For system hardware inventory purposes (I assume OP is asking for >> reasons along those lines, as am I) I'd want the value which >> reflects 1024MB of RAM in this case, understanding that it may >> not be precisely the amount available for system/user/etc. >> usage. >> >> Is dmesg the (only?) place to get that number? >> >> Cheers, sr. > > Here I use hw.physmem and round up to the nearest 1GB. > > You can also check the output of 'dmidecode -t 17' and total up the > listed size of each DIMM. It gets its info from the BIOS, which > probed the SPD on each EEPROM at boot time. dmidecode is in > ports/sysutils/dmidecode. You don't have to use dmidecode for that. The same information is already available from loader(8) for very long time: % kenv smbios.memory.enabled 4194304 % dmesg | grep 'real memory' real memory = 4294967296 (4096 MB) http://svnweb.freebsd.org/base?view=revision&revision=190599 > Sometimes a flaky motherboard won't find all of the memory, so it's > useful to make sure they match. Correct. In fact, the "real memory" from dmesg is derived from the same SMBIOS data unless it is less than "avail memory". http://svnweb.freebsd.org/base?view=revision&revision=196412 Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk/shfMACgkQmlay1b9qnVMb1gCgtaJbMoBycsDKMLki3ttlp7xz NfwAoMNbHVs+l5EluxFGDbL1zpBsrRXh =rbey -----END PGP SIGNATURE-----