8214816: os::read() should not transition to _thread_blocked with safepoint check on Solaris

Reviewed-by: jiangli, mgronlun
This commit is contained in:
David Holmes 2019-01-13 16:54:01 -05:00
parent 1c5496ac8b
commit c6653432a5
14 changed files with 24 additions and 96 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -2594,14 +2594,6 @@ char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
return addr;
}
size_t os::read(int fd, void *buf, unsigned int nBytes) {
return ::read(fd, buf, nBytes);
}
size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
return ::pread(fd, buf, nBytes, offset);
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION
void os::infinite_sleep() {
while (true) { // sleep forever ...

View File

@ -98,12 +98,6 @@ inline int os::ftruncate(int fd, jlong length) {
inline bool os::numa_has_static_binding() { ShouldNotReachHere(); return true; }
inline bool os::numa_has_group_homing() { ShouldNotReachHere(); return false; }
inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
size_t res;
RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
return res;
}
inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
size_t res;
RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);

View File

@ -2217,14 +2217,6 @@ char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
}
}
size_t os::read(int fd, void *buf, unsigned int nBytes) {
RESTARTABLE_RETURN_INT(::read(fd, buf, nBytes));
}
size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
RESTARTABLE_RETURN_INT(::pread(fd, buf, nBytes, offset));
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION
void os::infinite_sleep() {
while (true) { // sleep forever ...

View File

@ -100,12 +100,6 @@ inline int os::ftruncate(int fd, jlong length) {
inline bool os::numa_has_static_binding() { return true; }
inline bool os::numa_has_group_homing() { return false; }
inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
size_t res;
RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
return res;
}
inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
size_t res;
RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);

View File

@ -4027,14 +4027,6 @@ char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) {
}
}
size_t os::read(int fd, void *buf, unsigned int nBytes) {
return ::read(fd, buf, nBytes);
}
size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
return ::pread(fd, buf, nBytes, offset);
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION
void os::infinite_sleep() {
while (true) { // sleep forever ...

View File

@ -92,12 +92,6 @@ inline int os::ftruncate(int fd, jlong length) {
inline bool os::numa_has_static_binding() { return true; }
inline bool os::numa_has_group_homing() { return false; }
inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
size_t res;
RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
return res;
}
inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
size_t res;
RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2019, 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
@ -554,6 +554,10 @@ FILE* os::open(int fd, const char* mode) {
return ::fdopen(fd, mode);
}
ssize_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
return ::pread(fd, buf, nBytes, offset);
}
void os::flockfile(FILE* fp) {
::flockfile(fp);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -2844,33 +2844,6 @@ bool os::can_execute_large_page_memory() {
return true;
}
// Read calls from inside the vm need to perform state transitions
size_t os::read(int fd, void *buf, unsigned int nBytes) {
size_t res;
JavaThread* thread = (JavaThread*)Thread::current();
assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
ThreadBlockInVM tbiv(thread);
RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
return res;
}
size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
size_t res;
JavaThread* thread = (JavaThread*)Thread::current();
assert(thread->thread_state() == _thread_in_vm, "Assumed _thread_in_vm");
ThreadBlockInVM tbiv(thread);
RESTARTABLE(::pread(fd, buf, (size_t) nBytes, offset), res);
return res;
}
size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
size_t res;
assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
"Assumed _thread_in_native");
RESTARTABLE(::read(fd, buf, (size_t) nBytes), res);
return res;
}
// Sleep forever; naked call to OS-specific sleep; use with CAUTION
void os::infinite_sleep() {
while (true) { // sleep forever ...

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -4539,7 +4539,7 @@ jlong os::lseek(int fd, jlong offset, int whence) {
return (jlong) ::_lseeki64(fd, offset, whence);
}
size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
ssize_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
OVERLAPPED ov;
DWORD nread;
BOOL result;

View File

@ -70,14 +70,6 @@ inline void os::map_stack_shadow_pages(address sp) {
inline bool os::numa_has_static_binding() { return true; }
inline bool os::numa_has_group_homing() { return false; }
inline size_t os::read(int fd, void *buf, unsigned int nBytes) {
return ::read(fd, buf, nBytes);
}
inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
return ::read(fd, buf, nBytes);
}
inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
return ::write(fd, buf, nBytes);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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
@ -94,11 +94,13 @@ bool DirectivesParser::parse_from_file_inner(const char* filename, outputStream*
if (file_handle != -1) {
// read contents into resource array
char* buffer = NEW_RESOURCE_ARRAY(char, st.st_size+1);
size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
buffer[num_read] = '\0';
// close file
os::close(file_handle);
return parse_string(buffer, stream) > 0;
ssize_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
if (num_read >= 0) {
buffer[num_read] = '\0';
// close file
os::close(file_handle);
return parse_string(buffer, stream) > 0;
}
}
}
return false;

View File

@ -3283,11 +3283,7 @@ jint Arguments::parse_vm_options_file(const char* file_name, ScopedVMInitArgs* v
memset(buf, 0, bytes_alloc);
// Fill buffer
// Use ::read() instead of os::read because os::read()
// might do a thread state transition
// and it is too early for that here
ssize_t bytes_read = ::read(fd, (void *)buf, (unsigned)bytes_alloc);
ssize_t bytes_read = os::read(fd, (void *)buf, (unsigned)bytes_alloc);
os::close(fd);
if (bytes_read < 0) {
FREE_C_HEAP_ARRAY(char, buf);

View File

@ -539,9 +539,8 @@ class os: AllStatic {
//File i/o operations
static size_t read(int fd, void *buf, unsigned int nBytes);
static size_t read_at(int fd, void *buf, unsigned int nBytes, jlong offset);
static size_t restartable_read(int fd, void *buf, unsigned int nBytes);
static ssize_t read(int fd, void *buf, unsigned int nBytes);
static ssize_t read_at(int fd, void *buf, unsigned int nBytes, jlong offset);
static size_t write(int fd, const void *buf, unsigned int nBytes);
// Reading directories.

View File

@ -27,6 +27,10 @@
#include "runtime/os.hpp"
inline ssize_t os::read(int fd, void *buf, unsigned int nBytes) {
return ::read(fd, buf, nBytes);
}
#include OS_HEADER_INLINE(os)
#endif // SHARE_RUNTIME_OS_INLINE_HPP