5765 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages. 5766 void TestReserveMemorySpecial_test() { 5767 if (!UseLargePages) { 5768 if (VerboseInternalVMTests) { 5769 gclog_or_tty->print("Skipping test because large pages are disabled"); 5770 } 5771 return; 5772 } 5773 // save current value of globals 5774 bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation; 5775 bool old_use_numa_interleaving = UseNUMAInterleaving; 5776 5777 // set globals to make sure we hit the correct code path 5778 UseLargePagesIndividualAllocation = UseNUMAInterleaving = false; 5779 5780 // do an allocation at an address selected by the OS to get a good one. 5781 const size_t large_allocation_size = os::large_page_size() * 4; 5782 char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false); 5783 if (result == NULL) { 5784 if (VerboseInternalVMTests) { 5785 gclog_or_tty->print("Failed to allocate control block with size "SIZE_FORMAT". Skipping remainder of test.", 5786 large_allocation_size); 5787 } 5788 } else { 5789 os::release_memory_special(result, large_allocation_size); 5790 5791 // allocate another page within the recently allocated memory area which seems to be a good location. At least 5792 // we managed to get it once. 5793 const size_t expected_allocation_size = os::large_page_size(); 5794 char* expected_location = result + os::large_page_size(); 5795 char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false); 5796 if (actual_location == NULL) { 5797 if (VerboseInternalVMTests) { 5798 gclog_or_tty->print("Failed to allocate any memory at "PTR_FORMAT" size "SIZE_FORMAT". Skipping remainder of test.", 5799 expected_location, large_allocation_size); 5800 } 5801 } else { 5802 // release memory 5803 os::release_memory_special(actual_location, expected_allocation_size); 5804 // only now check, after releasing any memory to avoid any leaks. 5805 assert(actual_location == expected_location, 5806 err_msg("Failed to allocate memory at requested location "PTR_FORMAT" of size "SIZE_FORMAT", is "PTR_FORMAT" instead", 5807 expected_location, expected_allocation_size, actual_location)); 5808 } 5809 } 5810 5811 // restore globals 5812 UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation; 5813 UseNUMAInterleaving = old_use_numa_interleaving; 5814 } 5815 #endif // PRODUCT 5816 | 5765 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages. 5766 void TestReserveMemorySpecial_test() { 5767 if (!UseLargePages) { 5768 if (VerboseInternalVMTests) { 5769 gclog_or_tty->print("Skipping test because large pages are disabled"); 5770 } 5771 return; 5772 } 5773 // save current value of globals 5774 bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation; 5775 bool old_use_numa_interleaving = UseNUMAInterleaving; 5776 5777 // set globals to make sure we hit the correct code path 5778 UseLargePagesIndividualAllocation = UseNUMAInterleaving = false; 5779 5780 // do an allocation at an address selected by the OS to get a good one. 5781 const size_t large_allocation_size = os::large_page_size() * 4; 5782 char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false); 5783 if (result == NULL) { 5784 if (VerboseInternalVMTests) { 5785 gclog_or_tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.", 5786 large_allocation_size); 5787 } 5788 } else { 5789 os::release_memory_special(result, large_allocation_size); 5790 5791 // allocate another page within the recently allocated memory area which seems to be a good location. At least 5792 // we managed to get it once. 5793 const size_t expected_allocation_size = os::large_page_size(); 5794 char* expected_location = result + os::large_page_size(); 5795 char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false); 5796 if (actual_location == NULL) { 5797 if (VerboseInternalVMTests) { 5798 gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.", 5799 expected_location, large_allocation_size); 5800 } 5801 } else { 5802 // release memory 5803 os::release_memory_special(actual_location, expected_allocation_size); 5804 // only now check, after releasing any memory to avoid any leaks. 5805 assert(actual_location == expected_location, 5806 err_msg("Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead", 5807 expected_location, expected_allocation_size, actual_location)); 5808 } 5809 } 5810 5811 // restore globals 5812 UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation; 5813 UseNUMAInterleaving = old_use_numa_interleaving; 5814 } 5815 #endif // PRODUCT 5816 |