Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8293007: riscv: failed to build after JDK-8290025 #10056

Closed
wants to merge 4 commits into from

Conversation

yadongw
Copy link
Contributor

@yadongw yadongw commented Aug 27, 2022

The riscv port tier1 failed after JDK-8290025,after which GC took over the work of code cache sweeping.
Then, concurrent GC like ZGC or Shenandoah failed at the unimplemented BarreirSetNMethod::arm(), and meanwhile, it exposed a long-stand bug in G1BarrierSetAssembler::g1_write_barrier_pre().

Considering we are at the same time to rewrite the nmethod entry barrier when porting loom and generational ZGC in riscv port, we solve them together in this issue to make things smooth.

Like JDK-8290700, we brought the similar optimization to the nmethod entry barrier, and introduced a out-of-line stub to the entry barriers of C2 methods, and also a concurrent-data-and instruction-patching barrier.

Tier1 passed on unmatched, and also full jtreg tests tested on qemu user mode without new failures.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8293007: riscv: failed to build after JDK-8290025

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10056/head:pull/10056
$ git checkout pull/10056

Update a local copy of the PR:
$ git checkout pull/10056
$ git pull https://git.openjdk.org/jdk pull/10056/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10056

View PR using the GUI difftool:
$ git pr show -t 10056

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10056.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 27, 2022

👋 Welcome back yadongwang! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Aug 27, 2022

@yadongw The following labels will be automatically applied to this pull request:

  • hotspot
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Aug 27, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 27, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 27, 2022

Webrevs

Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

The riscv-specific code changes look fine. And I see the changes made to hotspot shared code are small and are guarded with #if defined(RISCV), which is the same as how aarch64 does, this should be safe and won't affect other platforms.

BTW: I also performed tier2 hotspot & jdk test on riscv64-linux unmatched machine, result looks good.

@openjdk
Copy link

openjdk bot commented Aug 29, 2022

@yadongw This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8293007: riscv: failed to build after JDK-8290025

Reviewed-by: fyang, fjiang, shade

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 10 new commits pushed to the master branch:

  • 9424d6d: 8293012: ConstantPool::print_on can crash if _cache is NULL
  • 40b0ed5: 8292891: ifdef-out some CDS-only functions
  • adb3d4f: 8292694: x86_64 c2i/i2c adapters may use more stack space than necessary
  • 30def49: 8292769: [JVMCI] OutOfMemoryError thrown when attaching the libgraal isolate causes HotSpot to crash.
  • a88a9e3: 8291466: C2: assert(false) failed: infinite loop in PhaseIterGVN::transform_old with -XX:+StressIGVN
  • d5167a9: 7189422: [macosx] Submenu's arrow have a wrong position
  • 512fee1: 8292972: Initialize fields if CodeBlobIterator shortcuts without heaps
  • a476ec5: 8292983: ModuleReferenceImpl.computeHash should record algorithm for cache checks
  • 99cab6a: 8292911: Add a note about jtreg failure handlers in the testing doc
  • f6b6360: 8289949: Improve test coverage for XPath: operators

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@RealFYang, @shipilev) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 29, 2022
Copy link
Member

@feilongjiang feilongjiang left a comment

Choose a reason for hiding this comment

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

Looks good. (Not a JDK Reviewer)

@yadongw
Copy link
Contributor Author

yadongw commented Aug 29, 2022

Better have another review, maybe @shipilev please?

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks okay with minor comments.


__ push_reg(saved, sp);
__ push_call_clobbered_registers();
Copy link
Member

Choose a reason for hiding this comment

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

So this looks like a bugfix? https://mail.openjdk.org/pipermail/riscv-port-dev/2022-August/000601.html

The issue and PR should probably reflect that then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I have modified issue and PR.

}

