Register linear-alloc with uffd before mremap

Currently, when preparing the moving-space and linear-alloc for
concurrent compaction in the compaction pause, we mremap them first and
then do userfaultfd registration. While this is sufficient for the
moving-space, being part of the java-heap and hence protected by
mutator-lock, it leaves a gap for suspended threads. In between the
operations, if a thread accesses some page on the linear-alloc, then it
doesn't trigger userfault and instead gets a zero-page mapped, resulting
in non-deterministic failures (usually null pointer exceptions).

The right approach is to first register linear-alloc with userfaultfd
and then mremap. This ensures that suspended threads would either access
the page with contents or would trigger userfault.

Bug: 160737021
Test: manual (install module and observe the device for any tombstones
with null-pointer exceptions.

Change-Id: I0420974e0131b43c25bcb135eee4f9c438f46ad2
(cherry picked from commit 0430a13499375efc415bd16af301059e21fb2041)
Merged-In: I0420974e0131b43c25bcb135eee4f9c438f46ad2
2 files changed