Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754364AbXJVFoH (ORCPT ); Mon, 22 Oct 2007 01:44:07 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751998AbXJVFn4 (ORCPT ); Mon, 22 Oct 2007 01:43:56 -0400 Received: from E23SMTP06.au.ibm.com ([202.81.18.175]:42068 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751802AbXJVFnz (ORCPT ); Mon, 22 Oct 2007 01:43:55 -0400 Message-ID: <471C3A17.5020400@linux.vnet.ibm.com> Date: Mon, 22 Oct 2007 11:20:15 +0530 From: Vaidyanathan Srinivasan Organization: IBM User-Agent: Thunderbird 2.0.0.6 (X11/20071008) MIME-Version: 1.0 To: "Ravinandan Arakali (rarakali)" CC: Linux Kernel Subject: Re: Question about free/used memory on Linux References: <471BA1D1.5040905@linux.vnet.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2837 Lines: 78 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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/