diff options
author | Suren Baghdasaryan <surenb@google.com> | 2018-10-10 14:17:17 -0700 |
---|---|---|
committer | Suren Baghdasaryan <surenb@google.com> | 2018-10-10 22:11:23 +0000 |
commit | c89be17730845548a797427d237e5a59e6001235 (patch) | |
tree | 7a485da2d7264ff638165566b2b531f0f29a71a3 /lmkd/lmkd.c | |
parent | d6cbf3f41d7cb54e7dc62f4c29f7a7cba05aa28b (diff) | |
download | core-c89be17730845548a797427d237e5a59e6001235.tar.gz core-c89be17730845548a797427d237e5a59e6001235.tar.bz2 core-c89be17730845548a797427d237e5a59e6001235.zip |
lmkd: Implement pid purge command to clear old pids when zygote restarts
lmkd keeps a list of pids registered by ActivityManager, however on rare
occasions when framework restarts and lmkd survives that list has to be
purged. Implement a command that can be used to clear the pid list.
Bug: 116801366
Test: locally by killing zygote process
Change-Id: I71d6012f86bb83a73edd5b687e05a0848e0569b1
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Diffstat (limited to 'lmkd/lmkd.c')
-rw-r--r-- | lmkd/lmkd.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index bf265b0f2..e36f72b02 100644 --- a/lmkd/lmkd.c +++ b/lmkd/lmkd.c @@ -526,6 +526,31 @@ static void cmd_procremove(LMKD_CTRL_PACKET packet) { pid_remove(params.pid); } +static void cmd_procpurge() { + int i; + struct proc *procp; + struct proc *next; + + if (use_inkernel_interface) { + return; + } + + for (i = 0; i <= ADJTOSLOT(OOM_SCORE_ADJ_MAX); i++) { + procadjslot_list[i].next = &procadjslot_list[i]; + procadjslot_list[i].prev = &procadjslot_list[i]; + } + + for (i = 0; i < PIDHASH_SZ; i++) { + procp = pidhash[i]; + while (procp) { + next = procp->pidhash_next; + free(procp); + procp = next; + } + } + memset(&pidhash[0], 0, sizeof(pidhash)); +} + static void cmd_target(int ntargets, LMKD_CTRL_PACKET packet) { int i; struct lmk_target target; @@ -634,6 +659,11 @@ static void ctrl_command_handler(int dsock_idx) { goto wronglen; cmd_procremove(packet); break; + case LMK_PROCPURGE: + if (nargs != 0) + goto wronglen; + cmd_procpurge(); + break; default: ALOGE("Received unknown command code %d", cmd); return; |