• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

修訂bb2bc1586d1de2afec9874fdbeb1e204b996aadf (tree)
時間2019-04-19 08:31:11
作者Wei Wang <wvw@goog...>
CommiterWei Wang

Log Message

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

Change Summary

差異

--- a/init/init.cpp
+++ b/init/init.cpp
@@ -630,6 +630,11 @@ int SecondStageMain(int argc, char** argv) {
630630 InitKernelLogging(argv, InitAborter);
631631 LOG(INFO) << "init second stage started!";
632632
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+
633638 // Enable seccomp if global boot option was passed (otherwise it is enabled in zygote).
634639 GlobalSeccomp();
635640
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -13,9 +13,6 @@ import /init.${ro.zygote}.rc
1313
1414 # Cgroups are mounted right before early-init using list from /etc/cgroups.json
1515 on early-init
16- # Set init and its forked children's oom_adj.
17- write /proc/1/oom_score_adj -1000
18-
1916 # Disable sysrq from keyboard
2017 write /proc/sys/kernel/sysrq 0
2118