Revert "android/lowmemorykiller: Wait for memory to be freed"

This reverts commit 25f87e504b.

Change-Id: If8709a45b36fb73bee4e9c3e4e99937a8a952651
This commit is contained in:
Thierry Strudel 2015-12-22 10:15:32 -08:00 committed by syphyr
parent 6f6c955aa5
commit 919a123cc9
1 changed files with 7 additions and 30 deletions

View File

@ -40,8 +40,6 @@
#include <linux/swap.h>
#include <linux/rcupdate.h>
#include <linux/notifier.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#define CREATE_TRACE_POINTS
#include "trace/lowmemorykiller.h"
@ -86,8 +84,6 @@ static int test_task_flag(struct task_struct *p, int flag)
return 0;
}
static DEFINE_MUTEX(scan_mutex);
static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
{
struct task_struct *tsk;
@ -100,17 +96,8 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
int selected_tasksize = 0;
short selected_oom_score_adj;
int array_size = ARRAY_SIZE(lowmem_adj);
int other_free;
int other_file;
unsigned long nr_to_scan = sc->nr_to_scan;
if (nr_to_scan > 0) {
if (mutex_lock_interruptible(&scan_mutex) < 0)
return 0;
}
other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
other_file = global_page_state(NR_FILE_PAGES) -
int other_free = global_page_state(NR_FREE_PAGES) - totalreserve_pages;
int other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM);
if (lowmem_adj_size < array_size)
@ -124,21 +111,17 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
break;
}
}
if (nr_to_scan > 0)
if (sc->nr_to_scan > 0)
lowmem_print(3, "lowmem_shrink %lu, %x, ofree %d %d, ma %hd\n",
nr_to_scan, sc->gfp_mask, other_free,
sc->nr_to_scan, sc->gfp_mask, other_free,
other_file, min_score_adj);
rem = global_page_state(NR_ACTIVE_ANON) +
global_page_state(NR_ACTIVE_FILE) +
global_page_state(NR_INACTIVE_ANON) +
global_page_state(NR_INACTIVE_FILE);
if (nr_to_scan <= 0 || min_score_adj == OOM_SCORE_ADJ_MAX + 1) {
if (sc->nr_to_scan <= 0 || min_score_adj == OOM_SCORE_ADJ_MAX + 1) {
lowmem_print(5, "lowmem_shrink %lu, %x, return %d\n",
nr_to_scan, sc->gfp_mask, rem);
if (nr_to_scan > 0)
mutex_unlock(&scan_mutex);
sc->nr_to_scan, sc->gfp_mask, rem);
return rem;
}
selected_oom_score_adj = min_score_adj;
@ -154,9 +137,6 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
if (time_before_eq(jiffies, lowmem_deathpending_timeout)) {
if (test_task_flag(tsk, TIF_MEMDIE)) {
rcu_read_unlock();
/* give the system time to free up the memory */
msleep_interruptible(20);
mutex_unlock(&scan_mutex);
return 0;
}
}
@ -208,13 +188,10 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
set_tsk_thread_flag(selected, TIF_MEMDIE);
send_sig(SIGKILL, selected, 0);
rem -= selected_tasksize;
/* give the system time to free up the memory */
msleep_interruptible(20);
}
lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n",
nr_to_scan, sc->gfp_mask, rem);
sc->nr_to_scan, sc->gfp_mask, rem);
rcu_read_unlock();
mutex_unlock(&scan_mutex);
return rem;
}