lmkd: Set task profiles to the entire process
set_process_group_and_prio sets task profiles for each thread in the process separately. This can be avoided by setting task profiles to the entire process using its pid. Bug: 215557553 Signed-off-by: Suren Baghdasaryan <surenb@google.com> Change-Id: I9c1917172019a42809385f6c9c084b8cb343b520 Merged-In: I9c1917172019a42809385f6c9c084b8cb343b520
This commit is contained in:
parent
931bf0954f
commit
b8cdb6ac91
16
lmkd.cpp
16
lmkd.cpp
|
|
@ -1987,12 +1987,17 @@ static struct proc *proc_get_heaviest(int oomadj) {
|
|||
return maxprocp;
|
||||
}
|
||||
|
||||
static void set_process_group_and_prio(int pid, const std::vector<std::string>& profiles,
|
||||
int prio) {
|
||||
|
||||
static void set_process_group_and_prio(uid_t uid, int pid,
|
||||
const std::vector<std::string>& profiles, int prio) {
|
||||
DIR* d;
|
||||
char proc_path[PATH_MAX];
|
||||
struct dirent* de;
|
||||
|
||||
if (!SetProcessProfilesCached(uid, pid, profiles)) {
|
||||
ALOGW("Failed to set task profiles for the process (%d) being killed", pid);
|
||||
}
|
||||
|
||||
snprintf(proc_path, sizeof(proc_path), "/proc/%d/task", pid);
|
||||
if (!(d = opendir(proc_path))) {
|
||||
ALOGW("Failed to open %s; errno=%d: process pid(%d) might have died", proc_path, errno,
|
||||
|
|
@ -2014,11 +2019,6 @@ static void set_process_group_and_prio(int pid, const std::vector<std::string>&
|
|||
if (setpriority(PRIO_PROCESS, t_pid, prio) && errno != ESRCH) {
|
||||
ALOGW("Unable to raise priority of killing t_pid (%d): errno=%d", t_pid, errno);
|
||||
}
|
||||
|
||||
if (!SetTaskProfiles(t_pid, profiles, true)) {
|
||||
ALOGW("Failed to set task_profiles on pid(%d) t_pid(%d)", pid, t_pid);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
|
|
@ -2191,7 +2191,7 @@ static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_i
|
|||
goto out;
|
||||
}
|
||||
|
||||
set_process_group_and_prio(pid, {"CPUSET_SP_FOREGROUND", "SCHED_SP_FOREGROUND"},
|
||||
set_process_group_and_prio(uid, pid, {"CPUSET_SP_FOREGROUND", "SCHED_SP_FOREGROUND"},
|
||||
ANDROID_PRIORITY_HIGHEST);
|
||||
|
||||
last_kill_tm = *tm;
|
||||
|
|
|
|||
Loading…
Reference in New Issue