[*] More Linux tweaks

This commit is contained in:
Reece Wilson 2023-08-28 19:13:18 +01:00
parent 0d759f85f8
commit fef6eac859

View File

@ -68,7 +68,7 @@ namespace Aurora::Threading::Threads
static ThreadInfo gDummyThreadInfo;
#if defined(AURORA_IS_POSIX_DERIVED)
static const auto kSignalAbort = SIGUSR1;
static const auto kSignalAbort = SIGUSR1 + 69;
static void HandleSigAbortThread(int a)
{
@ -547,6 +547,8 @@ namespace Aurora::Threading::Threads
}
}
void AttachSignalKiller();
void OSThread::_ThreadEP()
{
// Poke TLS reference thread entity
@ -564,6 +566,8 @@ namespace Aurora::Threading::Threads
Exit(true);
return;
}
AttachSignalKiller();
this->bSupportsAltKill = true;
#endif
try
@ -743,7 +747,8 @@ namespace Aurora::Threading::Threads
#if defined(AURORA_IS_POSIX_DERIVED)
struct sigaction action =
{
.sa_handler = HandleSigAbortThread,
.sa_handler = HandleSigAbortThread
};
::sigemptyset(&action.sa_mask);
::sigaction(kSignalAbort, &action, nullptr);
@ -794,7 +799,6 @@ namespace Aurora::Threading::Threads
if (!this->bNotOwned)
{
this->bSupportsAltKill = true;
AttachSignalKiller();
}
}
@ -1011,12 +1015,16 @@ namespace Aurora::Threading::Threads
#if defined(AURORA_IS_LINUX_DERIVED)
if (getrlimit(RLIMIT_RTPRIO, &rl) == 0)
{
bool bWarnOnce {};
rl.rlim_max = param.sched_priority;
if (rl.rlim_max != RLIM_INFINITY)
{
AuLogWarn("We will not use RT-Kit to keep your Linux machine alive through XDG_FREEEEEEDESKTOP_HOPES_AND_DREAMS");
AuLogWarn("Hint: append '* hard rtprio unlimited' to /etc/security/limits.conf");
AuLogWarn("Hint: try (1) : in bash, elevate using: '[doas/sudo] prlimit --rtprio=unlimited --pid=$$' before running the main executable");
AuLogWarn("Hint: try (2) : append '* hard rtprio unlimited' to /etc/security/limits.conf");
AuLogWarn("Hint: try (3) : check /etc/systemd/[system/user].conf");
bWarnOnce = true;
rl.rlim_cur = rl.rlim_max;
}
else
@ -1033,10 +1041,13 @@ namespace Aurora::Threading::Threads
}
#endif
if (::setrlimit(RLIMIT_RTPRIO, &rl) != 0)
if (::setrlimit(RLIMIT_RTPRIO, &rl) != 0 &&
!bWarnOnce)
{
AuLogWarn("We will not use RT-Kit to keep your Linux machine alive through XDG_FREEEEEEDESKTOP_HOPES_AND_DREAMS");
AuLogWarn("Hint: append '* hard rtprio unlimited' to /etc/security/limits.conf");
AuLogWarn("Hint: try (1) : in bash, elevate using: '[doas/sudo] prlimit --rtprio=unlimited --pid=$$' before running the main executable");
AuLogWarn("Hint: try (2) : append '* hard rtprio unlimited' to /etc/security/limits.conf");
AuLogWarn("Hint: try (3) : check /etc/systemd/[system/user].conf");
}
#if defined(SCHED_RR)
@ -1453,8 +1464,6 @@ namespace Aurora::Threading::Threads
AuxUlibInitialize();
#endif
AttachSignalKiller();
if (auto pThread = GetThread())
{
AuStaticCast<OSThread>(pThread)->MakeMain();