Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 17: Data Synchronization


17.6 Periodic Flushing
Now that you are familiar with the framework in which thepdflushmechanism operates, let’s move on
to describe the routines responsible for the actual synchronization of cache contents with the associated
backing store. Recall that two alternatives are available, one periodic and one enforced. First, let’s discuss
the periodic writeback mechanism.

In earlier kernel versions, a user mode application was used to perform periodic write operations. This
application was started at kernel initialization timeand invoked a system call at regular intervals to
write back dirty pages. In the meantime, this not particularly elegant procedure was replaced with a
more modern alternative that does not take the longroute via user mode and is therefore not only more
efficient but also more aesthetic.

What’s left of the earlier method is the namekupdate. The name appears as a component of some functions
and is often used to describe the flushing mechanism.

Two things are needed to periodically flush dirty cache data: the worker function that is executed with
the help of thepdflushmechanism, and code to regularly activate the mechanism.

17.7 Associated Data Structures
Thewb_kupdatefunction inmm/page-writeback.cis responsible for the technical aspects of flushing. It
is based on the address space concept (discussed in Chapter 4) that establishes the relationship among
RAM, files or inodes, and the underlying block devices.

17.7.1 Page Status


wb_kupdateis based on two data structures that control how it functions. One of these structures is the
global arrayvm_stat, which enables the status of all system memory pages to be queried:

mm/vmstat.c
atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];

The array holds a comprehensive collection of statistical information to describe the status of the memory
pagesof each CPU; consequently, there is an instance of the structure for each CPU in the system. The
individual instances are grouped together in an array to simplify access.

The structure elements are simple, elementary numbers and therefore indicate only
how manypages have a specific status. Other means must be devised to find out
whichpages these are. This issue is discussed below.

The following statistics are collected invm_stat:

<mmzone.h>
enum zone_stat_item {
/* First 128 byte cacheline (assuming 64 bit words) */
NR_FREE_PAGES,
NR_INACTIVE,
NR_ACTIVE,
NR_ANON_PAGES, /* Mapped anonymous pages */
Free download pdf