Session preload: drop oom_score_adj raises so lmkd does not treat games as cached apps

steam-launch-wrapper starts every game with --oom-score-adjust 900; on
Android 900 is CACHED_APP_MIN_ADJ, so lmkd kills the running game first
when memory runs short (and on Linux 6.1 the raise becomes the process's
permanent minimum). A process in the app cannot go below the score it
inherits, so the writes that succeed from inside are raises: every
write-open of /proc/<pid|self|thread-self>[/task/<tid>]/oom_score_adj (or
oom_adj), through open/openat or fopen, goes to /dev/null, logged once.

Based on the oom_score_adj redirect in the preload's opens.c by jdmg28 (https://github.com/jdmg28/DroidDeck-Mali/commit/6be00e00)
This commit is contained in:
The412Banner committed 2026-10-15 19:47:18 -04:00
1 parent 5bc5f68761
commit b3f3e4fdaf
4 files changed
+100

No files matched your search

+3
View File
@@ -537,6 +537,8 @@ static FILE *synthesize(const char *table) {
int bl_status_without_tracer(const char *path, int flags) __attribute__((visibility("hidden")));
const char *bl_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
static FILE *open_stream(fopen_fn real, const char *path, const char *mode) {
int status = mode && mode[0] == 'r' && !strchr(mode, '+')
? bl_status_without_tracer(path, O_RDONLY | O_CLOEXEC) : -1;
@@ -545,6 +547,7 @@ static FILE *open_stream(fopen_fn real, const char *path, const char *mode) {
if (copy == NULL) close(status);
return copy;
}
path = bl_oom_adj_redirect(path, mode && (mode[0] == 'w' || mode[0] == 'a' || strchr(mode, '+')));
FILE *f = real(path, mode);
if (f || path == NULL || mode == NULL || mode[0] != 'r') return f;
int saved = errno;