From owner-freebsd-hackers Thu Jan 30 16:24: 1 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9708037B401 for ; Thu, 30 Jan 2003 16:23:59 -0800 (PST) Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0630F43F85 for ; Thu, 30 Jan 2003 16:23:59 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: from apollo.backplane.com (localhost [127.0.0.1]) by apollo.backplane.com (8.12.6/8.12.6) with ESMTP id h0V0Nr0i090964; Thu, 30 Jan 2003 16:23:53 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.12.6/8.12.6/Submit) id h0V0NqAE090963; Thu, 30 Jan 2003 16:23:52 -0800 (PST) Date: Thu, 30 Jan 2003 16:23:52 -0800 (PST) From: Matthew Dillon Message-Id: <200301310023.h0V0NqAE090963@apollo.backplane.com> To: David Schultz Cc: James Gritton , freebsd-hackers@FreeBSD.ORG Subject: Re: What's the memory footprint of a set of processes? References: <20030130064448.GA7258@HAL9000.homeunix.com> <200301300719.h0U7JOfI086054@apollo.backplane.com> <20030130091419.GA7776@HAL9000.homeunix.com> <200301301923.h0UJNT0l089037@apollo.backplane.com> <20030131001436.GA10856@HAL9000.homeunix.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG : :Thus spake Matthew Dillon : :> It's not possible to get a wholely accurate count no matter what :> you do. For example, to truely know whether a process is using :> a page you have to run through the process's page table (PMAP), :> access the vm_page, then locate where in the shadow chain the VM object :> the vm_page belongs to resides. But since hardware page tables are :> throw-away, the system could very well have thrown away whole page :> tables so this method is no more accurate then any other. : :Thanks for the explanations! I still don't understand why this :doesn't work, assuming you don't care about nonresident pages: : :for each process p in the set : for each map entry e in p->vmspace->vm_map : for each page m in e->object.vm_object->memq : if I haven't seen this m.phys_addr yet in the scan : resident_pages++ That would get close, as long as the machine is not paging heavily. Think of it this way: If you have a lot of ram the above calculation will give you an upper bound on memory use, but some of the pages in the VM object's may be very old and not actually under active access by the process (for example, the pages might represent part of the program that was used during initialization and then never used again). If you do not have so much memory older pages will get flushed out or flushed to swap and the above calculation will represent more of a lower bound on the memory used by the group of processes. Consider a database. A database might be mapping a large table file and, if you have lots of memory, most of that table file might be cached (in the VM object's memq), but that doesn't mean the database has necessarily needed all that data recently. The database might run just as well with less memory available. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message