aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index beb592fe9389..8a5467ee6265 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -53,8 +53,7 @@ static DEFINE_SPINLOCK(zone_scan_mutex);
53 * of least surprise ... (be careful when you change it) 53 * of least surprise ... (be careful when you change it)
54 */ 54 */
55 55
56unsigned long badness(struct task_struct *p, unsigned long uptime, 56unsigned long badness(struct task_struct *p, unsigned long uptime)
57 struct mem_cgroup *mem)
58{ 57{
59 unsigned long points, cpu_time, run_time, s; 58 unsigned long points, cpu_time, run_time, s;
60 struct mm_struct *mm; 59 struct mm_struct *mm;
@@ -175,12 +174,14 @@ static inline enum oom_constraint constrained_alloc(struct zonelist *zonelist,
175 gfp_t gfp_mask) 174 gfp_t gfp_mask)
176{ 175{
177#ifdef CONFIG_NUMA 176#ifdef CONFIG_NUMA
178 struct zone **z; 177 struct zone *zone;
178 struct zoneref *z;
179 enum zone_type high_zoneidx = gfp_zone(gfp_mask);
179 nodemask_t nodes = node_states[N_HIGH_MEMORY]; 180 nodemask_t nodes = node_states[N_HIGH_MEMORY];
180 181
181 for (z = zonelist->zones; *z; z++) 182 for_each_zone_zonelist(zone, z, zonelist, high_zoneidx)
182 if (cpuset_zone_allowed_softwall(*z, gfp_mask)) 183 if (cpuset_zone_allowed_softwall(zone, gfp_mask))
183 node_clear(zone_to_nid(*z), nodes); 184 node_clear(zone_to_nid(zone), nodes);
184 else 185 else
185 return CONSTRAINT_CPUSET; 186 return CONSTRAINT_CPUSET;
186 187
@@ -254,7 +255,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
254 if (p->oomkilladj == OOM_DISABLE) 255 if (p->oomkilladj == OOM_DISABLE)
255 continue; 256 continue;
256 257
257 points = badness(p, uptime.tv_sec, mem); 258 points = badness(p, uptime.tv_sec);
258 if (points > *ppoints || !chosen) { 259 if (points > *ppoints || !chosen) {
259 chosen = p; 260 chosen = p;
260 *ppoints = points; 261 *ppoints = points;
@@ -460,29 +461,29 @@ EXPORT_SYMBOL_GPL(unregister_oom_notifier);
460 * if a parallel OOM killing is already taking place that includes a zone in 461 * if a parallel OOM killing is already taking place that includes a zone in
461 * the zonelist. Otherwise, locks all zones in the zonelist and returns 1. 462 * the zonelist. Otherwise, locks all zones in the zonelist and returns 1.
462 */ 463 */
463int try_set_zone_oom(struct zonelist *zonelist) 464int try_set_zone_oom(struct zonelist *zonelist, gfp_t gfp_mask)
464{ 465{
465 struct zone **z; 466 struct zoneref *z;
467 struct zone *zone;
466 int ret = 1; 468 int ret = 1;
467 469
468 z = zonelist->zones;
469
470 spin_lock(&zone_scan_mutex); 470 spin_lock(&zone_scan_mutex);
471 do { 471 for_each_zone_zonelist(zone, z, zonelist, gfp_zone(gfp_mask)) {
472 if (zone_is_oom_locked(*z)) { 472 if (zone_is_oom_locked(zone)) {
473 ret = 0; 473 ret = 0;
474 goto out; 474 goto out;
475 } 475 }
476 } while (*(++z) != NULL); 476 }
477
478 for_each_zone_zonelist(zone, z, zonelist, gfp_zone(gfp_mask)) {
479 /*
480 * Lock each zone in the zonelist under zone_scan_mutex so a
481 * parallel invocation of try_set_zone_oom() doesn't succeed
482 * when it shouldn't.
483 */
484 zone_set_flag(zone, ZONE_OOM_LOCKED);
485 }
477 486
478 /*
479 * Lock each zone in the zonelist under zone_scan_mutex so a parallel
480 * invocation of try_set_zone_oom() doesn't succeed when it shouldn't.
481 */
482 z = zonelist->zones;
483 do {
484 zone_set_flag(*z, ZONE_OOM_LOCKED);
485 } while (*(++z) != NULL);
486out: 487out:
487 spin_unlock(&zone_scan_mutex); 488 spin_unlock(&zone_scan_mutex);
488 return ret; 489 return ret;
@@ -493,16 +494,15 @@ out:
493 * allocation attempts with zonelists containing them may now recall the OOM 494 * allocation attempts with zonelists containing them may now recall the OOM
494 * killer, if necessary. 495 * killer, if necessary.
495 */ 496 */
496void clear_zonelist_oom(struct zonelist *zonelist) 497void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_mask)
497{ 498{
498 struct zone **z; 499 struct zoneref *z;
499 500 struct zone *zone;
500 z = zonelist->zones;
501 501
502 spin_lock(&zone_scan_mutex); 502 spin_lock(&zone_scan_mutex);
503 do { 503 for_each_zone_zonelist(zone, z, zonelist, gfp_zone(gfp_mask)) {
504 zone_clear_flag(*z, ZONE_OOM_LOCKED); 504 zone_clear_flag(zone, ZONE_OOM_LOCKED);
505 } while (*(++z) != NULL); 505 }
506 spin_unlock(&zone_scan_mutex); 506 spin_unlock(&zone_scan_mutex);
507} 507}
508 508