Skip to content
Permalink
Browse files
8235908: omit ThreadPriorityPolicy warning when value is set from image
Reviewed-by: dholmes, clanger, kvn
  • Loading branch information
Matthias Neugschwandtner committed Mar 18, 2020
1 parent 44eca82 commit 99546049b3a3f901376938368afaf3499eb1a701
@@ -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.");
@@ -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.");
@@ -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.");
@@ -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");
@@ -187,6 +187,7 @@ struct JVMFlag {

bool is_default();
bool is_ergonomic();
bool is_jimage_resource();
bool is_command_line();
void set_command_line();

@@ -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))

0 comments on commit 9954604

Please sign in to comment.