@@ -589,6 +589,7 @@ static const struct limit_names lnames[RLIM_NLIMITS] = {
[RLIMIT_NICE] = {"Max nice priority", NULL},
[RLIMIT_RTPRIO] = {"Max realtime priority", NULL},
[RLIMIT_RTTIME] = {"Max realtime timeout", "us"},
+ [RLIMIT_GPUPRIO] = {"Max DRM GPU priority", NULL},
};
/* Display limits for a process */
@@ -3,7 +3,7 @@
#define _ASM_GENERIC_RESOURCE_H
#include <uapi/asm-generic/resource.h>
-
+#include <drm/drm_sched_priority.h>
/*
* boot-time rlimit defaults for the init task:
@@ -26,6 +26,7 @@
[RLIMIT_NICE] = { 0, 0 }, \
[RLIMIT_RTPRIO] = { 0, 0 }, \
[RLIMIT_RTTIME] = { RLIM_INFINITY, RLIM_INFINITY }, \
+ [RLIMIT_GPUPRIO] = { DRM_SCHED_PRIORITY_NORMAL, DRM_SCHED_PRIORITY_NORMAL }, \
}
#endif
@@ -46,7 +46,8 @@
0-39 for nice level 19 .. -20 */
#define RLIMIT_RTPRIO 14 /* maximum realtime priority */
#define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */
-#define RLIM_NLIMITS 16
+#define RLIMIT_GPUPRIO 16 /* maximum GPU priority */
+#define RLIM_NLIMITS 17
/*
* SuS says limits have to be unsigned.
Introduce a new RLIMIT that allows the user to set a runtime limit on the GPU scheduler priority for tasks. This avoids the need for leased compositors such as SteamVR's vrcompositor to be launched via a setcap'ed executable with CAP_SYS_NICE. This is required for SteamVR as it doesn't run as a DRM master, but rather on a DRM lease using the HMD's connector. The current situation is bad for a few reasons, one being that in order to setcap the executable, typically one must run as root which involves a pretty high privelage escalation in order to achieve one small feat, a realtime async compute queue queue for VR or a compositor. The executable cannot be setcap'ed inside a container nor can the setcap'ed executable be run in a container with NO_NEW_PRIVS. Even in cases where one may think the DRM master check to be useful, such as Gamescope where it is the DRM master, the part of the compositor that runs as the DRM master is entirely separate to the Vulkan device with it's own DRM device fd doing the GPU work that demands the realtime priority queue. Additionally, Gamescope can also run nested in a traditional compositor where there is no DRM master, but having a realtime queue is still advantageous. With adding RLIMIT_GPUPRIO, a process outside of a container or eg. rtkit could call `prlimit` on the process inside to allow it to make a realtime queue and solve these problems. Signed-off-by: Joshua Ashton <joshua@froggi.es> --- fs/proc/base.c | 1 + include/asm-generic/resource.h | 3 ++- include/uapi/asm-generic/resource.h | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-)