Chapter 8: The Virtual Filesystem
mark_page_accessedno_cached_pagepage_cache_alloc_coldadd_to_page_cache_lrumapping->a_ops->readpageFigure 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_accessedNofilemap_faultpage_cache_readfind_lock_pagemapping->a_ops->readpageRandom Read Hint?Sequential read hint? Use generic RA logicPage not found?Invoke generic readaheadPage uptodate?Retry from find_lock_page onwards
YesFigure 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.