Skip to content
This repository has been archived by the owner on Sep 9, 2019. It is now read-only.

Commit

Permalink
simple_lmk: React faster to kswapd reclaim events
Browse files Browse the repository at this point in the history
With the previous change, there would be up to a KSWAPD_LMK_EXPIRES delay before
Simple LMK would react to a kswapd reclaim being needed, and it would still make
it difficult for a kswapd reclaim to occur if an oom reclaim occurred less than
KSWAPD_LMK_EXPIRES ago.

To remedy Simple LMK's slow kswapd reaction time, poll every other jiffy once
kswapd has been running without sleeping for at least KSWAPD_LMK_EXPIRES' worth
of _wall time_. In addition, when a kswapd reclaim is needed, don't disregard it
if an oom reclaim has occurred recently; in other words, kswapd reclaims are
considered to be of high importance and should not be ignored.

Signed-off-by: Sultan Alsawaf <[email protected]>
Signed-off-by: kdrag0n <[email protected]>
  • Loading branch information
kerneltoast authored and kdrag0n committed Feb 20, 2019
1 parent 954cac4 commit 07737c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/staging/android/simple_lmk.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static cputime_t get_kswapd_cputime(void)

static void simple_lmk_reclaim_work(struct work_struct *work)
{
unsigned long mib_freed = 0;
unsigned long mib_freed, resched_delay_jiffies = 1;
cputime_t kswapd_time_now;
u64 delta_us;

Expand All @@ -162,15 +162,15 @@ static void simple_lmk_reclaim_work(struct work_struct *work)
kswapd_start_time = kswapd_time_now;

mutex_lock(&reclaim_lock);
if (time_after_eq(jiffies, last_reclaim_jiffies + KSWAPD_LMK_EXPIRES))
mib_freed = do_lmk_reclaim(MIN_FREE_PAGES);
mib_freed = do_lmk_reclaim(MIN_FREE_PAGES);
mutex_unlock(&reclaim_lock);

if (mib_freed)
pr_info("kswapd: freed %lu MiB\n", mib_freed);

resched_delay_jiffies = KSWAPD_LMK_EXPIRES;
reschedule:
queue_delayed_work(simple_lmk_wq, &reclaim_work, KSWAPD_LMK_EXPIRES);
queue_delayed_work(simple_lmk_wq, &reclaim_work, resched_delay_jiffies);
}

void simple_lmk_one_reclaim(void)
Expand Down

0 comments on commit 07737c4

Please sign in to comment.