From owner-freebsd-i386@freebsd.org Tue Oct 6 12:58:47 2015 Return-Path: Delivered-To: freebsd-i386@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 679AD9B25EE for ; Tue, 6 Oct 2015 12:58:47 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 2C30DFC6 for ; Tue, 6 Oct 2015 12:58:46 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id AE50DD66154; Tue, 6 Oct 2015 23:58:34 +1100 (AEDT) Date: Tue, 6 Oct 2015 23:58:33 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Martin T cc: freebsd-i386@freebsd.org Subject: Re: questions regarding "Inactive", "Cache" and "Buffers" memory In-Reply-To: Message-ID: <20151006231051.Q2729@besplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=R4L+YolX c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=kj9zAlcOel0A:10 a=OXxPhNoKxnt1On6mg8cA:9 a=CjuIK1q_8ugA:10 X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Oct 2015 12:58:47 -0000 On Tue, 6 Oct 2015, Martin T wrote: This is not really i386-specific. > FreeBSD "top" utility categorizes memory into "Active", "Inact", > "Wired", "Cache", "Buf" and "Free" sections. For example: > > Mem: 125M Active, 42M Inact, 51M Wired, 17M Cache, 34M Buf, 2720K Free > Swap: 512M Total, 512M Free > > Those sections should have following meanings: "should" according to top's UI? Some of them are too FreeBSD-specific to match a general UI. > Active: Memory currently being used by processes. > Inactive: Memory that was used by processes that are no longer > running, but is cached since it may be used again. > Wired: Memory in use by the FreeBSD kernel. This memory cannot be swapped out. > Cache: Memory being used to cache data. Can be freed immediately if required. > Buffers: Disk(HDD/SSD) cache. "Buf" is a generic idea, but top only displays a FreeBSD buffer variable that is unrelated to top's idea of what it is, and is among the least useful of FreeBSD buffer-related variables. It is what is given by the vfs.bufspace sysctl. Most of the disk cache lives in VMIO pages which are counted under "Inact". Under some loads (especially light ones), "Inact" is mostly for the disk cache, but it is not easy to say exactly when this applies. "Buf" is just the amount of virtual memory currently used for mapping VMIO pages. In normal use (not using zfs) after the system has read a lot off disks, it is much smaller than the amount buffered in VMIO pages. The mapping may be sparse or fragmented, so it may be much larger than the amount mapped. It is limited to a fixed amount given by the vfs.maxbufspace syscall. This value is even less interesting since it is fixed at boot time and is determined by the amount of memory unless it is manually configured. But unless the mapping is very sparse or fragmented, after the buffer cache warms up bufspace is much the same as maxbufspace. So all that the dynamic bufspace tells you most of the time is how ineffective the mapping is. > Free: Completely free and ready to use. > > Questions: > > 1) Is it possible to flush "Inactive", "Cache" or "Buffers" memory? Or > can this be done only be kernel automatically? I don't know of any way except unmounting a file system. That moves all pages for buffering the file system out of "Inact", and any of these that are mapped into the buffer cache out of "Buf". zfs doesn't use the normal mechism, so I think neither "Inact" or "Buf" is relevant for it. It now has its own line on the top display. > 2) What is the difference between "Cache" and "Buffers" memory? "Cache" is even more technical and unsuitable for putting in the top display than "Buf". Since it is a FreeBSD (mach vm) thing, users shouldn't even detect top to display it. This seems to be fixed in -current -- "Cache" is just not displayed. It usually has a small value (28K on my old system) so was best ignored. "Wired" and "Inact" are also techical vm things, but they are worth displaying since they have interesting values that can be partly understood without knowing all the details. Bruce