• Linus Torvalds's avatar
    Simplify and speed up mmap read-around handling · 82a333fa
    Linus Torvalds authored
    This improves cold-cache program startup noticeably for me, and
    simplifies the read-ahead logic at the same time. The rules for
    read-ahead are:
    
     - if the vma is marked random, we just do the regular one-page case. 
       Obvious.
    
     - if the vma is marked "linear access", we use the regular readahead
       code. No change in behaviour there (well, we also only consider it a 
       _miss_ if it was marked linear access - the "readahead" and
       "readaround"  things are now totally independent of each other)
    
     - otherwise, we look at how many hits/misses we've had for this 
       particular file open for mmap, and if we've had noticeably more
       misses than hits, we don't bother with read-around.
    
    In particular, this means that the "real" read-ahead logic literally
    only needs to worry about finding sequential accesses, and does not
    have to worry about the common executable mmap access patthers that 
    have very different behaviour.
    
    Some constant tweaking may be a good idea.
    82a333fa
readahead.c 14.4 KB