Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

8288846: misc tests fail "assert(ms < 1000) failed: Un-interruptable sleep, short time use only" #57

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/hotspot/share/jfr/periodic/sampling/jfrThreadSampler.cpp
Expand Up @@ -504,6 +504,12 @@ void JfrThreadSampler::run() {
const int64_t java_period_millis = _java_period_millis == 0 ? max_jlong : MAX2<int64_t>(_java_period_millis, 1);
const int64_t native_period_millis = _native_period_millis == 0 ? max_jlong : MAX2<int64_t>(_native_period_millis, 1);

// If both period fields are 0, it implies the sampler is in the process
// of disenrolling. Loop back for graceful disenroll by means of the semaphore.
if (java_period_millis == max_jlong && native_period_millis == max_jlong) {
continue;
}

const int64_t now_ms = get_monotonic_ms();

/*
Expand All @@ -521,7 +527,7 @@ void JfrThreadSampler::run() {
const int64_t sleep_to_next = MIN2<int64_t>(next_j, next_n);

if (sleep_to_next > 0) {
os::naked_short_sleep(sleep_to_next);
os::naked_sleep(sleep_to_next);
}

if ((next_j - sleep_to_next) <= 0) {
Expand Down
7 changes: 5 additions & 2 deletions test/jdk/jdk/jfr/event/sampling/TestNative.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -48,9 +48,12 @@ public class TestNative {

static volatile boolean alive = true;

// Please resist the temptation to speed up the test by decreasing
// the period. It is explicity set to 1100 ms to provoke the 1000 ms
// threshold in the JVM for os::naked_short_sleep().
public static void main(String[] args) throws Exception {
try (RecordingStream rs = new RecordingStream()) {
rs.enable(NATIVE_EVENT).withPeriod(Duration.ofMillis(1));
rs.enable(NATIVE_EVENT).withPeriod(Duration.ofMillis(1100));
rs.onEvent(NATIVE_EVENT, e -> {
alive = false;
rs.close();
Expand Down