system/core
修訂 | bb2bc1586d1de2afec9874fdbeb1e204b996aadf (tree) |
---|---|
時間 | 2019-04-19 08:31:11 |
作者 | Wei Wang <wvw@goog...> |
Commiter | Wei Wang |
init: set oom_adj early before fork vendor_init
right now vendor_init is forked before we set oom_adj for init which
leaves a chance vendor_init could be killed in heavy memory pressure.
this CL set the oom_adj before forking everything to ensure all native
have correct oom_adj settings.
Fixes: 130824864
Test: procrank -o
(cherry picked from commit 45d8174fe7b6f35883f74ceefdf591b209f1fab2)
Change-Id: I68c18f9db24d55239f7f0608592fcc702f04542e
@@ -630,6 +630,11 @@ int SecondStageMain(int argc, char** argv) { | ||
630 | 630 | InitKernelLogging(argv, InitAborter); |
631 | 631 | LOG(INFO) << "init second stage started!"; |
632 | 632 | |
633 | + // Set init and its forked children's oom_adj. | |
634 | + if (auto result = WriteFile("/proc/1/oom_score_adj", "-1000"); !result) { | |
635 | + LOG(ERROR) << "Unable to write -1000 to /proc/1/oom_score_adj: " << result.error(); | |
636 | + } | |
637 | + | |
633 | 638 | // Enable seccomp if global boot option was passed (otherwise it is enabled in zygote). |
634 | 639 | GlobalSeccomp(); |
635 | 640 |
@@ -13,9 +13,6 @@ import /init.${ro.zygote}.rc | ||
13 | 13 | |
14 | 14 | # Cgroups are mounted right before early-init using list from /etc/cgroups.json |
15 | 15 | on early-init |
16 | - # Set init and its forked children's oom_adj. | |
17 | - write /proc/1/oom_score_adj -1000 | |
18 | - | |
19 | 16 | # Disable sysrq from keyboard |
20 | 17 | write /proc/sys/kernel/sysrq 0 |
21 | 18 |