Skip to content

CORE-96: Sempar - Verify thread binding against its reservation - #211

Open
peter-lawrey wants to merge 7 commits into
developfrom
bugfix/core-96-sempar-aff-7
Open

peter-lawrey wants to merge 7 commits into
developfrom
bugfix/core-96-sempar-aff-7

Conversation

@peter-lawrey

@peter-lawrey peter-lawrey commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Seeing a thread run on the requested CPU does not tell a benchmark whether the OS can move it to another CPU. AffinityLock.checkBound() compares the caller’s reservation with its current native affinity mask.

  • VERIFIED means the caller owns a bound reservation and the mask allows only the reserved CPU.
  • MISMATCH covers an unallocated lock, another thread’s reservation, a reservation without binding, or a mask that allows a different or additional CPU.
  • UNKNOWN means the backend cannot supply a usable mask for that check.

The result includes a reason and a defensive copy of the observed mask when available. Affinity.describeCurrentThread() reports the thread name, backend and allowed mask. Both calls observe the current state without changing affinity.

The Linux writer records the native owner TID, UTC acquisition time, current owner's start time and PID namespace after the two legacy lines. A reservation transferred from thread A to B keeps its acquisition time. Java callers can read the same immutable observation through lock.reservationOwner() and AffinityLock.currentThreadReservation(). These lookups use in-memory state.

The branch incorporates the paired-acquisition rollback from #215. If the second CPU cannot be reserved, the first is released. Handoff updates use the held descriptor, including when the receiving thread is interrupted.

Linux verification on JDK 21 ran 92 module tests with 90 passed and two JNI clock tests skipped. A separate JVM observed a reserve, handoff, forced owner exit and subsequent reacquisition. The reader in #210 and JLBH's run-end report agreed on the live PID, native TID and UTC instants.

Release note

Affinity can report the native owner and age of a CPU reservation, including ownership transfers.

@peter-lawrey
peter-lawrey force-pushed the bugfix/core-96-sempar-aff-7 branch from 93587e4 to 76ac5fc Compare November 11, 2026 14:44
@peter-lawrey
peter-lawrey marked this pull request as ready for review November 11, 2026 18:12
@peter-lawrey
peter-lawrey requested a review from a team as a code owner November 11, 2026 18:12
@peter-lawrey peter-lawrey self-assigned this Nov 13, 2026

@amilbourne amilbourne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks OK - Although javadoc could be better

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants