Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


mark_page_accessed

no_cached_page

page_cache_alloc_cold

add_to_page_cache_lru

mapping->a_ops->readpage

Figure 8-15: Code flow diagram for
no_cached_page.

8.5.2 The fault Mechanism


Memory mappings normally invoke thefilemap_faultstandard routine provided by the VFS layer to
read pages not held in cache. Figure 8-16 shows the code flow diagram of this function.

mark_page_accessed

No

filemap_fault

page_cache_read

find_lock_page

mapping->a_ops->readpage

Random Read Hint?

Sequential read hint? Use generic RA logic

Page not found?

Invoke generic readahead

Page uptodate?

Retry from find_lock_page onwards
Yes

Figure 8-16: Code flow diagram forfilemap_fault.

As the diagram illustrates, the implementation exhibits several parallels with thegeneric_file_read
mechanism just discussed.

First, the function checks if the virtual memory area to which the page belongs contains a hint that
accesses are mostly random and not in any predictable order. This hint is given if theVM_RAND_READ
is set; this can be checked with the helper macroVM_RandomReadHint. Note that themadvisesystem call
(not discussed here) can be invoked to advise memory management which access pattern will be most
likely. If a random read pattern is expected, the kernel directly callspage_cache_readto allocate a new
page in the page cache and issue a read request.
Free download pdf