Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Oct 2015 17:26:13 +0300
From:      Martin T <m4rtntns@gmail.com>
To:        brde@optusnet.com.au
Cc:        freebsd-i386@freebsd.org
Subject:   Re: questions regarding "Inactive", "Cache" and "Buffers" memory
Message-ID:  <CAJx5YvF-D6ZvPeXg41EFrt_U-DdWpLWTNWV1PsXxESsFNo=kOA@mail.gmail.com>
In-Reply-To: <20151006231051.Q2729@besplex.bde.org>
References:  <CAJx5YvGbZyEL3Dnzu_0bZyfgmFMW5z2ufahR4wqWbhNyAcCnfg@mail.gmail.com> <20151006231051.Q2729@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <brde@optusnet.com.au> 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
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJx5YvF-D6ZvPeXg41EFrt_U-DdWpLWTNWV1PsXxESsFNo=kOA>