aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2009-05-11 18:45:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 14:00:52 -0400
commit34006e11ee406daa98aaf685d2de80c70e68decf (patch)
tree005c31faa699a5bc4123103cbeb809dce2f3f7a6 /drivers
parent31d59a4198f3f07da8250dfb5b698eacfaf612e5 (diff)
Staging: android: lowmemorykiller: cleanup android low memory killer
Clean up the code in lowmem_shrink() for the Android low memory killer so that it follows the kernel coding style. It's unnecessary to check for p->oomkilladj >= min_adj if the selected task's oomkilladj score is stored since get_mm_rss() will always be greater than zero. Cc: San Mehat <san@android.com> Cc: Arve Hjønnevåg <arve@android.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/android/lowmemorykiller.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index b2ab7faac4fb..f61333b96025 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -57,58 +57,71 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
57 int i; 57 int i;
58 int min_adj = OOM_ADJUST_MAX + 1; 58 int min_adj = OOM_ADJUST_MAX + 1;
59 int selected_tasksize = 0; 59 int selected_tasksize = 0;
60 int selected_oom_adj;
60 int array_size = ARRAY_SIZE(lowmem_adj); 61 int array_size = ARRAY_SIZE(lowmem_adj);
61 int other_free = global_page_state(NR_FREE_PAGES); 62 int other_free = global_page_state(NR_FREE_PAGES);
62 int other_file = global_page_state(NR_FILE_PAGES); 63 int other_file = global_page_state(NR_FILE_PAGES);
63 if(lowmem_adj_size < array_size) 64
65 if (lowmem_adj_size < array_size)
64 array_size = lowmem_adj_size; 66 array_size = lowmem_adj_size;
65 if(lowmem_minfree_size < array_size) 67 if (lowmem_minfree_size < array_size)
66 array_size = lowmem_minfree_size; 68 array_size = lowmem_minfree_size;
67 for(i = 0; i < array_size; i++) { 69 for (i = 0; i < array_size; i++) {
68 if (other_free < lowmem_minfree[i] && 70 if (other_free < lowmem_minfree[i] &&
69 other_file < lowmem_minfree[i]) { 71 other_file < lowmem_minfree[i]) {
70 min_adj = lowmem_adj[i]; 72 min_adj = lowmem_adj[i];
71 break; 73 break;
72 } 74 }
73 } 75 }
74 if(nr_to_scan > 0) 76 if (nr_to_scan > 0)
75 lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n", nr_to_scan, gfp_mask, other_free, other_file, min_adj); 77 lowmem_print(3, "lowmem_shrink %d, %x, ofree %d %d, ma %d\n",
78 nr_to_scan, gfp_mask, other_free, other_file,
79 min_adj);
76 rem = global_page_state(NR_ACTIVE_ANON) + 80 rem = global_page_state(NR_ACTIVE_ANON) +
77 global_page_state(NR_ACTIVE_FILE) + 81 global_page_state(NR_ACTIVE_FILE) +
78 global_page_state(NR_INACTIVE_ANON) + 82 global_page_state(NR_INACTIVE_ANON) +
79 global_page_state(NR_INACTIVE_FILE); 83 global_page_state(NR_INACTIVE_FILE);
80 if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) { 84 if (nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1) {
81 lowmem_print(5, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem); 85 lowmem_print(5, "lowmem_shrink %d, %x, return %d\n",
86 nr_to_scan, gfp_mask, rem);
82 return rem; 87 return rem;
83 } 88 }
89 selected_oom_adj = min_adj;
84 90
85 read_lock(&tasklist_lock); 91 read_lock(&tasklist_lock);
86 for_each_process(p) { 92 for_each_process(p) {
87 if (p->oomkilladj < min_adj || !p->mm) 93 int oom_adj;
94
95 if (!p->mm)
96 continue;
97 oom_adj = p->oomkilladj;
98 if (oom_adj < min_adj)
88 continue; 99 continue;
89 tasksize = get_mm_rss(p->mm); 100 tasksize = get_mm_rss(p->mm);
90 if (tasksize <= 0) 101 if (tasksize <= 0)
91 continue; 102 continue;
92 if (selected) { 103 if (selected) {
93 if (p->oomkilladj < selected->oomkilladj) 104 if (oom_adj < selected_oom_adj)
94 continue; 105 continue;
95 if (p->oomkilladj == selected->oomkilladj && 106 if (oom_adj == selected_oom_adj &&
96 tasksize <= selected_tasksize) 107 tasksize <= selected_tasksize)
97 continue; 108 continue;
98 } 109 }
99 selected = p; 110 selected = p;
100 selected_tasksize = tasksize; 111 selected_tasksize = tasksize;
112 selected_oom_adj = oom_adj;
101 lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n", 113 lowmem_print(2, "select %d (%s), adj %d, size %d, to kill\n",
102 p->pid, p->comm, p->oomkilladj, tasksize); 114 p->pid, p->comm, oom_adj, tasksize);
103 } 115 }
104 if(selected != NULL) { 116 if (selected) {
105 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n", 117 lowmem_print(1, "send sigkill to %d (%s), adj %d, size %d\n",
106 selected->pid, selected->comm, 118 selected->pid, selected->comm,
107 selected->oomkilladj, selected_tasksize); 119 selected_oom_adj, selected_tasksize);
108 force_sig(SIGKILL, selected); 120 force_sig(SIGKILL, selected);
109 rem -= selected_tasksize; 121 rem -= selected_tasksize;
110 } 122 }
111 lowmem_print(4, "lowmem_shrink %d, %x, return %d\n", nr_to_scan, gfp_mask, rem); 123 lowmem_print(4, "lowmem_shrink %d, %x, return %d\n",
124 nr_to_scan, gfp_mask, rem);
112 read_unlock(&tasklist_lock); 125 read_unlock(&tasklist_lock);
113 return rem; 126 return rem;
114} 127}