diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 2 | ||||
-rw-r--r-- | mm/oom_kill.c | 23 |
2 files changed, 21 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 11c9e6a1dad5..fe4d258ef32b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1556,7 +1556,7 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, | |||
1556 | * quickly exit and free its memory. | 1556 | * quickly exit and free its memory. |
1557 | */ | 1557 | */ |
1558 | if (fatal_signal_pending(current) || task_will_free_mem(current)) { | 1558 | if (fatal_signal_pending(current) || task_will_free_mem(current)) { |
1559 | set_thread_flag(TIF_MEMDIE); | 1559 | mark_tsk_oom_victim(current); |
1560 | return; | 1560 | return; |
1561 | } | 1561 | } |
1562 | 1562 | ||
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 294493a7ae4b..80b34e285f96 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -416,6 +416,23 @@ void note_oom_kill(void) | |||
416 | atomic_inc(&oom_kills); | 416 | atomic_inc(&oom_kills); |
417 | } | 417 | } |
418 | 418 | ||
419 | /** | ||
420 | * mark_tsk_oom_victim - marks the given taks as OOM victim. | ||
421 | * @tsk: task to mark | ||
422 | */ | ||
423 | void mark_tsk_oom_victim(struct task_struct *tsk) | ||
424 | { | ||
425 | set_tsk_thread_flag(tsk, TIF_MEMDIE); | ||
426 | } | ||
427 | |||
428 | /** | ||
429 | * unmark_oom_victim - unmarks the current task as OOM victim. | ||
430 | */ | ||
431 | void unmark_oom_victim(void) | ||
432 | { | ||
433 | clear_thread_flag(TIF_MEMDIE); | ||
434 | } | ||
435 | |||
419 | #define K(x) ((x) << (PAGE_SHIFT-10)) | 436 | #define K(x) ((x) << (PAGE_SHIFT-10)) |
420 | /* | 437 | /* |
421 | * Must be called while holding a reference to p, which will be released upon | 438 | * Must be called while holding a reference to p, which will be released upon |
@@ -440,7 +457,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, | |||
440 | */ | 457 | */ |
441 | task_lock(p); | 458 | task_lock(p); |
442 | if (p->mm && task_will_free_mem(p)) { | 459 | if (p->mm && task_will_free_mem(p)) { |
443 | set_tsk_thread_flag(p, TIF_MEMDIE); | 460 | mark_tsk_oom_victim(p); |
444 | task_unlock(p); | 461 | task_unlock(p); |
445 | put_task_struct(p); | 462 | put_task_struct(p); |
446 | return; | 463 | return; |
@@ -495,7 +512,7 @@ void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, | |||
495 | 512 | ||
496 | /* mm cannot safely be dereferenced after task_unlock(victim) */ | 513 | /* mm cannot safely be dereferenced after task_unlock(victim) */ |
497 | mm = victim->mm; | 514 | mm = victim->mm; |
498 | set_tsk_thread_flag(victim, TIF_MEMDIE); | 515 | mark_tsk_oom_victim(victim); |
499 | pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n", | 516 | pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n", |
500 | task_pid_nr(victim), victim->comm, K(victim->mm->total_vm), | 517 | task_pid_nr(victim), victim->comm, K(victim->mm->total_vm), |
501 | K(get_mm_counter(victim->mm, MM_ANONPAGES)), | 518 | K(get_mm_counter(victim->mm, MM_ANONPAGES)), |
@@ -652,7 +669,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, | |||
652 | */ | 669 | */ |
653 | if (current->mm && | 670 | if (current->mm && |
654 | (fatal_signal_pending(current) || task_will_free_mem(current))) { | 671 | (fatal_signal_pending(current) || task_will_free_mem(current))) { |
655 | set_thread_flag(TIF_MEMDIE); | 672 | mark_tsk_oom_victim(current); |
656 | return; | 673 | return; |
657 | } | 674 | } |
658 | 675 | ||