public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: jonathan@jonmasters.org
Cc: jonmasters@gmail.com, "Linux-Kernel," <linux-kernel@vger.kernel.org>
Subject: Re: /proc/kcore size incorrect ?
Date: Mon, 24 Oct 2005 01:57:10 +0200	[thread overview]
Message-ID: <20051024015710.29a02e63@werewolf.able.es> (raw)
In-Reply-To: <35fb2e590510231613u492d24c6k4d65ff3ac5ffcee6@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2694 bytes --]

On Mon, 24 Oct 2005 00:13:44 +0100, Jon Masters <jonmasters@gmail.com> wrote:

> On 10/23/05, J.A. Magallon <jamagallon@able.es> wrote:
> 
> > BTW, any simple method to get the real mem of the box ?
> 
> This is a typical example of using a hammer to crack a nut aka
> modifying the kernel before giving up on userspace.
> 

Ejem.

Who talks about modifying anything ?

> Several ways of looking up a solution:
> 
>     * google

Well, perhaps I buy this, but as this looks like a strange/buggy thing, as
I will explain later...

>     * man -k memory
> 
> Leading to:
> 
> * free(1):
>     ``free  displays the total amount of free and used physical and swap''
> 
> * Or /proc/meminfo (both the same thing) - which you can trivially
> parse using sed:
> 
> cat /proc/meminfo | sed -n -e "s/^MemTotal:[ ]*\([0-9]*\) kB\$/\1/p"
> 

Do your homework.

free gives the free amount of memory _available for the user_, ie, the
full memory of the box minus the kernel reserved part.

From dmesg:

BIOS-provided physical RAM map:
 BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
 BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
 BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
 BIOS-e820: 0000000000100000 - 000000003fee0000 (usable)
 BIOS-e820: 000000003fee0000 - 000000003fee3000 (ACPI NVS)
 BIOS-e820: 000000003fee3000 - 000000003fef0000 (ACPI data)
 BIOS-e820: 000000003fef0000 - 000000003ff00000 (reserved)
 BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
1022MB LOWMEM available.
...
Memory: 1034744k/1047424k available (1858k kernel code, 12208k reserved, 634k da
ta, 184k init, 0k highmem)
werewolf:~> echo $((1047424 / 1024))
1022

werewolf:~> free
             total       used       free     shared    buffers     cached
Mem:       1035012    1000660      34352          0      98348     649284
werewolf:~> cat /proc/meminfo | grep MemTotal
MemTotal:      1035012 kB
werewolf:~> echo $((1035012 / 1024))
1010

So free/proc give the available memory, not the total:
- free: 1010 Mb
- kcore: 1022 Mb

I expected /proc/kcore to give the size of your installed memory, with
the reserved BIOS areas just not accesible, but it looks like it already
has them discounted, so gives 1022 Mb.

It looks really silly to have a motd say "wellcome to this box, it has
2 xeons and 1022 Mb of RAM".



--
J.A. Magallon <jamagallon()able!es>     \               Software is like sex:
werewolf!able!es                         \         It's better when it's free
Mandriva Linux release 2006.1 (Cooker) for i586
Linux 2.6.13-jam9 (gcc 4.0.1 (4.0.1-5mdk for Mandriva Linux release 2006.0))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-10-23 23:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-23 21:58 /proc/kcore size incorrect ? J.A. Magallon
2005-10-23 23:13 ` Jon Masters
2005-10-23 23:57   ` J.A. Magallon [this message]
2005-10-24 12:02     ` Jon Masters
2005-10-24 14:19     ` Stefan Smietanowski
2005-10-25 12:04     ` Matan Peled
2005-10-25 13:37       ` Brian Waite
2005-10-25 16:02     ` /proc/kcore size incorrect ? (OT) Eric Piel
2005-10-25 16:06       ` J.A. Magallon
2005-10-25 18:04         ` Tony Luck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051024015710.29a02e63@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=jonathan@jonmasters.org \
    --cc=jonmasters@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox