mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +02:00
Warn on startup if RLIMIT_MEMLOCK is set too low
This should diagnose issues like #119.
This commit is contained in:
@@ -57,6 +57,15 @@ bool set_realtime_priority(bool sched_fifo, int priority) noexcept {
|
||||
¶ms) == 0;
|
||||
}
|
||||
|
||||
std::optional<rlim_t> get_memlock_limit() noexcept {
|
||||
rlimit limits{};
|
||||
if (getrlimit(RLIMIT_MEMLOCK, &limits) == 0) {
|
||||
return limits.rlim_cur;
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<rlim_t> get_rttime_limit() noexcept {
|
||||
rlimit limits{};
|
||||
if (getrlimit(RLIMIT_RTTIME, &limits) == 0) {
|
||||
|
||||
+13
-4
@@ -106,10 +106,19 @@ std::optional<int> get_realtime_priority() noexcept;
|
||||
bool set_realtime_priority(bool sched_fifo, int priority = 5) 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.
|
||||
* Get the (soft) `RLIMIT_MEMLOCK` resource limit. If this is set to some low
|
||||
* value, then we'll print a warning during initialization because mapping
|
||||
* shared memory may fail. 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.
|
||||
*/
|
||||
std::optional<rlim_t> get_memlock_limit() noexcept;
|
||||
|
||||
/**
|
||||
* Get the (soft) `RLIMIT_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
|
||||
|
||||
Reference in New Issue
Block a user