1
1
/* drivers/misc/lowmemorykiller.c
2
2
*
3
3
* The lowmemorykiller driver lets user-space specify a set of memory thresholds
4
- * where processes with a range of oom_adj values will get killed. Specify the
5
- * minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the
6
- * number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both
7
- * files take a comma separated list of numbers in ascending order.
4
+ * where processes with a range of oom_score_adj values will get killed. Specify
5
+ * the minimum oom_score_adj values in
6
+ * /sys/module/lowmemorykiller/parameters/adj and the number of free pages in
7
+ * /sys/module/lowmemorykiller/parameters/minfree. Both files take a comma
8
+ * separated list of numbers in ascending order.
8
9
*
9
10
* For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
10
11
* "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill
11
- * processes with a oom_adj value of 8 or higher when the free memory drops
12
- * below 4096 pages and kill processes with a oom_adj value of 0 or higher
13
- * when the free memory drops below 1024 pages.
12
+ * processes with a oom_score_adj value of 8 or higher when the free memory
13
+ * drops below 4096 pages and kill processes with a oom_score_adj value of 0 or
14
+ * higher when the free memory drops below 1024 pages.
14
15
*
15
16
* The driver considers memory used for caches to be free, but if a large
16
17
* percentage of the cached memory is locked this can be very inaccurate
@@ -88,9 +89,9 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
88
89
int rem = 0 ;
89
90
int tasksize ;
90
91
int i ;
91
- int min_adj = OOM_ADJUST_MAX + 1 ;
92
+ int min_score_adj = OOM_SCORE_ADJ_MAX + 1 ;
92
93
int selected_tasksize = 0 ;
93
- int selected_oom_adj ;
94
+ int selected_oom_score_adj ;
94
95
int array_size = ARRAY_SIZE (lowmem_adj );
95
96
int other_free = global_page_state (NR_FREE_PAGES );
96
97
int other_file = global_page_state (NR_FILE_PAGES ) -
@@ -116,29 +117,29 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
116
117
for (i = 0 ; i < array_size ; i ++ ) {
117
118
if (other_free < lowmem_minfree [i ] &&
118
119
other_file < lowmem_minfree [i ]) {
119
- min_adj = lowmem_adj [i ];
120
+ min_score_adj = lowmem_adj [i ];
120
121
break ;
121
122
}
122
123
}
123
124
if (sc -> nr_to_scan > 0 )
124
125
lowmem_print (3 , "lowmem_shrink %lu, %x, ofree %d %d, ma %d\n" ,
125
126
sc -> nr_to_scan , sc -> gfp_mask , other_free ,
126
- other_file , min_adj );
127
+ other_file , min_score_adj );
127
128
rem = global_page_state (NR_ACTIVE_ANON ) +
128
129
global_page_state (NR_ACTIVE_FILE ) +
129
130
global_page_state (NR_INACTIVE_ANON ) +
130
131
global_page_state (NR_INACTIVE_FILE );
131
- if (sc -> nr_to_scan <= 0 || min_adj == OOM_ADJUST_MAX + 1 ) {
132
+ if (sc -> nr_to_scan <= 0 || min_score_adj == OOM_SCORE_ADJ_MAX + 1 ) {
132
133
lowmem_print (5 , "lowmem_shrink %lu, %x, return %d\n" ,
133
134
sc -> nr_to_scan , sc -> gfp_mask , rem );
134
135
return rem ;
135
136
}
136
- selected_oom_adj = min_adj ;
137
+ selected_oom_score_adj = min_score_adj ;
137
138
138
139
rcu_read_lock ();
139
140
for_each_process (tsk ) {
140
141
struct task_struct * p ;
141
- int oom_adj ;
142
+ int oom_score_adj ;
142
143
143
144
if (tsk -> flags & PF_KTHREAD )
144
145
continue ;
@@ -147,8 +148,8 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
147
148
if (!p )
148
149
continue ;
149
150
150
- oom_adj = p -> signal -> oom_adj ;
151
- if (oom_adj < min_adj ) {
151
+ oom_score_adj = p -> signal -> oom_score_adj ;
152
+ if (oom_score_adj < min_score_adj ) {
152
153
task_unlock (p );
153
154
continue ;
154
155
}
@@ -157,22 +158,22 @@ static int lowmem_shrink(struct shrinker *s, struct shrink_control *sc)
157
158
if (tasksize <= 0 )
158
159
continue ;
159
160
if (selected ) {
160
- if (oom_adj < selected_oom_adj )
161
+ if (oom_score_adj < selected_oom_score_adj )
161
162
continue ;
162
- if (oom_adj == selected_oom_adj &&
163
+ if (oom_score_adj == selected_oom_score_adj &&
163
164
tasksize <= selected_tasksize )
164
165
continue ;
165
166
}
166
167
selected = p ;
167
168
selected_tasksize = tasksize ;
168
- selected_oom_adj = oom_adj ;
169
+ selected_oom_score_adj = oom_score_adj ;
169
170
lowmem_print (2 , "select %d (%s), adj %d, size %d, to kill\n" ,
170
- p -> pid , p -> comm , oom_adj , tasksize );
171
+ p -> pid , p -> comm , oom_score_adj , tasksize );
171
172
}
172
173
if (selected ) {
173
174
lowmem_print (1 , "send sigkill to %d (%s), adj %d, size %d\n" ,
174
175
selected -> pid , selected -> comm ,
175
- selected_oom_adj , selected_tasksize );
176
+ selected_oom_score_adj , selected_tasksize );
176
177
/*
177
178
* If CONFIG_PROFILING is off, then task_handoff_register()
178
179
* is a nop. In that case we don't want to stall the killer
0 commit comments