Add a function for fetching the RTTIME limit

We can use this to more easily diagnose issues caused by PipeWire.
This commit is contained in:
Robbert van der Helm
2021-05-27 13:48:34 +02:00
parent 4d5b2fcb12
commit 0d3850e837
2 changed files with 23 additions and 0 deletions
+9
View File
@@ -48,6 +48,15 @@ bool set_realtime_priority(bool sched_fifo, int priority) noexcept {
&params) == 0;
}
std::optional<rlim_t> get_rttime_limit() noexcept {
rlimit limits{};
if (getrlimit(RLIMIT_RTTIME, &limits) == 0) {
return limits.rlim_cur;
} else {
return std::nullopt;
}
}
bool pid_running(pid_t pid) {
// With regular individually hosted plugins we can simply check whether the
// process is still running, however Boost.Process does not allow you to do
+14
View File
@@ -18,6 +18,8 @@
#include <optional>
#include <sys/resource.h>
#ifdef __WINE__
#include "../wine-host/boost-fix.h"
#endif
@@ -86,6 +88,18 @@ boost::filesystem::path get_temporary_directory();
*/
std::optional<int> get_realtime_priority() noexcept;
/**
* Get the (soft) `RTTIME` resource limit, or the amount of time a `SCHED_FIFO`
* process may spend uninterrupted before being killed by the scheduler. A value
* of `-1`/`RLIM_INFINITY` means that there is no limit. If there was some error
* fetching this value, then a nullopt will be returned.
*
* This is useful to diagnose issues caused by PipeWire. They use rtkit at the
* moment, and both rtkit and PipeWire's rtkit module will enable a realtime CPU
* time limit with some low value.
*/
std::optional<rlim_t> get_rttime_limit() noexcept;
/**
* Set the scheduling policy to `SCHED_FIFO` with priority 5 for this process.
* We explicitly don't do this for wineserver itself since from my testing that