JDK-8215962 : Support ThreadPriorityPolicy mode 1 for non-root users on linux/bsd
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9,10,11,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-12-28
  • Updated: 2019-10-02
  • Resolved: 2019-01-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 JDK 13
11.0.3Fixed 12.0.1Fixed 13 b03Fixed
Description
Currently, when ThreadPriorityPolicy is set to 1  (so called Aggressive mode), on linux and bsd(+Mac) a root-user-check  (geteuid() != 0)) is done.
See for example the coding in  jdk/src/hotspot/os/linux/os_linux.cpp int prio_init().

However the root-user-check has a few drawbacks:
- it blocks the capabilities feature available on current Linux distros (CAP_SYS_NICE capability) that can be used to allow setting lower niceness also for non-root
- setting a higher "niceness" (lower priority) is not possible on Linux for non-root because of the geteuid check
Comments
Fix Request This small enhancement should be backported to JDK 11 and 12 because otherwise there's a regression which can't be mitigated for users that made use of this unintentional behavior in JDK 8 to reduce thread priorities. The patch applies cleanly to both, jdk11u and jdk12u.
31-01-2019

Yes but that was NOT intentional!
11-01-2019

Before adding the range check for (0,1) for the flag in JDK 9 it was possible to workaround this limitation by setting any value !=0,1.
11-01-2019