Pre-populating anonymous pages

By: Travis Downs (travis.downs.delete@this.gmail.com), June 6, 2019 9:02 am
Room: Moderated Discussions
Foo_ (foo.delete@this.nomail.com) on June 6, 2019 7:56 am wrote:
> Travis Downs (travis.downs.delete@this.gmail.com) on June 6, 2019 6:59 am wrote:
> > Foo_ (foo.delete@this.nomail.com) on June 6, 2019 12:30 am wrote:
> > > Travis Downs (travis.downs.delete@this.gmail.com) on June 5, 2019 4:48 pm wrote:
> > > > Maybe it's a bit OT for this forum, but hey I figure it can't be worse than Ireland spam, right?
> > > >
> > > > On Linux, given a mapped-but-probably-not-populated anonymous region
> > > > of memory, is there any way to ask the kernel to populate it?
> > >
> > > How about madvise(..., MADV_WILLNEED)? Am I misunderstanding your intent?
> >
> > I had already tried it, but it seems to do nothing for anonymous pages. If you read between
> > the lines of the man page, this advice (and related ones like MADV_SEQUENTIAL) seem to be
> > targeted to file-backed pages, and are there to tune the readahead behavior for such pages.
> > For anonymous pages there is no readahead, so I guess that's why it does nothing.
> >
> > I agree it would be nice if this mapped the pages though.
>
> Another thought: write() the whole area to /dev/null? Not sure
> how expensive that is, or if it even accesses the source area.

Heh, yeah had a similar thought on the parallel thread, although I suggested read(2) from /dev/zero. I'm not sure write() will work, because normally a read access causes pages to populated but all pointing to the shared zero page: only on a write do you get a dedicated private page (so yes, you get 2 page faults rather than one if you read before write, which sometimes happens if you do say memory[i] += foo using the fact that it is initially zeroed).

I guess I will try it out.

< 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?