Re: [PATCH][RFC][0/4] InfiniBand userspace verbs implementation

Andrew Morton
2005-04-25T20:55:42Z

Roland Dreier <roland@topspin.com> wrote:
>
> Timur> With mlock(), we don't need to use get_user_pages() at all.
> Timur> Arjan tells me the only time an mlocked page can move is
> Timur> with hot (un)plug of memory, but that isn't supported on
> Timur> the systems that we support. We actually prefer mlock()
> Timur> over get_user_pages(), because if the process dies, the
> Timur> locks automatically go away too.
>
> There actually is another way pages can move, with both
> get_user_pages() and mlock(): copy-on-write after a fork(). If
> userspace does a fork(), then all PTEs are marked read-only, and if
> the original process touches the page after the fork(), a new page
> will be allocated and mapped at the original virtual address.

Do we care about that? A straightforward scenario under which this can
happen is:

a) app starts some read I/O in an asynchronous manner
b) app forks
c) child writes to one of the pages which is still under read I/O
d) the read I/O completes
e) the child is left with the old data plus the child's modification instead
of the new data

which is a very silly application which is giving itself unpredictable
memory contents anyway.

I assume there's a more sensible scenario?