Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 16: Page and Buffer Cache


❑ The total number of cached pages is held in thenrpagescounter variable.
❑ address_space_operationsis a pointer to a structure that contains a list of function pointers to
specific operations for handling address spaces. Its definition is discussed below.
❑ i_mmapis the root element of a tree that holds all normal memory mappings of the inode (normal
in the sense that they were not created using the nonlinear mapping mechanism). The task of the
tree is to support finding all memory regions that include at least one page in a given interval,
and the auxiliary macrovma_prio_tree_foreachis provided for this purpose. Recall that the
purpose of the tree is discussed in Section 4.4.3. The details of tree implementation are of no
relevance to us at the moment — it is sufficient to know that all pages of the mapping can be
found on the tree and that the structure can be manipulated easily.
❑ Two further elements are concerned with the management of memory mappings:
i_mmap_writeablecounts all mappings created with a setVM_SHAREDattribute so that
they can be shared by several users at the same time.i_mmap_nonlinearis used to set up a list
of all pages included in nonlinear mappings (reminder: nonlinear mappings are generated by
skillful manipulation of the page tables under the control of theremap_file_pagessystem call).
❑ backing_dev_infois a pointer to a further structure that holds information on the associated
backing store.
Backing storeis the name used for the peripheral device that serves as a ‘‘backbone‘‘ for the infor-
mation present in the address space. It is typically a block device:
<backing-dev.h>
struct backing_dev_info {
unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
unsigned long state; /* Always use atomic bitops on this */
unsigned int capabilities; /* Device capabilities */
...
};
ra_pagesspecifies the maximum number of pages to be read in anticipation (readahead). The
state of the backing store is stored instate.capabilitiesholds information on the backing
store — for example, whether the data in the store can be executed directly as is necessary in
ROM-based filesystems. However, the most important information incapabilitiesis whether
pages can be written back. This can always be done with genuine block devices but is not possi-
ble with memory-based devices such as RAM disks because there would be little point in writing
back data from memory to memory.
IfBDI_CAP_NO_WRITEBACKis set, then synchronization is not required; otherwise, it is. Chapter 17
discusses the mechanisms used for this purpose in detail.
❑ private_listis used to interlinkbuffer_headinstances which hold filesystem metadata (usu-
ally indirection blocks).assoc_mappingis a pointer to the associated address space.
❑ The flag set inflagsis used primarily to hold information on the GFP memory area from
which the mapped pages originate. It can also hold errors that occur during asynchronous
input/output and that cannot therefore be propagated directly.AS_EIOstands for a general I/O
error, andAS_ENOSPCindicates that there is no longer sufficient space for an asynchronous write
operation.

Figure 16-3 sketches how address spaces are connected with various other parts of the kernel. Only the
most important links are shown in this overview; more details will be discussed in the remainder of this
chapter.

Free download pdf