mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
simple_lmk: Don't queue up new reclaim requests during reclaim
Queuing up reclaim requests while a reclaim is in progress doesn't make sense, since the additional reclaims may not be needed after the existing reclaim completes. This would cause Simple LMK to go berserk during periods of high memory pressure where kswapd would fire off reclaim requests nonstop. Make Simple LMK ignore new reclaim requests until an existing reclaim is finished to prevent a slaughter-fest. Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com> Signed-off-by: azrim <mirzaspc@gmail.com>
This commit is contained in:
parent
7e86f1e61f
commit
e2cb78a57e
@ -245,8 +245,9 @@ static int simple_lmk_reclaim_thread(void *data)
|
||||
sched_setscheduler_nocheck(current, SCHED_FIFO, &sched_max_rt_prio);
|
||||
|
||||
while (1) {
|
||||
wait_event(oom_waitq, atomic_add_unless(&needs_reclaim, -1, 0));
|
||||
wait_event(oom_waitq, atomic_read_acquire(&needs_reclaim));
|
||||
scan_and_kill(MIN_FREE_PAGES);
|
||||
atomic_set_release(&needs_reclaim, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -254,18 +255,9 @@ static int simple_lmk_reclaim_thread(void *data)
|
||||
|
||||
void simple_lmk_decide_reclaim(int kswapd_priority)
|
||||
{
|
||||
if (kswapd_priority == CONFIG_ANDROID_SIMPLE_LMK_AGGRESSION) {
|
||||
int v, v1;
|
||||
|
||||
for (v = 0;; v = v1) {
|
||||
v1 = atomic_cmpxchg(&needs_reclaim, v, v + 1);
|
||||
if (likely(v1 == v)) {
|
||||
if (!v)
|
||||
wake_up(&oom_waitq);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (kswapd_priority == CONFIG_ANDROID_SIMPLE_LMK_AGGRESSION &&
|
||||
!atomic_cmpxchg(&needs_reclaim, 0, 1))
|
||||
wake_up(&oom_waitq);
|
||||
}
|
||||
|
||||
void simple_lmk_mm_freed(struct mm_struct *mm)
|
||||
|
Loading…
x
Reference in New Issue
Block a user