From owner-freebsd-i386@freebsd.org Tue Oct 6 14:26:14 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 C81E39B6BC1 for ; Tue, 6 Oct 2015 14:26:14 +0000 (UTC) (envelope-from m4rtntns@gmail.com) Received: from mail-oi0-x233.google.com (mail-oi0-x233.google.com [IPv6:2607:f8b0:4003:c06::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 92079BE6 for ; Tue, 6 Oct 2015 14:26:14 +0000 (UTC) (envelope-from m4rtntns@gmail.com) Received: by oixx17 with SMTP id x17so109479533oix.0 for ; Tue, 06 Oct 2015 07:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qquGWOiUFz3IHPdyE9Q7l03h6SwqRzN+Tf/FiZgwl/g=; b=P2ejxt4vH/SiJK0ogno/887LXcoYQo+kqL+UD1DJHTIzwk5kkOSaNVmGckst6zU5zA L+UgAO0XaAAE6ivI9sm1xeKELtnd+l8pGv6Ox5X+zy0VyfF4Qu3wPLL1UopKSGwAmh1v H2vghCH2m+VXobuno23jl0l6kWyRt3kYHUwgsTSCrJJ58rPdENT9gnPbutpH178VGDyS lP4aLtpYYWOCaKrPWcD/Gl3xRmyTTmBqYJdD2La8UPXKvY6ZqkkL9qdyisn2MZryieRO 1EIwQwV9A1LZvE8g85elg007H03fIH7KJXamK+hcJfNCEuG8c3uPR/eS+8MoKTKTF6GQ EngA== MIME-Version: 1.0 X-Received: by 10.202.228.210 with SMTP id b201mr20125205oih.100.1444141573925; Tue, 06 Oct 2015 07:26:13 -0700 (PDT) Received: by 10.202.222.134 with HTTP; Tue, 6 Oct 2015 07:26:13 -0700 (PDT) In-Reply-To: <20151006231051.Q2729@besplex.bde.org> References: <20151006231051.Q2729@besplex.bde.org> Date: Tue, 6 Oct 2015 17:26:13 +0300 Message-ID: Subject: Re: questions regarding "Inactive", "Cache" and "Buffers" memory From: Martin T To: brde@optusnet.com.au Cc: freebsd-i386@freebsd.org Content-Type: text/plain; charset=UTF-8 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 14:26:14 -0000 Thanks for explanation! This is probably a huge simplification, but am I correct that FreeBSD kernel will automatically allocate memory from "Inactive", "Cache" and "Buffers" pools to "Active" and "Wired" if this is needed? Martin On 10/6/15, Bruce Evans wrote: > 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 >