RFR: 8263236: runtime/os/TestTracePageSizes.java fails on old kernels [v5]
Aleksey Shipilev
shade at openjdk.java.net
Thu May 6 18:15:31 UTC 2021
On Thu, 6 May 2021 14:24:53 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> Okay, I did a rough bisect over pre-built Debian kernels, and that points to `4.15` as the first kernel that works. I updated the PR changeset and PR description accordingly. I am still struggling to find a particular commit that solved it, so I can explain to myself why this works...
All right. Here is a kicker. Vanilla `4.14.17` kernel is passing the tests, while Debian's `4.14.17` fails it! Looking at Debian kernel patches, I see a few suspicious ones. Applying [these patches](https://salsa.debian.org/kernel-team/linux/-/commit/3f937de4507cf678ebfa53654bee5ffe20d76ad6) to vanilla `4.14.17` also makes the test fail. This hunk from that Debian's kernel patch is apparently the problem:
diff --git a/include/linux/mman.h b/include/linux/mman.h
index 7c87b6652244..f22c15d5e24c 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -87,7 +87,8 @@ calc_vm_flag_bits(unsigned long flags)
{
return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
_calc_vm_trans(flags, MAP_DENYWRITE, VM_DENYWRITE ) |
- _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED );
+ _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
+ _calc_vm_trans(flags, MAP_FIXED, VM_FIXED );
}
It copies the mmap tags to the VMA flag. Now, that thing is getting printed in [show_smap_vma_flags](https://github.com/torvalds/linux/blob/master/fs/proc/task_mmu.c#L603-L681). Notice how that method prepares itself for missing flag cases by [printing `??`](https://github.com/torvalds/linux/blob/master/fs/proc/task_mmu.c#L609-L612). Indeed, Debian patch misses that addition, so we see `??` for some entries in `/proc/smaps`.
How's that a problem for this test? Stare at this regexp:
String smapsPatternString = "(\\w+)-(\\w+).*?" +
"KernelPageSize:\\s*(\\d*) kB.*?" +
"VmFlags: ([\\w ]*)";
`?` is _not_ `\w`, so the entire thing mismatches the moment the VMA flags have `??` in them.
And this only happens on some Debian kernels, because you have to have that new unhandled flag. This also explains why `4.15` works, the [later commit](https://salsa.debian.org/kernel-team/linux/-/commit/7dd9b58675f9c285944cd6b12199481765c932a0#b23bf90ba1c0322d4a1bb8ace6fac27f98426b10_21_21) redefined that new flag to existing, handled value for `VM_ARCH`.
So this is deserves a simple fix in the regexp itself:
- "VmFlags: ([\\w ]*)";
+ "VmFlags: ([\\w\? ]*)";
Testing that now...
-------------
PR: https://git.openjdk.java.net/jdk/pull/3415
More information about the hotspot-runtime-dev
mailing list