Skip to content

Commit e3f3647

Browse files
committed
8280056: gtest/LargePageGtests.java#use-large-pages failed "os.release_one_mapping_multi_commits_vm"
Backport-of: 66520be7a752ebade6c88d164bc87c4bfcfce40a
1 parent f2a013b commit e3f3647

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

test/hotspot/gtest/runtime/test_os.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@ TEST_VM(os, release_multi_mappings) {
504504

505505
// ...re-reserve the middle stripes. This should work unless release silently failed.
506506
address p2 = (address)os::attempt_reserve_memory_at((char*)p_middle_stripes, middle_stripe_len);
507+
507508
ASSERT_EQ(p2, p_middle_stripes);
509+
508510
PRINT_MAPPINGS("C");
509511

510512
// Clean up. Release all mappings.
@@ -548,26 +550,29 @@ TEST_VM(os, release_bad_ranges) {
548550
TEST_VM(os, release_one_mapping_multi_commits) {
549551
// Test that we can release an area consisting of interleaved
550552
// committed and uncommitted regions:
551-
const size_t stripe_len = 4 * M;
552-
const int num_stripes = 4;
553+
const size_t stripe_len = os::vm_allocation_granularity();
554+
const int num_stripes = 6;
553555
const size_t total_range_len = stripe_len * num_stripes;
554556

555557
// reserve address space...
556558
address p = reserve_one_commit_multiple(num_stripes, stripe_len);
557-
ASSERT_NE(p, (address)NULL);
558559
PRINT_MAPPINGS("A");
560+
ASSERT_NE(p, (address)nullptr);
559561

560-
// .. release it...
561-
ASSERT_TRUE(os::release_memory((char*)p, total_range_len));
562+
// // make things even more difficult by trying to reserve at the border of the region
563+
address border = p + num_stripes * stripe_len;
564+
address p2 = (address)os::attempt_reserve_memory_at((char*)border, stripe_len);
562565
PRINT_MAPPINGS("B");
563566

564-
// re-reserve it. This should work unless release failed.
565-
address p2 = (address)os::attempt_reserve_memory_at((char*)p, total_range_len);
566-
ASSERT_EQ(p2, p);
567-
PRINT_MAPPINGS("C");
567+
ASSERT_TRUE(p2 == nullptr || p2 == border);
568568

569569
ASSERT_TRUE(os::release_memory((char*)p, total_range_len));
570-
PRINT_MAPPINGS("D");
570+
PRINT_MAPPINGS("C");
571+
572+
if (p2 != nullptr) {
573+
ASSERT_TRUE(os::release_memory((char*)p2, stripe_len));
574+
PRINT_MAPPINGS("D");
575+
}
571576
}
572577

573578
static void test_show_mappings(address start, size_t size) {

0 commit comments

Comments
 (0)