lmkd: migrate process to FOREGROUND sched group before kill
BG group may have settings such as cpu.shares impacting reclaim performance. Let us migrate task to foreground sched group similarly to cpuset group. Test: Build Bug: 199797672 Signed-off-by: Wei Wang <wvw@google.com> Change-Id: I75ee9f3486a2c76e65267a98e39edff96a5e1673
This commit is contained in:
parent
0e64eadc21
commit
0195bcdba7
12
lmkd.cpp
12
lmkd.cpp
|
|
@ -40,7 +40,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
#include <cutils/sched_policy.h>
|
|
||||||
#include <cutils/sockets.h>
|
#include <cutils/sockets.h>
|
||||||
#include <liblmkd_utils.h>
|
#include <liblmkd_utils.h>
|
||||||
#include <lmkd.h>
|
#include <lmkd.h>
|
||||||
|
|
@ -48,6 +47,7 @@
|
||||||
#include <log/log_event_list.h>
|
#include <log/log_event_list.h>
|
||||||
#include <log/log_time.h>
|
#include <log/log_time.h>
|
||||||
#include <private/android_filesystem_config.h>
|
#include <private/android_filesystem_config.h>
|
||||||
|
#include <processgroup/processgroup.h>
|
||||||
#include <psi/psi.h>
|
#include <psi/psi.h>
|
||||||
#include <system/thread_defs.h>
|
#include <system/thread_defs.h>
|
||||||
|
|
||||||
|
|
@ -2008,7 +2008,8 @@ static struct proc *proc_get_heaviest(int oomadj) {
|
||||||
return maxprocp;
|
return maxprocp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_process_group_and_prio(int pid, SchedPolicy sp, int prio) {
|
static void set_process_group_and_prio(int pid, const std::vector<std::string>& profiles,
|
||||||
|
int prio) {
|
||||||
DIR* d;
|
DIR* d;
|
||||||
char proc_path[PATH_MAX];
|
char proc_path[PATH_MAX];
|
||||||
struct dirent* de;
|
struct dirent* de;
|
||||||
|
|
@ -2035,8 +2036,8 @@ static void set_process_group_and_prio(int pid, SchedPolicy sp, int prio) {
|
||||||
ALOGW("Unable to raise priority of killing t_pid (%d): errno=%d", t_pid, errno);
|
ALOGW("Unable to raise priority of killing t_pid (%d): errno=%d", t_pid, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set_cpuset_policy(t_pid, sp)) {
|
if (!SetTaskProfiles(t_pid, profiles)) {
|
||||||
ALOGW("Failed to set_cpuset_policy on pid(%d) t_pid(%d) to %d", pid, t_pid, (int)sp);
|
ALOGW("Failed to set task_profiles on pid(%d) t_pid(%d)", pid, t_pid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2207,7 +2208,8 @@ static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_i
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_process_group_and_prio(pid, SP_FOREGROUND, ANDROID_PRIORITY_HIGHEST);
|
set_process_group_and_prio(pid, {"CPUSET_SP_BACKGROUND", "SCHED_SP_FOREGROUND"},
|
||||||
|
ANDROID_PRIORITY_HIGHEST);
|
||||||
|
|
||||||
last_kill_tm = *tm;
|
last_kill_tm = *tm;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue