8235908: omit ThreadPriorityPolicy warning when value is set from image

Reviewed-by: dholmes, clanger, kvn
This commit is contained in:
Matthias Neugschwandtner 2020-03-18 15:59:07 -07:00
parent 44eca823aa
commit 99546049b3
6 changed files with 16 additions and 3 deletions

View File

@ -2649,7 +2649,7 @@ int os::java_to_os_priority[CriticalPriority + 1] = {
static int prio_init() {
if (ThreadPriorityPolicy == 1) {
if (geteuid() != 0) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy) && !FLAG_IS_JIMAGE_RESOURCE(ThreadPriorityPolicy)) {
warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \
"e.g., being the root user. If the necessary permission is not " \
"possessed, changes to priority will be silently ignored.");

View File

@ -2277,7 +2277,7 @@ int os::java_to_os_priority[CriticalPriority + 1] = {
static int prio_init() {
if (ThreadPriorityPolicy == 1) {
if (geteuid() != 0) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy) && !FLAG_IS_JIMAGE_RESOURCE(ThreadPriorityPolicy)) {
warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \
"e.g., being the root user. If the necessary permission is not " \
"possessed, changes to priority will be silently ignored.");

View File

@ -4332,7 +4332,7 @@ int os::java_to_os_priority[CriticalPriority + 1] = {
static int prio_init() {
if (ThreadPriorityPolicy == 1) {
if (geteuid() != 0) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy) && !FLAG_IS_JIMAGE_RESOURCE(ThreadPriorityPolicy)) {
warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \
"e.g., being the root user. If the necessary permission is not " \
"possessed, changes to priority will be silently ignored.");

View File

@ -153,6 +153,10 @@ bool JVMFlag::is_command_line() {
return (_flags & ORIG_COMMAND_LINE) != 0;
}
bool JVMFlag::is_jimage_resource() {
return (get_origin() == JIMAGE_RESOURCE);
}
void JVMFlag::set_command_line() {
_flags = Flags(_flags | ORIG_COMMAND_LINE);
}
@ -839,6 +843,12 @@ bool JVMFlagEx::is_cmdline(JVMFlagsEnum flag) {
return flag_from_enum(flag)->is_command_line();
}
bool JVMFlagEx::is_jimage_resource(JVMFlagsEnum flag) {
assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
JVMFlag* f = &JVMFlag::flags[flag];
return f->is_jimage_resource();
}
void JVMFlagEx::setOnCmdLine(JVMFlagsEnum flag) {
JVMFlag* faddr = flag_from_enum(flag);
assert(faddr != NULL, "Unknown flag");

View File

@ -187,6 +187,7 @@ public:
bool is_default();
bool is_ergonomic();
bool is_jimage_resource();
bool is_command_line();
void set_command_line();

View File

@ -88,6 +88,7 @@ class JVMFlagEx : JVMFlag {
static bool is_default(JVMFlagsEnum flag);
static bool is_ergo(JVMFlagsEnum flag);
static bool is_cmdline(JVMFlagsEnum flag);
static bool is_jimage_resource(JVMFlagsEnum flag);
static void setOnCmdLine(JVMFlagsEnum flag);
@ -132,6 +133,7 @@ ALL_FLAGS(FLAG_MEMBER_SET_DEVELOP,
#define FLAG_IS_DEFAULT(name) (JVMFlagEx::is_default(FLAG_MEMBER_ENUM(name)))
#define FLAG_IS_ERGO(name) (JVMFlagEx::is_ergo(FLAG_MEMBER_ENUM(name)))
#define FLAG_IS_CMDLINE(name) (JVMFlagEx::is_cmdline(FLAG_MEMBER_ENUM(name)))
#define FLAG_IS_JIMAGE_RESOURCE(name) (JVMFlagEx::is_jimage_resource(FLAG_MEMBER_ENUM(name)))
#define FLAG_SET_DEFAULT(name, value) ((name) = (value))