Skip to content

Commit

Permalink
Change low memory killer to take swap into account and prevent swap t…
Browse files Browse the repository at this point in the history
…hrashing.
  • Loading branch information
travistabbal committed Aug 22, 2011
1 parent 73732ed commit 0d6df94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion drivers/staging/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ source "drivers/staging/sep/Kconfig"

source "drivers/staging/iio/Kconfig"

source "drivers/staging/ramzswap/Kconfig"
source "drivers/staging/zram/Kconfig"

source "drivers/staging/zcache/Kconfig"

Expand Down
25 changes: 19 additions & 6 deletions drivers/staging/android/lowmemorykiller.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
#include <linux/oom.h>
#include <linux/sched.h>
#include <linux/notifier.h>
#include <linux/swap.h>

static uint32_t lowmem_debug_level = 2;
static uint32_t lowmem_debug_level = 4;
static int lowmem_adj[6] = {
0,
1,
Expand Down Expand Up @@ -83,6 +84,7 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
{
struct task_struct *p;
struct task_struct *selected = NULL;
struct sysinfo si;
int rem = 0;
int tasksize;
int i;
Expand All @@ -91,8 +93,18 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
int selected_oom_adj;
int array_size = ARRAY_SIZE(lowmem_adj);
int other_free = global_page_state(NR_FREE_PAGES);
int other_file = global_page_state(NR_FILE_PAGES) -
global_page_state(NR_SHMEM);
int other_file = global_page_state(NR_FILE_PAGES) - global_page_state(NR_SHMEM);

si_swapinfo(&si);

//unsigned long int usedSwap = si.totalswap - si.freeswap;

if (si.freeswap > (si.totalswap * .75))
{
other_free += si.freeswap;
lowmem_print(3, "OF %d FREESWPAGES %ld NEWOF %ld\n", other_free, si.freeswap, other_free + si.freeswap);
}


/*
* If we already have a death outstanding, then
Expand All @@ -109,9 +121,10 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
array_size = lowmem_adj_size;
if (lowmem_minfree_size < array_size)
array_size = lowmem_minfree_size;
for (i = 0; i < array_size; i++) {
if (other_free < lowmem_minfree[i] &&
other_file < lowmem_minfree[i]) {
for (i = 0; i < array_size; i++)
{
if (other_free < lowmem_minfree[i] && other_file < lowmem_minfree[i])
{
min_adj = lowmem_adj[i];
break;
}
Expand Down

0 comments on commit 0d6df94

Please sign in to comment.