Pre-populating anonymous pages

By: Linus Torvalds (, June 6, 2019 10:01 am
Room: Moderated Discussions
Travis Downs ( on June 5, 2019 4:48 pm wrote:
> One interesting observation is that in this respect anonymous pages are slower than file-backed pages:
> file-backed pages on any kernel in the last 5-10 years use "fault-around" which reads in additional nearby
> pages (16 by default on x86) when a page faults. This behavior doesn't apply to anonymous pages.

If you have a real load you can share where this is noticeable, we could probably add it somewhat easily. But quite often it's not clear how many pages end up needing new allocations after a fork, for example. The file mmap case tends to be much more predictable (it's almost universally just for reading, executables being a big deal).

(And while tmpfs may look like an anonymous mapping in many ways, it doesn't tend to have the COW and zero page issues that a real anonymous mapping does. Of course, I'm not 100% convinced the zero-page thing makes much sense any more at all. It was noticeable for some benchmarks and some users that have sparse data mappings, but I wouldn't be surprised if it's a net loss in reality these days with just extra page faults due to read->write transitions)

So it might be very interesting if you have some true macrobenchmark with real loads etc.

But I suspect you are doing very specific and low-level CPU micro-benchmarks, and then just re-mmap'ing the memory with MAP_POPULATE is almost certainly the right thing to do. Even that won't work with really old kernels which just did a read to populate, but I don't think you can even find kernels that old any more in the wild.

< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
Pre-populating anonymous pagesTravis Downs2019/06/05 03:48 PM
  Pre-populating anonymous pagesJeff S.2019/06/05 07:03 PM
    Pre-populating anonymous pagesTravis Downs2019/06/06 06:11 AM
      Pre-populating anonymous pagesJeff S.2019/06/06 07:40 AM
        Pre-populating anonymous pagesTravis Downs2019/06/06 07:59 AM
          Pre-populating anonymous pagesJeff S.2019/06/06 08:19 AM
  Pre-populating anonymous pagesFoo_2019/06/05 11:30 PM
    Pre-populating anonymous pagesTravis Downs2019/06/06 05:59 AM
      Pre-populating anonymous pagesFoo_2019/06/06 06:56 AM
        Pre-populating anonymous pagesTravis Downs2019/06/06 08:02 AM
  Pre-populating anonymous pagesLinus Torvalds2019/06/06 10:01 AM
    Pre-populating anonymous pagesTravis Downs2019/06/07 01:16 PM
      Pre-populating anonymous pagesBrendan2019/06/08 01:55 AM
        Pre-populating anonymous pagesTravis Downs2019/06/08 07:18 AM
        Pre-populating anonymous pagesLinus Torvalds2019/06/08 10:43 AM
          Pre-populating anonymous pagesBrendan2019/06/09 02:29 AM
            Pre-populating anonymous pagesLinus Torvalds2019/06/10 10:20 AM
          Pre-populating anonymous pagesTravis Downs2019/06/17 08:18 AM
            Pre-populating anonymous pagesLinus Torvalds2019/06/18 03:28 PM
Reply to this Topic
Body: No Text
How do you spell tangerine? 🍊