diff --git a/lmkd.cpp b/lmkd.cpp index faa55b2..5fe5f06 100644 --- a/lmkd.cpp +++ b/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& profiles, - int prio) { + +static void set_process_group_and_prio(uid_t uid, int pid, + const std::vector& 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& 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;