Skip to content

Commit

Permalink
8276801: gc/stress/CriticalNativeStress.java fails intermittently wit…
Browse files Browse the repository at this point in the history
…h Shenandoah

Backport-of: 73e6d7d74d2ddd27f11775944c6fc4fb5268106d
  • Loading branch information
zhengyu123 committed Nov 19, 2021
1 parent 19201da commit acecce5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void ShenandoahCodeRoots::initialize() {
}

void ShenandoahCodeRoots::register_nmethod(nmethod* nm) {
assert_locked_or_safepoint(CodeCache_lock);
assert(CodeCache_lock->owned_by_self(), "Must have CodeCache_lock held");
_nmethod_table->register_nmethod(nm);
}

Expand All @@ -121,7 +121,7 @@ void ShenandoahCodeRoots::unregister_nmethod(nmethod* nm) {
}

void ShenandoahCodeRoots::flush_nmethod(nmethod* nm) {
assert_locked_or_safepoint(CodeCache_lock);
assert(CodeCache_lock->owned_by_self(), "Must have CodeCache_lock held");
_nmethod_table->flush_nmethod(nm);
}

Expand Down
8 changes: 7 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,17 @@ void ShenandoahNMethodTable::register_nmethod(nmethod* nm) {
assert(_index >= 0 && _index <= _list->size(), "Sanity");

ShenandoahNMethod* data = ShenandoahNMethod::gc_data(nm);
ShenandoahReentrantLocker data_locker(data != NULL ? data->lock() : NULL);

if (data != NULL) {
assert(contain(nm), "Must have been registered");
assert(nm == data->nm(), "Must be same nmethod");
// Prevent updating a nmethod while concurrent iteration is in progress.
wait_until_concurrent_iteration_done();
ShenandoahReentrantLocker data_locker(data->lock());
data->update();
} else {
// For a new nmethod, we can safely append it to the list, because
// concurrent iteration will not touch it.
data = ShenandoahNMethod::for_nmethod(nm);
assert(data != NULL, "Sanity");
ShenandoahNMethod::attach_gc_data(nm, data);
Expand Down Expand Up @@ -382,11 +386,13 @@ void ShenandoahNMethodTable::rebuild(int size) {
}

ShenandoahNMethodTableSnapshot* ShenandoahNMethodTable::snapshot_for_iteration() {
assert(CodeCache_lock->owned_by_self(), "Must have CodeCache_lock held");
_itr_cnt++;
return new ShenandoahNMethodTableSnapshot(this);
}

void ShenandoahNMethodTable::finish_iteration(ShenandoahNMethodTableSnapshot* snapshot) {
assert(CodeCache_lock->owned_by_self(), "Must have CodeCache_lock held");
assert(iteration_in_progress(), "Why we here?");
assert(snapshot != NULL, "No snapshot");
_itr_cnt--;
Expand Down

3 comments on commit acecce5

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@earthling-amzn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on acecce5 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@earthling-amzn Could not automatically backport acecce5a to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp
  • src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk11u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk11u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b earthling-amzn-backport-acecce5a

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk17u.git acecce5ab875e98f0a06a9063b0fb3e6fb6cd38e

# Backport the commit
$ git cherry-pick --no-commit acecce5ab875e98f0a06a9063b0fb3e6fb6cd38e
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport acecce5ab875e98f0a06a9063b0fb3e6fb6cd38e'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport acecce5ab875e98f0a06a9063b0fb3e6fb6cd38e.

Please sign in to comment.