Mmfilemapc

page_cache_sync_readahead(mapping, ra, file, vmf->pgoff, 1); page = find_lock_page(mapping, vmf->pgoff); if (!page)

goto no_cached_page;

if (PageReadahead(page)) {

page_cache_async_readahead(mapping, ra, file, page, vmf->pgoff, 1);

The mechanism is identical with the mechanism used in do_generic_mapping_read. When the page cannot be found with synchronous readahead, the jump to no_cached_page employs page_cache_read to allocate a new page in the page cache and issue a read request. Afterward, the code retries the operation from the first call to find_lock_page onward. Obviously, this requires using C's goto feature.

Let's go back to the code snippet shown above. If the page was present in the system, it has originated from a previous readahead operation. As discussed in Chapter 16.4.5., the readahead mechanism marks a page near the end of a readahead window, that is, a range of files that is read in before a process actually requests them. Once this page is reached, then asynchronous readahead should be started to read in pages speculatively. The required mark is the PG_readahead bit (which can be checked with PageReadahead), and the function responsible to perform asynchronous readahead is page_cache_async_readahead. Again, notice that more details about this mechanism are discussed in Chapter 16.4.5.

If no sequential readahead hint was given and the page could not be found in the page cache, the generic readahead mechanism needs to be invoked. Slightly simplified, it is implemented as follows:

Continue reading here: Mmfilemapc

Was this article helpful?

0 0