utils: don't set realtime scheduling again if we already tried

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-03-03 01:28:35 +00:00
parent 615924cc4a
commit dc3271e81b
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
1 changed files with 6 additions and 0 deletions

View File

@ -282,6 +282,12 @@ void rolling_quantile_pop_front(struct rolling_quantile *rq, int x) {
/// This requires the user to set up permissions for the real-time scheduling. e.g. by
/// setting `ulimit -r`, or giving us the CAP_SYS_NICE capability.
void set_rr_scheduling(void) {
static thread_local bool already_tried = false;
if (already_tried) {
return;
}
already_tried = true;
int priority = sched_get_priority_min(SCHED_RR);
if (rtkit_make_realtime(0, priority)) {