Skip to content

Commit 130c294

Browse files
weivincewangkdrag0n
authored andcommitted
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
1 parent a810e9f commit 130c294

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lmkd.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
#include <unistd.h>
4141

4242
#include <cutils/properties.h>
43-
#include <cutils/sched_policy.h>
4443
#include <cutils/sockets.h>
4544
#include <liblmkd_utils.h>
4645
#include <lmkd.h>
4746
#include <log/log.h>
4847
#include <log/log_event_list.h>
4948
#include <log/log_time.h>
5049
#include <private/android_filesystem_config.h>
50+
#include <processgroup/processgroup.h>
5151
#include <psi/psi.h>
5252
#include <system/thread_defs.h>
5353

@@ -1977,7 +1977,8 @@ static struct proc *proc_get_heaviest(int oomadj) {
19771977
return maxprocp;
19781978
}
19791979

1980-
static void set_process_group_and_prio(int pid, SchedPolicy sp, int prio) {
1980+
static void set_process_group_and_prio(int pid, const std::vector<std::string>& profiles,
1981+
int prio) {
19811982
DIR* d;
19821983
char proc_path[PATH_MAX];
19831984
struct dirent* de;
@@ -2004,8 +2005,8 @@ static void set_process_group_and_prio(int pid, SchedPolicy sp, int prio) {
20042005
ALOGW("Unable to raise priority of killing t_pid (%d): errno=%d", t_pid, errno);
20052006
}
20062007

2007-
if (set_cpuset_policy(t_pid, sp)) {
2008-
ALOGW("Failed to set_cpuset_policy on pid(%d) t_pid(%d) to %d", pid, t_pid, (int)sp);
2008+
if (!SetTaskProfiles(t_pid, profiles)) {
2009+
ALOGW("Failed to set task_profiles on pid(%d) t_pid(%d)", pid, t_pid);
20092010
continue;
20102011
}
20112012
}
@@ -2180,7 +2181,8 @@ static int kill_one_process(struct proc* procp, int min_oom_score, struct kill_i
21802181
goto out;
21812182
}
21822183

2183-
set_process_group_and_prio(pid, SP_FOREGROUND, ANDROID_PRIORITY_HIGHEST);
2184+
set_process_group_and_prio(pid, {"CPUSET_SP_BACKGROUND", "SCHED_SP_FOREGROUND"},
2185+
ANDROID_PRIORITY_HIGHEST);
21842186

21852187
last_kill_tm = *tm;
21862188

0 commit comments

Comments
 (0)