mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
simple_lmk: Update adj targeting for Android 10
Android 10 changed its adj assignments. Update Simple LMK to use the new adjs, which also requires looking at each pair of adjs as a range. Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com> Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
parent
08eda9b371
commit
dd1405e35e
@ -29,23 +29,21 @@ struct victim_info {
|
||||
};
|
||||
|
||||
/* Pulled from the Android framework. Lower adj means higher priority. */
|
||||
static const short adj_prio[] = {
|
||||
906, /* CACHED_APP_MAX_ADJ */
|
||||
905, /* Cached app */
|
||||
904, /* Cached app */
|
||||
903, /* Cached app */
|
||||
902, /* Cached app */
|
||||
901, /* Cached app */
|
||||
900, /* CACHED_APP_MIN_ADJ */
|
||||
800, /* SERVICE_B_ADJ */
|
||||
700, /* PREVIOUS_APP_ADJ */
|
||||
600, /* HOME_APP_ADJ */
|
||||
500, /* SERVICE_ADJ */
|
||||
400, /* HEAVY_WEIGHT_APP_ADJ */
|
||||
300, /* BACKUP_APP_ADJ */
|
||||
200, /* PERCEPTIBLE_APP_ADJ */
|
||||
100, /* VISIBLE_APP_ADJ */
|
||||
0 /* FOREGROUND_APP_ADJ */
|
||||
static const short adjs[] = {
|
||||
1000, /* CACHED_APP_MAX_ADJ + 1 */
|
||||
950, /* CACHED_APP_LMK_FIRST_ADJ */
|
||||
900, /* CACHED_APP_MIN_ADJ */
|
||||
800, /* SERVICE_B_ADJ */
|
||||
700, /* PREVIOUS_APP_ADJ */
|
||||
600, /* HOME_APP_ADJ */
|
||||
500, /* SERVICE_ADJ */
|
||||
400, /* HEAVY_WEIGHT_APP_ADJ */
|
||||
300, /* BACKUP_APP_ADJ */
|
||||
250, /* PERCEPTIBLE_LOW_APP_ADJ */
|
||||
200, /* PERCEPTIBLE_APP_ADJ */
|
||||
100, /* VISIBLE_APP_ADJ */
|
||||
50, /* PERCEPTIBLE_RECENT_FOREGROUND_APP_ADJ */
|
||||
0 /* FOREGROUND_APP_ADJ */
|
||||
};
|
||||
|
||||
static struct victim_info victims[MAX_VICTIMS];
|
||||
@ -87,7 +85,8 @@ static unsigned long get_total_mm_pages(struct mm_struct *mm)
|
||||
return pages;
|
||||
}
|
||||
|
||||
static unsigned long find_victims(int *vindex, short target_adj)
|
||||
static unsigned long find_victims(int *vindex, short target_adj_min,
|
||||
short target_adj_max)
|
||||
{
|
||||
unsigned long pages_found = 0;
|
||||
int old_vindex = *vindex;
|
||||
@ -96,6 +95,7 @@ static unsigned long find_victims(int *vindex, short target_adj)
|
||||
for_each_process(tsk) {
|
||||
struct signal_struct *sig;
|
||||
struct task_struct *vtsk;
|
||||
short adj;
|
||||
|
||||
/*
|
||||
* Search for suitable tasks with the targeted importance (adj).
|
||||
@ -107,7 +107,8 @@ static unsigned long find_victims(int *vindex, short target_adj)
|
||||
* trying to lock a task that we locked earlier.
|
||||
*/
|
||||
sig = tsk->signal;
|
||||
if (READ_ONCE(sig->oom_score_adj) != target_adj ||
|
||||
adj = READ_ONCE(sig->oom_score_adj);
|
||||
if (adj < target_adj_min || adj > target_adj_max - 1 ||
|
||||
sig->flags & (SIGNAL_GROUP_EXIT | SIGNAL_GROUP_COREDUMP) ||
|
||||
(thread_group_empty(tsk) && tsk->flags & PF_EXITING) ||
|
||||
vtsk_is_duplicate(*vindex, tsk))
|
||||
@ -177,8 +178,8 @@ static void scan_and_kill(unsigned long pages_needed)
|
||||
* is guaranteed to be up to date.
|
||||
*/
|
||||
read_lock(&tasklist_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(adj_prio); i++) {
|
||||
pages_found += find_victims(&nr_victims, adj_prio[i]);
|
||||
for (i = 1; i < ARRAY_SIZE(adjs); i++) {
|
||||
pages_found += find_victims(&nr_victims, adjs[i], adjs[i - 1]);
|
||||
if (pages_found >= pages_needed || nr_victims == MAX_VICTIMS)
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user