linux: use -1000 adjustment for /proc/<pid>/oom_score_adj first #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The intent of the
bcd_os_oom_adjust()
function is apparently to disable OOM killing of the process, as it writes the value -17 to the/proc/<pid>/oom_adj
path if it exists.Per the kernel documentation:
If
/proc/<pid>/oom_adj
does not exist,bcd_os_oom_adjust()
attempts to write the same value (-17) to/proc/<pid>/oom_score_adj
. This results in different behavior, because this value is within the OOM score adjustment range. Per the kernel documentation:Additionally, the
bcd_os_oom_adjust()
function attempts to write to/proc/<pid>/oom_adj
and, if that path does not exist, falls back to writing to/proc/<pid>/oom_score_adj
. On modern kernels where both paths exist, this results in a kernel warning being logged:https://github.com/torvalds/linux/blob/f69d02e37a85645aa90d18cacfff36dba370f797/fs/proc/base.c#L1074-L1080
This commit updates
bcd_os_oom_adjust()
to write "-1000" to/proc/<pid>/oom_score_adj
first and, if that path does not exist, "-17" to the legacy/proc/<pid>/oom_adj
path.