void BarrierSetAssembler::clear_patching_epoch() {
_patching_epoch = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want Atomic::store(&_patching_epoch, 0) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do a relax clear here, because clear_patching_epoch() was only called by arm_all_nmethods(), which happened always in the safepoint.

Copy link
Member

Choose a reason for hiding this comment

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

Allright then.

// With STW patching, no data or instructions are updated concurrently,
// which means there isn't really any need for any fencing for neither
// data nor instruction modification happening concurrently. The
// instruction patching is synchronized with glocal icache_flush() by
Copy link
Member

Choose a reason for hiding this comment

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

"global"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed.

// is performed with a release store. In the nmethod entry barrier, the values
// are read in the opposite order, such that the load of the nmethod guard
// acquires the patching epoch. This way, the guard is guaranteed to block
// entries to the nmethod, util it has safely published the requirement for
Copy link
Member

Choose a reason for hiding this comment

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

"until"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 29, 2022
@yadongw yadongw changed the title 8293007: riscv: optimize nmethod entry barrier 8293007: riscv: failed to build after JDK-8290025 Aug 29, 2022
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 29, 2022
@yadongw
Copy link
Contributor Author

yadongw commented Aug 30, 2022

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 30, 2022
@openjdk
Copy link

openjdk bot commented Aug 30, 2022

@yadongw
Your change (at version 2bcc033) is now ready to be sponsored by a Committer.

@RealFYang
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 30, 2022

Going to push as commit e016363.
Since your change was applied there have been 10 commits pushed to the master branch:

  • 9424d6d: 8293012: ConstantPool::print_on can crash if _cache is NULL
  • 40b0ed5: 8292891: ifdef-out some CDS-only functions
  • adb3d4f: 8292694: x86_64 c2i/i2c adapters may use more stack space than necessary
  • 30def49: 8292769: [JVMCI] OutOfMemoryError thrown when attaching the libgraal isolate causes HotSpot to crash.
  • a88a9e3: 8291466: C2: assert(false) failed: infinite loop in PhaseIterGVN::transform_old with -XX:+StressIGVN
  • d5167a9: 7189422: [macosx] Submenu's arrow have a wrong position
  • 512fee1: 8292972: Initialize fields if CodeBlobIterator shortcuts without heaps
  • a476ec5: 8292983: ModuleReferenceImpl.computeHash should record algorithm for cache checks
  • 99cab6a: 8292911: Add a note about jtreg failure handlers in the testing doc
  • f6b6360: 8289949: Improve test coverage for XPath: operators

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 30, 2022
@openjdk openjdk bot closed this Aug 30, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Aug 30, 2022
@openjdk
Copy link

openjdk bot commented Aug 30, 2022

@RealFYang @yadongw Pushed as commit e016363.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@vnkozlov
Copy link
Contributor

@yadongw this broke aarch64 Zero build:

/workspace/open/src/hotspot/share/gc/shared/barrierSetNMethod.cpp: In member function 'void BarrierSetNMethod::arm_all_nmethods()':
/workspace/open/src/hotspot/share/gc/shared/barrierSetNMethod.cpp:136:24: error: incomplete type 'BarrierSetAssembler' used in nested name specifier
   136 |   BarrierSetAssembler::clear_patching_epoch();
       |                        ^~~~~~~~~~~~~~~~~~~~

@feilongjiang
Copy link
Member

@yadongw this broke aarch64 Zero build:

/workspace/open/src/hotspot/share/gc/shared/barrierSetNMethod.cpp: In member function 'void BarrierSetNMethod::arm_all_nmethods()':
/workspace/open/src/hotspot/share/gc/shared/barrierSetNMethod.cpp:136:24: error: incomplete type 'BarrierSetAssembler' used in nested name specifier
   136 |   BarrierSetAssembler::clear_patching_epoch();
       |                        ^~~~~~~~~~~~~~~~~~~~

Thanks for reporting this issue, I'm working on it and will submit a fixing PR later.

@yadongw
Copy link
Contributor Author

yadongw commented Aug 30, 2022

@yadongw this broke aarch64 Zero build:

/workspace/open/src/hotspot/share/gc/shared/barrierSetNMethod.cpp: In member function 'void BarrierSetNMethod::arm_all_nmethods()':
/workspace/open/src/hotspot/share/gc/shared/barrierSetNMethod.cpp:136:24: error: incomplete type 'BarrierSetAssembler' used in nested name specifier
   136 |   BarrierSetAssembler::clear_patching_epoch();
       |                        ^~~~~~~~~~~~~~~~~~~~

@vnkozlov Sorry for the problem. I missed the building/testing of zero, and we'll fix that right way.

@feilongjiang
Copy link
Member

See: #10075

Copy link
Contributor

@fisk fisk left a comment

Choose a reason for hiding this comment

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

Sorry for the late feedback but I'm not sure this looks right.

__ la(t1, ExternalAddress(bs_asm->patching_epoch_addr()));
__ lwu(t1, t1);
__ sw(t1, thread_epoch_addr);
__ membar(__ LoadLoad);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you need a FENCE.I instruction here? Similar to the AArch64 isb instruction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need a fence.i here in the riscv port , see our discussion in https://mail.openjdk.org/pipermail/riscv-port- dev/2022-July/000572.html.

In the riscv world, fence.i in user-space cannot guarante the read hart see the modified code because threads may migrate to other processor core after fence.i. Instead, we called icache_flush() after the write hart modified code, which synchronized all harts to flush icache by IPI in kernel mode. So the read hart do not need a fence.i.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated shenandoah shenandoah-dev@openjdk.org
6 participants