public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
To: "Ravinandan Arakali (rarakali)" <rarakali@cisco.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: Question about free/used memory on Linux
Date: Mon, 22 Oct 2007 11:20:15 +0530	[thread overview]
Message-ID: <471C3A17.5020400@linux.vnet.ibm.com> (raw)
In-Reply-To: <FA6FB5FA4DA6BF4386D129273B2E3EC3024B847C@xmb-sjc-214.amer.cisco.com>


Ravinandan Arakali (rarakali) wrote:
> Hi Vaidy,
> Thanks for clarifying several of my doubts.
> 
> To answer your question about my intention, we currently have a 
> system with 2 GB RAM and I need to find out the actual used and 
> free memory so that we can decide if the same setup(applications,
> tmpfs etc.) can run on another system with lesser memory.
> 
> Is it correct to say that the "used" field "free -m" excluding
> buffers/caches would give the correct idea of used memory
> (I mean does it take care of shared memory, shared copies of 
> libraries etc.) ? I assume it does not include /dev/shm usage
> since that's also a tmpfs partition ?

Thats correct. The used excluding the buffer caches gives most of the
memory used by the system.  You have excludes _all_ file backed memory
including shm.

> 
> If so, then I can add the memory used by tmpfs partitions to
> the above and get the total memory used ?
> 
> For eg. if my "free -m" appears as below:
> Linux(debug)# free -m
>              total       used       free     shared    buffers
> cached
> Mem:          2014        984       1030          0         80
> 594
> -/+ buffers/cache:        309       1705
> 
> Can I say that 309MB + 350 MB(size of tmpfs partitions including
> /dev/shm)
> is the used memory on my system ?

Two problems with this logic:

1. all of tmpfs may not be really used.  You are over committing.
2. You still miss the pages needed to map the program code.  They are file
backed too. Though this will be very less amount of memory compared to data
 and shared memory.

Let me suggest a metric:

1. Take the used part excluding the buffers (309MB) in your case and add
'Mapped' and 'Dirty' from /proc/meminfo

This may be better than adding tmpfs/shmdev size.

2. Once your system is running will all applications loaded, cleanup the
pagecache (file data cached in memory)

sync
echo 1 > /proc/sys/vm/drop_caches

The first sync will bring down 'Dirty' count and drop_caches will reclaim
all 'not needed' file cache memory.

Now if you use 'free' and take the used count _with_ the buffers and file
cache, this will provide a realistic value. (Actually Free in /proc/meminfo)

Do not exclude buffers they are _needed_ for optimum system operation.
With the above figure you can probably add 10% or more memory as extra
memory for file cache when the system is operating with full load.

If you want to be sure of these experiments boot you system with less
memory using mem=xxx kernel parameter and run some performance tests to
ensure the degradation is under acceptable limits.

--Vaidy



  reply	other threads:[~2007-10-22  5:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-21 17:54 Question about free/used memory on Linux Ravinandan Arakali (rarakali)
2007-10-21 19:00 ` Vaidyanathan Srinivasan
2007-10-21 20:21   ` Ravinandan Arakali (rarakali)
2007-10-22  5:50     ` Vaidyanathan Srinivasan [this message]
2007-10-22  6:28       ` Ravinandan Arakali (rarakali)
2007-11-14  6:14       ` Ravinandan Arakali (rarakali)
2007-11-14 11:58         ` Pádraig Brady
2007-11-14 18:18           ` Ravinandan Arakali (rarakali)
2007-10-22 11:51     ` Helge Hafting
2007-10-22 17:34     ` linux-os (Dick Johnson)
2007-10-22 10:05 ` Pádraig Brady
2007-10-23  1:58   ` Ravinandan Arakali (rarakali)

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=471C3A17.5020400@linux.vnet.ibm.com \
    --to=svaidy@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rarakali@cisco.com \
    /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