Revert "android/lowmemorykiller: Ignore tasks with freed mm"

This reverts commit 05d5ad4d0a.

Change-Id: Ib5770b5b38f123116322507646ae9bce6c3c186a
This commit is contained in:
Thierry Strudel 2015-12-22 10:13:14 -08:00 committed by syphyr
parent 44ba2354e3
commit 6f6c955aa5
5 changed files with 6 additions and 19 deletions

View file

@ -161,7 +161,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
#define TIF_USING_IWMMXT 17 #define TIF_USING_IWMMXT 17
#define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
#define TIF_RESTORE_SIGMASK 20 #define TIF_RESTORE_SIGMASK 20
#define TIF_MM_RELEASED 23 /* task MM has been released */ #define TIF_SWITCH_MM 22 /* deferred switch_mm */
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)

View file

@ -151,10 +151,6 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
if (tsk->flags & PF_KTHREAD) if (tsk->flags & PF_KTHREAD)
continue; continue;
/* if task no longer has any memory ignore it */
if (test_task_flag(tsk, TIF_MM_RELEASED))
continue;
if (time_before_eq(jiffies, lowmem_deathpending_timeout)) { if (time_before_eq(jiffies, lowmem_deathpending_timeout)) {
if (test_task_flag(tsk, TIF_MEMDIE)) { if (test_task_flag(tsk, TIF_MEMDIE)) {
rcu_read_unlock(); rcu_read_unlock();
@ -212,14 +208,12 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
set_tsk_thread_flag(selected, TIF_MEMDIE); set_tsk_thread_flag(selected, TIF_MEMDIE);
send_sig(SIGKILL, selected, 0); send_sig(SIGKILL, selected, 0);
rem -= selected_tasksize; rem -= selected_tasksize;
rcu_read_unlock();
/* give the system time to free up the memory */ /* give the system time to free up the memory */
msleep_interruptible(20); msleep_interruptible(20);
} else }
rcu_read_unlock();
lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n", lowmem_print(4, "lowmem_shrink %lu, %x, return %d\n",
nr_to_scan, sc->gfp_mask, rem); nr_to_scan, sc->gfp_mask, rem);
rcu_read_unlock();
mutex_unlock(&scan_mutex); mutex_unlock(&scan_mutex);
return rem; return rem;
} }

View file

@ -2411,7 +2411,7 @@ static inline void mmdrop(struct mm_struct * mm)
} }
/* mmput gets rid of the mappings and all user-space */ /* mmput gets rid of the mappings and all user-space */
extern int mmput(struct mm_struct *); extern void mmput(struct mm_struct *);
/* Grab a reference to a task's mm, if it is not already going away */ /* Grab a reference to a task's mm, if it is not already going away */
extern struct mm_struct *get_task_mm(struct task_struct *task); extern struct mm_struct *get_task_mm(struct task_struct *task);
/* /*

View file

@ -409,7 +409,6 @@ static void exit_mm(struct task_struct * tsk)
{ {
struct mm_struct *mm = tsk->mm; struct mm_struct *mm = tsk->mm;
struct core_state *core_state; struct core_state *core_state;
int mm_released;
mm_release(tsk, mm); mm_release(tsk, mm);
if (!mm) if (!mm)
@ -455,10 +454,7 @@ static void exit_mm(struct task_struct * tsk)
enter_lazy_tlb(mm, current); enter_lazy_tlb(mm, current);
task_unlock(tsk); task_unlock(tsk);
mm_update_next_owner(mm); mm_update_next_owner(mm);
mmput(mm);
mm_released = mmput(mm);
if (mm_released)
set_tsk_thread_flag(tsk, TIF_MM_RELEASED);
} }
/* /*

View file

@ -630,9 +630,8 @@ EXPORT_SYMBOL_GPL(__mmdrop);
/* /*
* Decrement the use count and release all resources for an mm. * Decrement the use count and release all resources for an mm.
*/ */
int mmput(struct mm_struct *mm) void mmput(struct mm_struct *mm)
{ {
int mm_freed = 0;
might_sleep(); might_sleep();
if (atomic_dec_and_test(&mm->mm_users)) { if (atomic_dec_and_test(&mm->mm_users)) {
@ -650,9 +649,7 @@ int mmput(struct mm_struct *mm)
if (mm->binfmt) if (mm->binfmt)
module_put(mm->binfmt->module); module_put(mm->binfmt->module);
mmdrop(mm); mmdrop(mm);
mm_freed = 1;
} }
return mm_freed;
} }
EXPORT_SYMBOL_GPL(mmput); EXPORT_SYMBOL_GPL(mmput);