Pre-populating anonymous pages

By: Linus Torvalds (torvalds.delete@this.linux-foundation.org), June 6, 2019 11:01 am
Room: Moderated Discussions
Travis Downs (travis.downs.delete@this.gmail.com) 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.

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