lmkd: pass uid from ActivityManager to lmkd
lmkd will use the uid to find processgroups and kill forked processes. Bug: 15313911 Change-Id: I3f7bb003ccf15650cae6ebc2c042ddeb4cc796fc
This commit is contained in:
parent
b5b2e45a20
commit
748d2185d3
13
lmkd.c
13
lmkd.c
|
|
@ -104,6 +104,7 @@ struct adjslot_list {
|
||||||
struct proc {
|
struct proc {
|
||||||
struct adjslot_list asl;
|
struct adjslot_list asl;
|
||||||
int pid;
|
int pid;
|
||||||
|
uid_t uid;
|
||||||
int oomadj;
|
int oomadj;
|
||||||
struct proc *pidhash_next;
|
struct proc *pidhash_next;
|
||||||
};
|
};
|
||||||
|
|
@ -227,7 +228,7 @@ static void writefilestring(char *path, char *s) {
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_procprio(int pid, int oomadj) {
|
static void cmd_procprio(int pid, int uid, int oomadj) {
|
||||||
struct proc *procp;
|
struct proc *procp;
|
||||||
char path[80];
|
char path[80];
|
||||||
char val[20];
|
char val[20];
|
||||||
|
|
@ -253,6 +254,7 @@ static void cmd_procprio(int pid, int oomadj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
procp->pid = pid;
|
procp->pid = pid;
|
||||||
|
procp->uid = uid;
|
||||||
procp->oomadj = oomadj;
|
procp->oomadj = oomadj;
|
||||||
proc_insert(procp);
|
proc_insert(procp);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -356,9 +358,9 @@ static void ctrl_command_handler(void) {
|
||||||
cmd_target(targets, &ibuf[1]);
|
cmd_target(targets, &ibuf[1]);
|
||||||
break;
|
break;
|
||||||
case LMK_PROCPRIO:
|
case LMK_PROCPRIO:
|
||||||
if (nargs != 2)
|
if (nargs != 3)
|
||||||
goto wronglen;
|
goto wronglen;
|
||||||
cmd_procprio(ntohl(ibuf[1]), ntohl(ibuf[2]));
|
cmd_procprio(ntohl(ibuf[1]), ntohl(ibuf[2]), ntohl(ibuf[3]));
|
||||||
break;
|
break;
|
||||||
case LMK_PROCREMOVE:
|
case LMK_PROCREMOVE:
|
||||||
if (nargs != 1)
|
if (nargs != 1)
|
||||||
|
|
@ -565,6 +567,7 @@ static void mp_event(uint32_t events __unused) {
|
||||||
|
|
||||||
if (procp) {
|
if (procp) {
|
||||||
int pid = procp->pid;
|
int pid = procp->pid;
|
||||||
|
uid_t uid = procp->uid;
|
||||||
char *taskname;
|
char *taskname;
|
||||||
int tasksize;
|
int tasksize;
|
||||||
int r;
|
int r;
|
||||||
|
|
@ -581,10 +584,10 @@ static void mp_event(uint32_t events __unused) {
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALOGI("Killing '%s' (%d), adj %d\n"
|
ALOGI("Killing '%s' (%d), uid %d, adj %d\n"
|
||||||
" to free %ldkB because cache %ldkB is below limit %ldkB for oom_adj %d\n"
|
" to free %ldkB because cache %ldkB is below limit %ldkB for oom_adj %d\n"
|
||||||
" Free memory is %ldkB %s reserved",
|
" Free memory is %ldkB %s reserved",
|
||||||
taskname, pid, procp->oomadj, tasksize * page_k,
|
taskname, pid, uid, procp->oomadj, tasksize * page_k,
|
||||||
other_file * page_k, minfree * page_k, min_score_adj,
|
other_file * page_k, minfree * page_k, min_score_adj,
|
||||||
other_free * page_k, other_free >= 0 ? "above" : "below");
|
other_free * page_k, other_free >= 0 ? "above" : "below");
|
||||||
r = kill(pid, SIGKILL);
|
r = kill(pid, SIGKILL);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue