Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Sep 2000 18:42:09 -0400 (EDT)
From:      Christopher Stein <stein@eecs.harvard.edu>
To:        freebsd-arch@freebsd.org
Subject:   Re: vm and fs threads
Message-ID:  <Pine.OSF.4.20.0009041834000.8660-100000@wally>

next in thread | raw e-mail | index | archive | help

Hi, About a week ago, I posted some questions to this
list about the various VM and buffer cache kprocs. I was
directed to Matt Dillon and he replied with an excellent
outline. Please find it attached.

-Chris

---------- Forwarded message ----------
Date: Tue, 29 Aug 2000 16:34:01 -0700 (PDT)
From: Matt Dillon <dillon@earth.backplane.com>
To: Christopher Stein <stein@eecs.harvard.edu>
Subject: Re: vm and fs threads

:Hi Matt,
:
:I was referred to you from -ARCH to answer my questions about the
:functionality of the various FS and VM kernel threads.
:
:Here's some ps waux output from my 4.0 system:
:
:root       4  0.0  0.0     0    0  ??  DL   Wed04PM   0:00.50  (bufdaemon)
:root       5  0.0  0.0     0    0  ??  DL   Wed04PM   1:59.45  (syncer)

    The syncer is responsible for course-grained flushing of all files with
    dirty blocks.  It essentially runs down the list of files with dirty 
    blocks and fsync's them, file by file.  This occurs every so often
    whether there is memory pressure or not.

    The syncer operates primarily under light loads, to make sure that
    dirty blocks get flushed out to their backing store so you don't lose
    too much if the machine crashes.

    The bufdaemon is responsible for flushing dirty buffer cache blocks when
    necessary due to memory pressure.  It works on a block-by-block basis 
    rather then a file-by-file basis, and flushes the blocks based on a LRU
    algorithm.

    The bufdaemon operates primarily under heavier loads to make sure that
    there are a sufficient number of clean buffers for the filesystem the
    reuse and to sequence out I/O in a reasonable optimal manner under heavy
    load conditions.

:bufdaemon and syncer appear to be distinct processes. The syncer is the
:background thread that writes dirty blocks to disk. What does the
:bufdaemon do?
:
:Here are the 3 kernel VM daemons:
:
:root       2  0.0  0.0     0    0  ??  DL   Wed04PM   0:00.51 (pagedaemon)
:root       3  0.0  0.0     0    0  ??  DL   Wed04PM   0:00.00  (vmdaemon)
:root       0  0.0  0.0     0    0  ??  DLs  Wed04PM   0:00.23  (swapper)
:
:How are they different? From the source (vm/vm_pageout.c) vm_daemon
:appears to perform swapping activities; that is, the eviction of full
:processes from core. Pagedaemon (also vm/vm_pageout.c) appears to write
:and evict pages to the swap device. What then does the swapper do?
:
:Your clarifications are much appreciated.
:
:-Chris

    The pagedaemon is responsible for keeping track of how often VM pages
    are accessed and using that information to order them in the page queues.

    The pagedaemon is also responsible for flushing VM pages to their backing
    store (either the filesystem or swap, depending), under any load condition.
    The flush rate depends on the load.  On lightly loaded machines the
    pagedaemon is mostly idle and only tries to order pages 'loosely' (i.e.
    doesn't make a huge effort to keep pages in the right queues).  Under
    heavier loads the pagedaemon makes more of an effort to put pages in
    their proper page queues and is also responsible for flushing the pages
    to their backing store when it determines that there are too many dirty
    pages in the system.  The pagedaemon tends to take on the brunt of
    the disk writing work under heavier load conditions.

    The VM daemon wakes up under heavy memory pressure and is responsible
    for enforcing the resource limits associated with various processes.
    Specifically, the 'memoryuse' resource (RLIMIT_RSS).  It will forcefully
    deactivate pages in processes whos resident set sizes are larger then
    their resource limits allow.  The VM daemon does no paging on its own. 
    Instead it makes certain pages 'more likely to be paged' by the 
    pagedaemon.

    The VM daemon is also responsible, under extreme memory pressure, for
    swapping out whole processes.  It does this by forcefully deactivating
    all of a process's pages and then forcefully putting the process to 
    sleep for (typically) 20 seconds.  It does not actually page the pages
    out, it allows the pagedaemon to do that.  It simply makes the pages
    'most likely' to be paged out and enforces the sleep period to prevent
    the process from paging them back in too early.

    The 'swapper' (process 0) doesn't really do much any more.   It
    basically looks for processes marked as being swapped out, determines
    if there is sufficient space to allow them to run again, and wakes
    them up.  (see the 'scheduler' procedure in /usr/src/sys/vm/vm_glue.c).

						-Matt




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSF.4.20.0009041834000.8660-100000>