changeset 58444:c1fdb04213e9

8235908: omit ThreadPriorityPolicy warning when value is set from image Reviewed-by: dholmes, clanger, kvn
author mneugschwand
date Wed, 18 Mar 2020 15:59:07 -0700
parents af221c1b1671
children c2f7e63f72c4
files src/hotspot/os/aix/os_aix.cpp src/hotspot/os/bsd/os_bsd.cpp src/hotspot/os/linux/os_linux.cpp src/hotspot/share/runtime/flags/jvmFlag.cpp src/hotspot/share/runtime/flags/jvmFlag.hpp src/hotspot/share/runtime/globals_extension.hpp
diffstat 6 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os/aix/os_aix.cpp	Tue Mar 17 14:14:27 2020 +0000
+++ b/src/hotspot/os/aix/os_aix.cpp	Wed Mar 18 15:59:07 2020 -0700
@@ -2649,7 +2649,7 @@
 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.");
--- a/src/hotspot/os/bsd/os_bsd.cpp	Tue Mar 17 14:14:27 2020 +0000
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Wed Mar 18 15:59:07 2020 -0700
@@ -2277,7 +2277,7 @@
 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.");
--- a/src/hotspot/os/linux/os_linux.cpp	Tue Mar 17 14:14:27 2020 +0000
+++ b/src/hotspot/os/linux/os_linux.cpp	Wed Mar 18 15:59:07 2020 -0700
@@ -4332,7 +4332,7 @@
 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.");
--- a/src/hotspot/share/runtime/flags/jvmFlag.cpp	Tue Mar 17 14:14:27 2020 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp	Wed Mar 18 15:59:07 2020 -0700
@@ -153,6 +153,10 @@
   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 @@
   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");
--- a/src/hotspot/share/runtime/flags/jvmFlag.hpp	Tue Mar 17 14:14:27 2020 +0000
+++ b/src/hotspot/share/runtime/flags/jvmFlag.hpp	Wed Mar 18 15:59:07 2020 -0700
@@ -187,6 +187,7 @@
 
   bool is_default();
   bool is_ergonomic();
+  bool is_jimage_resource();
   bool is_command_line();
   void set_command_line();
 
--- a/src/hotspot/share/runtime/globals_extension.hpp	Tue Mar 17 14:14:27 2020 +0000
+++ b/src/hotspot/share/runtime/globals_extension.hpp	Wed Mar 18 15:59:07 2020 -0700
@@ -88,6 +88,7 @@
   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 @@
 #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))