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

8276663: Cleanup NMT AccessLock #6267

Closed

Conversation

zhengyu123
Copy link
Contributor

@zhengyu123 zhengyu123 commented Nov 4, 2021

Please review this cleanup patch to NMT AccessLock:

  • Make LockState enum private, no external use.
  • const lock location pointer
  • Use memory_order_acquire/memory_order_release for lock counter updates.

Test:

  • hotspot_nmt on x86_64 and aarch64

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6267/head:pull/6267
$ git checkout pull/6267

Update a local copy of the PR:
$ git checkout pull/6267
$ git pull https://git.openjdk.java.net/jdk pull/6267/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6267

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6267.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 4, 2021

👋 Welcome back zgu! 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 openjdk bot added the rfr label Nov 4, 2021
@openjdk
Copy link

openjdk bot commented Nov 4, 2021

@zhengyu123 The following label will be automatically applied to this pull request:

  • hotspot-runtime

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

@openjdk openjdk bot added the hotspot-runtime label Nov 4, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 4, 2021

Webrevs

@dholmes-ora
Copy link
Member

dholmes-ora commented Nov 5, 2021

Hi Zhengyu,

I do not understand this change. The "counter" is what makes the lock acts as a lock. Locks generally require acquire/release semantics wrt. to the locking and unlocking around a critical section. So how can you switch to use mo_relaxed?

David

@dholmes-ora
Copy link
Member

dholmes-ora commented Nov 5, 2021

To clarify a writeLock needs acquire on lock and release on unlock; the readLock only needs acquire on lock.

@shipilev
Copy link
Contributor

shipilev commented Nov 5, 2021

I do not understand this change. The "counter" is what makes the lock acts as a lock. Locks generally require acquire/release semantics wrt. to the locking and unlocking around a critical section. So how can you switch to use mo_relaxed?

+1. We cannot do this relaxation here, unless we also add explicit fences. I think the best we can do here is to "relax" mo_conservative (double-sided barrier) to mo_seqcst (which still have the memory ordering semantics we want for locks).

@zhengyu123
Copy link
Contributor Author

zhengyu123 commented Nov 5, 2021

Hi Zhengyu,

I do not understand this change. The "counter" is what makes the lock acts as a lock. Locks generally require acquire/release semantics wrt. to the locking and unlocking around a critical section. So how can you switch to use mo_relaxed?

David

Right, I am embarrassed. This is a lock, does have memory semantics.

Thanks,

-Zhengyu

@dholmes-ora
Copy link
Member

dholmes-ora commented Nov 6, 2021

I'm trying to reason about this but am struggling to understand how this "lock" is actually used. It isn't really a lock at all but a kind of access-latch: anyone can access things in normal operation but when we want to shutdown then we basically put up a closed sign, wait for all current users to leave and then do a reset. There are no critical sections as such and no related memory operations that this "lock" is guarding. So maybe it doesn't need any memory ordering after all. ??

@zhengyu123
Copy link
Contributor Author

zhengyu123 commented Nov 8, 2021

It has been a long time.

I reread the code. Yes, it is a kind of count-down-latch, which allows read-only walk to complete before list can be destroyed.

Now, I suspect that AccessLock is not sufficient, cause it does not guard against insertion.

I would like to withdraw this PR for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime rfr
3 participants