diff options
-rw-r--r-- | Documentation/cgroup-v2.txt | 20 | ||||
-rw-r--r-- | include/linux/memcontrol.h | 5 | ||||
-rw-r--r-- | include/linux/vm_event_item.h | 1 | ||||
-rw-r--r-- | mm/memcontrol.c | 2 | ||||
-rw-r--r-- | mm/oom_kill.c | 5 | ||||
-rw-r--r-- | mm/vmstat.c | 1 |
6 files changed, 29 insertions, 5 deletions
diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index 5ac2fbde97e6..e6101976e0f1 100644 --- a/Documentation/cgroup-v2.txt +++ b/Documentation/cgroup-v2.txt | |||
@@ -852,13 +852,25 @@ PAGE_SIZE multiple when read back. | |||
852 | 852 | ||
853 | The number of times the cgroup's memory usage was | 853 | The number of times the cgroup's memory usage was |
854 | about to go over the max boundary. If direct reclaim | 854 | about to go over the max boundary. If direct reclaim |
855 | fails to bring it down, the OOM killer is invoked. | 855 | fails to bring it down, the cgroup goes to OOM state. |
856 | 856 | ||
857 | oom | 857 | oom |
858 | 858 | ||
859 | The number of times the OOM killer has been invoked in | 859 | The number of time the cgroup's memory usage was |
860 | the cgroup. This may not exactly match the number of | 860 | reached the limit and allocation was about to fail. |
861 | processes killed but should generally be close. | 861 | |
862 | Depending on context result could be invocation of OOM | ||
863 | killer and retrying allocation or failing alloction. | ||
864 | |||
865 | Failed allocation in its turn could be returned into | ||
866 | userspace as -ENOMEM or siletly ignored in cases like | ||
867 | disk readahead. For now OOM in memory cgroup kills | ||
868 | tasks iff shortage has happened inside page fault. | ||
869 | |||
870 | oom_kill | ||
871 | |||
872 | The number of processes belonging to this cgroup | ||
873 | killed by any kind of OOM killer. | ||
862 | 874 | ||
863 | memory.stat | 875 | memory.stat |
864 | 876 | ||
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index b2a5b1cd4e55..72d0853beb31 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -582,8 +582,11 @@ static inline void count_memcg_event_mm(struct mm_struct *mm, | |||
582 | 582 | ||
583 | rcu_read_lock(); | 583 | rcu_read_lock(); |
584 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); | 584 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); |
585 | if (likely(memcg)) | 585 | if (likely(memcg)) { |
586 | this_cpu_inc(memcg->stat->events[idx]); | 586 | this_cpu_inc(memcg->stat->events[idx]); |
587 | if (idx == OOM_KILL) | ||
588 | cgroup_file_notify(&memcg->events_file); | ||
589 | } | ||
587 | rcu_read_unlock(); | 590 | rcu_read_unlock(); |
588 | } | 591 | } |
589 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 592 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index be3ab2d13adf..37e8d31a4632 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h | |||
@@ -41,6 +41,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, | |||
41 | KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY, | 41 | KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY, |
42 | PAGEOUTRUN, PGROTATED, | 42 | PAGEOUTRUN, PGROTATED, |
43 | DROP_PAGECACHE, DROP_SLAB, | 43 | DROP_PAGECACHE, DROP_SLAB, |
44 | OOM_KILL, | ||
44 | #ifdef CONFIG_NUMA_BALANCING | 45 | #ifdef CONFIG_NUMA_BALANCING |
45 | NUMA_PTE_UPDATES, | 46 | NUMA_PTE_UPDATES, |
46 | NUMA_HUGE_PTE_UPDATES, | 47 | NUMA_HUGE_PTE_UPDATES, |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3e2f8cf85b4c..4f686fc1c5fa 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -3573,6 +3573,7 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v) | |||
3573 | 3573 | ||
3574 | seq_printf(sf, "oom_kill_disable %d\n", memcg->oom_kill_disable); | 3574 | seq_printf(sf, "oom_kill_disable %d\n", memcg->oom_kill_disable); |
3575 | seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom); | 3575 | seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom); |
3576 | seq_printf(sf, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL)); | ||
3576 | return 0; | 3577 | return 0; |
3577 | } | 3578 | } |
3578 | 3579 | ||
@@ -5164,6 +5165,7 @@ static int memory_events_show(struct seq_file *m, void *v) | |||
5164 | seq_printf(m, "high %lu\n", memcg_sum_events(memcg, MEMCG_HIGH)); | 5165 | seq_printf(m, "high %lu\n", memcg_sum_events(memcg, MEMCG_HIGH)); |
5165 | seq_printf(m, "max %lu\n", memcg_sum_events(memcg, MEMCG_MAX)); | 5166 | seq_printf(m, "max %lu\n", memcg_sum_events(memcg, MEMCG_MAX)); |
5166 | seq_printf(m, "oom %lu\n", memcg_sum_events(memcg, MEMCG_OOM)); | 5167 | seq_printf(m, "oom %lu\n", memcg_sum_events(memcg, MEMCG_OOM)); |
5168 | seq_printf(m, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL)); | ||
5167 | 5169 | ||
5168 | return 0; | 5170 | return 0; |
5169 | } | 5171 | } |
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 04c9143a8625..0e2c925e7826 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -876,6 +876,11 @@ static void oom_kill_process(struct oom_control *oc, const char *message) | |||
876 | /* Get a reference to safely compare mm after task_unlock(victim) */ | 876 | /* Get a reference to safely compare mm after task_unlock(victim) */ |
877 | mm = victim->mm; | 877 | mm = victim->mm; |
878 | mmgrab(mm); | 878 | mmgrab(mm); |
879 | |||
880 | /* Raise event before sending signal: task reaper must see this */ | ||
881 | count_vm_event(OOM_KILL); | ||
882 | count_memcg_event_mm(mm, OOM_KILL); | ||
883 | |||
879 | /* | 884 | /* |
880 | * We should send SIGKILL before setting TIF_MEMDIE in order to prevent | 885 | * We should send SIGKILL before setting TIF_MEMDIE in order to prevent |
881 | * the OOM victim from depleting the memory reserves from the user | 886 | * the OOM victim from depleting the memory reserves from the user |
diff --git a/mm/vmstat.c b/mm/vmstat.c index 6dae6b240b21..46281825c710 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -1018,6 +1018,7 @@ const char * const vmstat_text[] = { | |||
1018 | 1018 | ||
1019 | "drop_pagecache", | 1019 | "drop_pagecache", |
1020 | "drop_slab", | 1020 | "drop_slab", |
1021 | "oom_kill", | ||
1021 | 1022 | ||
1022 | #ifdef CONFIG_NUMA_BALANCING | 1023 | #ifdef CONFIG_NUMA_BALANCING |
1023 | "numa_pte_updates", | 1024 | "numa_pte_updates", |