I4ATWY: introduce UsePSRelaxedForwardee to enable using relaxed CAS in copy_to_survivor_space

This commit is contained in:
kuenking111 2021-09-18 15:19:01 +08:00
parent 59d1889b62
commit b85b11260a
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,49 @@
diff --git a/src/hotspot/share/gc/parallel/parallel_globals.hpp b/src/hotspot/share/gc/parallel/parallel_globals.hpp
index 5461bf04f..75ee84d4f 100644
--- a/src/hotspot/share/gc/parallel/parallel_globals.hpp
+++ b/src/hotspot/share/gc/parallel/parallel_globals.hpp
@@ -78,6 +78,10 @@
"Delay in scheduling GC workers (in milliseconds)") \
\
product(bool, PSChunkLargeArrays, true, \
- "Process large arrays in chunks")
+ "Process large arrays in chunks") \
+ \
+ experimental(bool, UsePSRelaxedForwardee, false, \
+ "Use the UsePSRelaxedForwardee to enable ps use relaxed" \
+ "during young gc copying object")
#endif // SHARE_GC_PARALLEL_PARALLEL_GLOBALS_HPP
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
index cc5a4aa98..9bf45f82b 100644
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
@@ -218,8 +218,15 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size);
// Now we have to CAS in the header.
- // Make copy visible to threads reading the forwardee.
- if (o->cas_forward_to(new_obj, test_mark, o->klass()->oop_is_gc_leaf()? memory_order_relaxed : memory_order_release)) {
+ // When use relaxed CAS, cann't gurantee new obj visible for other threads accessing forwardee.
+ // As oop_is_gc_leaf is verified for long time without problems, for gc leaf's benefit, we add
+ // UsePSRelaxedForwardee to enable using relaxed CAS rather than delete oop_is_gc_leaf condition directly.
+#ifdef PRODUCT
+ if (o->cas_forward_to(new_obj, test_mark, (UsePSRelaxedForwardee || o->klass()->oop_is_gc_leaf()) ?
+ memory_order_relaxed : memory_order_release)) {
+#else
+ if (o->cas_forward_to(new_obj, test_mark, memory_order_release)) {
+#endif
// We won any races, we "own" this object.
assert(new_obj == o->forwardee(), "Sanity");
@@ -275,6 +282,10 @@ inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
// This code must come after the CAS test, or it will print incorrect
// information.
+ // When UsePSRelaxedForwardee is true or object o is gc leaf, CAS failed threads can't access forwardee's content,
+ // as relaxed CAS cann't gurantee new obj's content visible for these CAS failed threads.The below log output is
+ // dangerous.So we just support UsePSRelaxedForwardee and gc leaf in product.
+ // Everywhere access forwardee's content must be careful.
log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
should_scavenge(&new_obj) ? "copying" : "tenuring",
new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());

View File

@ -740,7 +740,7 @@ Provides: java-src%{?1} = %{epoch}:%{version}-%{release}
Name: java-%{javaver}-%{origin}
Version: %{newjavaver}.%{buildver}
Release: 2
Release: 3
# java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons
# and this change was brought into RHEL-4. java-1.5.0-ibm packages
# also included the epoch in their virtual provides. This created a
@ -862,6 +862,7 @@ Patch78: create-jfr-dump-file-with-pid-or-timestamp-if-specif.patch
Patch79: enhance-the-TimeZone-s-path-solution-on-Euler.patch
Patch80: Add-KAE-implementation.patch
Patch81: 8268427-Improve-AlgorithmConstraints-checkAlgorithm-.patch
Patch82: PS-introduce-UsePSRelaxedForwardee-to-enable-using-r.patch
BuildRequires: autoconf
BuildRequires: alsa-lib-devel
@ -1143,6 +1144,7 @@ pushd %{top_level_dir_name}
%patch79 -p1
%patch80 -p1
%patch81 -p1
%patch82 -p1
popd # openjdk
# %patch1000
@ -1645,6 +1647,9 @@ require "copy_jdk_configs.lua"
%changelog
* Sat Sep 18 2021 kuenking111 <wangkun49@huawei.com> - 1:11.0.12.7-3
- add PS-introduce-UsePSRelaxedForwardee-to-enable-using-r.patch
* Fri Sep 17 2021 kuenking111 <wangkun49@huawei.com> - 1:11.0.12.7-2
- add Update-algorithm-annotations-for-fill_words.patch
- add 8257145-Performance-regression-with-XX-ResizePLAB-af.patch