core: don't check RLIMIT_RTPRIO

FreeBSD doesn't have RLIMIT_RTPRIO. So instead we skip this check and
just always try to set our priority to the lowest SCHED_RR priority
available.

Fixes #1082

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2023-06-24 02:49:20 +01:00
parent b85272312a
commit 9295f7e4c7
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
1 changed files with 7 additions and 9 deletions

View File

@ -2577,11 +2577,8 @@ err:
return NULL;
}
void set_rr_scheduling(void) {
struct rlimit rlim;
if (getrlimit(RLIMIT_RTPRIO, &rlim) != 0) {
log_warn("Failed to get RLIMIT_RTPRIO, not setting real-time priority");
return;
}
int priority = sched_get_priority_min(SCHED_RR);
int old_policy;
int ret;
struct sched_param param;
@ -2592,14 +2589,15 @@ void set_rr_scheduling(void) {
return;
}
param.sched_priority = (int)rlim.rlim_cur;
param.sched_priority = priority;
ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
if (ret != 0) {
log_info("Failed to set scheduling priority to %lu", rlim.rlim_cur);
log_info("Failed to set real-time scheduling priority to %d. Consider "
"giving picom the CAP_SYS_NICE capability",
priority);
return;
}
log_info("Set scheduling priority to %lu", rlim.rlim_cur);
log_info("Set real-time scheduling priority to %d", priority);
}
/**