Add setting of oom_score_adj (#1504)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
mkdocs / deploy (push) Has been cancelled

To limit risk of killing by OOM Killer.
This commit is contained in:
trapexit 2025-08-08 00:58:06 -04:00 • committed by GitHub
parent 9872710720
commit 4439c2a030
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 119 additions and 1 deletions

View file

@ -23,13 +23,14 @@
#include "fs_umount2.hpp"
#include "fs_wait_for_mount.hpp"
#include "gidcache.hpp"
#include "maintenance_thread.hpp"
#include "oom.hpp"
#include "option_parser.hpp"
#include "procfs.hpp"
#include "resources.hpp"
#include "strvec.hpp"
#include "syslog.hpp"
#include "version.hpp"
#include "maintenance_thread.hpp"
#include "fuse_access.hpp"
#include "fuse_bmap.hpp"
@ -164,6 +165,27 @@ namespace l
resources::setpriority(scheduling_priority_);
}
static
void
set_oom_score_adj()
{
int rv;
int orig;
int score;
if(!oom::has_oom_score_adj())
return;
score = -990;
orig = oom::get_oom_score_adj();
rv = oom::set_oom_score_adj(score);
SysLog::info("set oom_score_adj to {}, originally {}",
score,
orig);
}
static
bool
wait_for_mount(const Config::Read &cfg_)
@ -318,6 +340,7 @@ namespace l
});
l::setup_resources(cfg->scheduling_priority);
l::setup_signal_handlers();
l::set_oom_score_adj();
l::get_fuse_operations(ops,cfg->nullrw);
if(cfg->lazy_umount_mountpoint)