mm/oom_kill: count global and memory cgroup oom kills
Subsystems (6)
PATCH 1/1 mm/oom_kill: count global and memory cgroup oom kills
Show count of global oom killer invocations in /proc/vmstat and count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).
Also describe difference between "oom" and "oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.
These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
--- Documentation/cgroup-v2.txt | 12 +++++++++++- include/linux/memcontrol.h | 1 + include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 2 ++ mm/oom_kill.c | 6 ++++++ mm/vmstat.c | 1 + 6 files changed, 22 insertions(+), 1 deletion(-)
Documentation/cgroup-v2.txt +11 -1
@@ -830,9 +830,19 @@ PAGE_SIZE multiple when read back. oom + The number of time the cgroup's memory usage was + reached the limit and allocation was about to fail. + Result could be oom kill, -ENOMEM from any syscall or + completely ignored in cases like disk readahead. + For now oom in memory cgroup kills tasks iff shortage + has happened inside page fault. + + oom_kill + The number of times the OOM killer has been invoked in the cgroup. This may not exactly match the number of - processes killed but should generally be close. + processes killed but should generally be close: each + invocation could kill several processes at once. memory.stat
include/linux/memcontrol.h +1 -0
@@ -55,6 +55,7 @@ enum memcg_event_item {MEMCG_HIGH ,MEMCG_MAX ,MEMCG_OOM , +MEMCG_OOM_KILL , MEMCG_NR_EVENTS, };
include/linux/vm_event_item.h +1 -0
@@ -41,6 +41,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,KSWAPD_LOW_WMARK_HIT_QUICKLY ,KSWAPD_HIGH_WMARK_HIT_QUICKLY ,PAGEOUTRUN ,PGROTATED ,DROP_PAGECACHE ,DROP_SLAB , +OOM_KILL , #ifdef CONFIG_NUMA_BALANCINGNUMA_PTE_UPDATES , NUMA_HUGE_PTE_UPDATES,
mm/memcontrol.c +2 -0
@@ -3574,6 +3574,7 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)seq_printf (sf,"oom_kill_disable %d\n" , memcg->oom_kill_disable);seq_printf (sf,"under_oom %d\n" , (bool )memcg->under_oom); +seq_printf (sf,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }
@@ -5165,6 +5166,7 @@ static int memory_events_show(struct seq_file *m, void *v)seq_printf (m,"high %lu\n" ,memcg_sum_events (memcg,MEMCG_HIGH ));seq_printf (m,"max %lu\n" ,memcg_sum_events (memcg,MEMCG_MAX ));seq_printf (m,"oom %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM )); +seq_printf (m,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }
mm/oom_kill.c +6 -0
@@ -873,6 +873,12 @@ static void oom_kill_process(struct oom_control *oc, const char *message) victim = p; } +/* Raise event before sending signal: reaper must see this */ +if (!is_memcg_oom (oc)) +count_vm_event (OOM_KILL ); +else +mem_cgroup_event (oc->memcg,MEMCG_OOM_KILL ); +/* Get a reference to safely compare mm after task_unlock(victim) */ mm = victim->mm;mmgrab (mm);
mm/vmstat.c +1 -0
@@ -1018,6 +1018,7 @@ const char * const vmstat_text[] = {"drop_pagecache" ,"drop_slab" , +"oom_kill" , #ifdef CONFIG_NUMA_BALANCING "numa_pte_updates",
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
maintainer[CC Vladimir and Johannes as this involves memcg]
i will get to this early next week but from a quick look it seems acceptable.
Quoted 125 lines · Konstantin Khlebnikov
Show count of global oom killer invocations in
/proc/vmstatand count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).Also describe difference between "oom" and "
oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
Signed-off-by Konstantin Khlebnikov <[email protected]>--- Documentation/cgroup-v2.txt | 12 +++++++++++- include/linux/memcontrol.h | 1 + include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 2 ++ mm/oom_kill.c | 6 ++++++ mm/vmstat.c | 1 + 6 files changed, 22 insertions(+), 1 deletion(-)Documentation/cgroup-v2.txt +11
-1@@ -830,9 +830,19 @@ PAGE_SIZE multiple when read back. oom + The number of time the cgroup's memory usage was + reached the limit and allocation was about to fail. + Result could be oom kill, -ENOMEM from any syscall or + completely ignored in cases like disk readahead. + For now oom in memory cgroup kills tasks iff shortage + has happened inside page fault. + + oom_kill + The number of times the OOM killer has been invoked in the cgroup. This may not exactly match the number of - processes killed but should generally be close. + processes killed but should generally be close: each + invocation could kill several processes at once. memory.statinclude/linux/memcontrol.h +1
-0@@ -55,6 +55,7 @@ enum memcg_event_item {MEMCG_HIGH ,MEMCG_MAX ,MEMCG_OOM , +MEMCG_OOM_KILL , MEMCG_NR_EVENTS, };include/linux/vm_event_item.h +1
-0@@ -41,6 +41,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,KSWAPD_LOW_WMARK_HIT_QUICKLY ,KSWAPD_HIGH_WMARK_HIT_QUICKLY ,PAGEOUTRUN ,PGROTATED ,DROP_PAGECACHE ,DROP_SLAB , +OOM_KILL , #ifdef CONFIG_NUMA_BALANCINGNUMA_PTE_UPDATES , NUMA_HUGE_PTE_UPDATES,mm/memcontrol.c +2
-0@@ -3574,6 +3574,7 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)seq_printf (sf,"oom_kill_disable %d\n" , memcg->oom_kill_disable);seq_printf (sf,"under_oom %d\n" , (bool )memcg->under_oom); +seq_printf (sf,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }@@ -5165,6 +5166,7 @@ static int memory_events_show(struct seq_file *m, void *v)seq_printf (m,"high %lu\n" ,memcg_sum_events (memcg,MEMCG_HIGH ));seq_printf (m,"max %lu\n" ,memcg_sum_events (memcg,MEMCG_MAX ));seq_printf (m,"oom %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM )); +seq_printf (m,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }mm/oom_kill.c +6
-0@@ -873,6 +873,12 @@ static void oom_kill_process(struct oom_control *oc, const char *message) victim = p; } +/* Raise event before sending signal: reaper must see this */ +if (!is_memcg_oom (oc)) +count_vm_event (OOM_KILL ); +else +mem_cgroup_event (oc->memcg,MEMCG_OOM_KILL ); +/* Get a reference to safely compare mm after task_unlock(victim) */ mm = victim->mm;mmgrab (mm);mm/vmstat.c +1
-1@@ -1018,6 +1018,7 @@ const char * const vmstat_text[] = {"drop_pagecache" ,"drop_slab" , +"oom_kill" , #ifdef CONFIG_NUMA_BALANCING "numa_pte_updates", --To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected] For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 2 lines
Michal Hocko SUSE Labs
2017-05-19 15:22 GMT+01:00 Konstantin Khlebnikov <[email protected]>:
Quoted 26 lines
Show count of global oom killer invocations in
/proc/vmstatand count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).Also describe difference between "oom" and "
oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
Signed-off-by Konstantin Khlebnikov <[email protected]>--- Documentation/cgroup-v2.txt | 12 +++++++++++- include/linux/memcontrol.h | 1 + include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 2 ++ mm/oom_kill.c | 6 ++++++ mm/vmstat.c | 1 + 6 files changed, 22 insertions(+), 1 deletion(-)Documentation/cgroup-v2.txt +0
-0
Documentation/cgroup-v2.txt PAGE_SIZE multiple when read back. · line 838
Quoted 9 lines
Documentation/cgroup-v2.txt +6
-0@@ -830,9 +830,19 @@ PAGE_SIZE multiple when read back. oom + The number of time the cgroup's memory usage was + reached the limit and allocation was about to fail. + Result could be oom kill, -ENOMEM from any syscall or + completely ignored in cases like disk readahead. + For now oom in memory cgroup kills tasks iff shortage + has happened inside page fault.
From a user's point of view the difference between "oom" and "max" becomes really vague here,
assuming that "max" is described almost in the same words:
"The number of times the cgroup's memory usage was about to go over the max boundary. If direct reclaim fails to bring it down, the OOM killer is invoked."
I wonder, if it's better to fix the existing "oom" value to show what it has to show, according to docs,
rather than to introduce a new one?
Documentation/cgroup-v2.txt PAGE_SIZE multiple when read back. · line 848
Quoted 11 lines
Documentation/cgroup-v2.txt +5
-1+ + oom_kill + The number of times the OOM killer has been invoked in the cgroup. This may not exactly match the number of - processes killed but should generally be close. + processes killed but should generally be close: each + invocation could kill several processes at once. memory.stat
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 41 lines · Roman Guschin
2017-05-19 15:22 GMT+01:00 Konstantin Khlebnikov <[email protected]>:
Quoted 26 lines
Show count of global oom killer invocations in
/proc/vmstatand count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).Also describe difference between "oom" and "
oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
Signed-off-by Konstantin Khlebnikov <[email protected]>--- Documentation/cgroup-v2.txt | 12 +++++++++++- include/linux/memcontrol.h | 1 + include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 2 ++ mm/oom_kill.c | 6 ++++++ mm/vmstat.c | 1 + 6 files changed, 22 insertions(+), 1 deletion(-)Documentation/cgroup-v2.txt +0
-0Documentation/cgroup-v2.txt PAGE_SIZE multiple when read back. · line 838
Quoted 9 lines
Documentation/cgroup-v2.txt +6
-0@@ -830,9 +830,19 @@ PAGE_SIZE multiple when read back. oom + The number of time the cgroup's memory usage was + reached the limit and allocation was about to fail. + Result could be oom kill, -ENOMEM from any syscall or + completely ignored in cases like disk readahead. + For now oom in memory cgroup kills tasks iff shortage + has happened inside page fault.From a user's point of view the difference between "oom" and "max"
becomes really vague here,
assuming that "max" is described almost in the same words:
Quoted 8 lines
"The number of times the cgroup's memory usage was about to go over the max boundary. If direct reclaim fails to bring it down, the OOM killer is invoked."
I wonder, if it's better to fix the existing "oom" value to show what it has to show, according to docs,
rather than to introduce a new one?
Nope, they are different. I think we should rephase documentation somehow
low - count of reclaims below low level
high - count of post-allocation reclaims above high level max - count of direct reclaims
oom - count of failed direct reclaimsoom_kill - count of oom killer invocations and killed processes
Quoted 11 lines
Documentation/cgroup-v2.txt PAGE_SIZE multiple when read back. · line 848
Quoted 11 lines
Documentation/cgroup-v2.txt +5
-1+ + oom_kill + The number of times the OOM killer has been invoked in the cgroup. This may not exactly match the number of - processes killed but should generally be close. + processes killed but should generally be close: each + invocation could kill several processes at once. memory.stat
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
2017-05-22 10:11 GMT+01:00 Konstantin Khlebnikov <[email protected]>:
Quoted 19 lines · Roman Guschin
Quoted 7 lines
2017-05-19 15:22 GMT+01:00 Konstantin Khlebnikov <[email protected]>:
From a user's point of view the difference between "oom" and "max"
becomes really vague here,
assuming that "max" is described almost in the same words:Quoted 8 lines
"The number of times the cgroup's memory usage was about to go over the max boundary. If direct reclaim fails to bring it down, the OOM killer is invoked."
I wonder, if it's better to fix the existing "oom" value to show what it has to show, according to docs,
rather than to introduce a new one?
Quoted 7 lines
Nope, they are different. I think we should rephase documentation somehow
low - count of reclaims below low level
high - count of post-allocation reclaims above high level max - count of direct reclaims
oom - count of failed direct reclaimsoom_kill- count of oom killer invocations and killed processes
Definitely worth it.
Also, I would prefer to reserve "oom" for number of oom victims, and introduce something like "reclaim_failed".
It will be consistent with existing vmstat.
Thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
David Rientjes
reviewerQuoted 8 lines · Konstantin Khlebnikov
Nope, they are different. I think we should rephase documentation somehow
low - count of reclaims below low level
high - count of post-allocation reclaims above high level max - count of direct reclaims
oom - count of failed direct reclaimsoom_kill- count of oom killer invocations and killed processes
In our kernel, we've maintained counts of oom kills per memcg for years as part of memory.oom_control for memcg v1, but we've also found it helpful to complement that with another count that specifies the number of processes oom killed that were attached to that exact memcg.
In your patch, oom_kill in memory.oom_control specifies that number of oom events that resulted in an oom kill of a process from that hierarchy, but not the number of processes killed from a specific memcg (the difference between oc->memcg and mem_cgroup_from_task(victim)). Not sure if you would also find it helpful.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 16 lines · David Rientjes
Quoted 8 lines · Konstantin Khlebnikov
Nope, they are different. I think we should rephase documentation somehow
low - count of reclaims below low level
high - count of post-allocation reclaims above high level max - count of direct reclaims
oom - count of failed direct reclaimsoom_kill- count of oom killer invocations and killed processesIn our kernel, we've maintained counts of oom kills per memcg for years as part of memory.oom_control for memcg v1, but we've also found it helpful to complement that with another count that specifies the number of processes oom killed that were attached to that exact memcg.
Quoted 6 lines
In your patch,
oom_killin memory.oom_control specifies that number of oom events that resulted in an oom kill of a process from that hierarchy, but not the number of processes killed from a specific memcg (the difference betweenoc->memcgandmem_cgroup_from_task(victim)). Not sure if you would also find it helpful.
This is worth addition. Let's call it "oom_victim" for short.
It allows to locate leaky part if they are spread over sub-containers within common limit. But doesn't tell which limit caused this kill. For hierarchical limits this might be not so easy.
I think oom_kill better suits for automatic actions - restart affected hierarchy, increase limits, e.t.c. But oom_victim allows to determine container affected by global oom killer.
So, probably it's worth to merge them together and increment oom_kill by global killer for victim memcg:
if (!is_memcg_oom(oc)) {
count_vm_event(OOM_KILL);
mem_cgroup_count_vm_event(mm, OOM_KILL);
} else
mem_cgroup_event(oc->memcg, OOM_KILL);--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
David Rientjes
reviewerQuoted 11 lines · Konstantin Khlebnikov
This is worth addition. Let's call it "
oom_victim" for short.It allows to locate leaky part if they are spread over sub-containers within common limit.
But doesn't tell which limit caused this kill. For hierarchical limits this might be not so easy.I think
oom_killbetter suits for automatic actions - restart affected hierarchy, increase limits,e.t.c.
Butoom_victimallows to determine container affected by global oom killer.
Quoted 9 lines
So, probably it's worth to merge them together and increment
oom_killby global killer for victim memcg:if (!is_memcg_oom(oc)) { count_vm_event(OOM_KILL); mem_cgroup_count_vm_event(mm, OOM_KILL); } else mem_cgroup_event(oc->memcg, OOM_KILL);
Our complete solution is that we have a complementary memory.oom_kill_control that allows users to register for eventfd(2) notification when the kernel oom killer kills a victim, but this is because we have had complete support for userspace oom handling for years. When read, it exports three classes of information:
- the "total" (hierarchical) and "local" (memcg specific) number of oom kills for system oom conditions (overcommit),
- the "total" and "local" number of oom kills for memcg oom conditions, and
- the total number of processes in the hierarchy where an oom victim was reaped successfully and unsuccessfully.
One benefit of this is that it prevents us from having to scrape the kernel log for oom events which has been troublesome in the past, but userspace can easily do so when the eventfd triggers for the kill notification.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 35 lines · David Rientjes
Quoted 11 lines · Konstantin Khlebnikov
This is worth addition. Let's call it "
oom_victim" for short.It allows to locate leaky part if they are spread over sub-containers within common limit.
But doesn't tell which limit caused this kill. For hierarchical limits this might be not so easy.I think
oom_killbetter suits for automatic actions - restart affected hierarchy, increase limits,e.t.c.
Butoom_victimallows to determine container affected by global oom killer.Quoted 9 lines
So, probably it's worth to merge them together and increment
oom_killby global killer for victim memcg:if (!is_memcg_oom(oc)) { count_vm_event(OOM_KILL); mem_cgroup_count_vm_event(mm, OOM_KILL); } else mem_cgroup_event(oc->memcg, OOM_KILL);Our complete solution is that we have a complementary memory.oom_kill_control that allows users to register for eventfd(2) notification when the kernel oom killer kills a victim, but this is because we have had complete support for userspace oom handling for years. When read, it exports three classes of information:
- the "total" (hierarchical) and "local" (memcg specific) number of oom kills for system oom conditions (overcommit),
- the "total" and "local" number of oom kills for memcg oom conditions, and
Quoted 8 lines
- the total number of processes in the hierarchy where an oom victim was reaped successfully and unsuccessfully.
One benefit of this is that it prevents us from having to scrape the kernel log for oom events which has been troublesome in the past, but userspace can easily do so when the eventfd triggers for the kill notification.
Ok. I've decided to simplify this thing and count kills to cgroup where task lived. Like page faults. And show in vmstat total count of any kind of kills.
Simply:
count_vm_event(OOM_KILL); mem_cgroup_count_vm_event(mm, OOM_KILL);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Konstantin Khlebnikov
Show count of global oom killer invocations in
/proc/vmstatand count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).Also describe difference between "oom" and "
oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
Have you considered adding memcg's oom alternative for the global case as well. It would be useful to see how many times we hit the OOM condition without killing anything. That could help debugging issues when the OOM killer cannot be invoked (e.g. GFP_NO{FS,IO} contextx) and the system cannot get out of the oom situation.
Quoted 1 line
Signed-off-by Konstantin Khlebnikov <[email protected]>
Quoted 113 lines
--- Documentation/cgroup-v2.txt | 12 +++++++++++- include/linux/memcontrol.h | 1 + include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 2 ++ mm/oom_kill.c | 6 ++++++ mm/vmstat.c | 1 + 6 files changed, 22 insertions(+), 1 deletion(-)Documentation/cgroup-v2.txt +11
-1@@ -830,9 +830,19 @@ PAGE_SIZE multiple when read back. oom + The number of time the cgroup's memory usage was + reached the limit and allocation was about to fail. + Result could be oom kill, -ENOMEM from any syscall or + completely ignored in cases like disk readahead. + For now oom in memory cgroup kills tasks iff shortage + has happened inside page fault. + + oom_kill + The number of times the OOM killer has been invoked in the cgroup. This may not exactly match the number of - processes killed but should generally be close. + processes killed but should generally be close: each + invocation could kill several processes at once. memory.statinclude/linux/memcontrol.h +1
-0@@ -55,6 +55,7 @@ enum memcg_event_item {MEMCG_HIGH ,MEMCG_MAX ,MEMCG_OOM , +MEMCG_OOM_KILL , MEMCG_NR_EVENTS, };include/linux/vm_event_item.h +1
-0@@ -41,6 +41,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,KSWAPD_LOW_WMARK_HIT_QUICKLY ,KSWAPD_HIGH_WMARK_HIT_QUICKLY ,PAGEOUTRUN ,PGROTATED ,DROP_PAGECACHE ,DROP_SLAB , +OOM_KILL , #ifdef CONFIG_NUMA_BALANCINGNUMA_PTE_UPDATES , NUMA_HUGE_PTE_UPDATES,mm/memcontrol.c +2
-0@@ -3574,6 +3574,7 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)seq_printf (sf,"oom_kill_disable %d\n" , memcg->oom_kill_disable);seq_printf (sf,"under_oom %d\n" , (bool )memcg->under_oom); +seq_printf (sf,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }@@ -5165,6 +5166,7 @@ static int memory_events_show(struct seq_file *m, void *v)seq_printf (m,"high %lu\n" ,memcg_sum_events (memcg,MEMCG_HIGH ));seq_printf (m,"max %lu\n" ,memcg_sum_events (memcg,MEMCG_MAX ));seq_printf (m,"oom %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM )); +seq_printf (m,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }mm/oom_kill.c +6
-0@@ -873,6 +873,12 @@ static void oom_kill_process(struct oom_control *oc, const char *message) victim = p; } +/* Raise event before sending signal: reaper must see this */ +if (!is_memcg_oom (oc)) +count_vm_event (OOM_KILL ); +else +mem_cgroup_event (oc->memcg,MEMCG_OOM_KILL ); +/* Get a reference to safely compare mm after task_unlock(victim) */ mm = victim->mm;mmgrab (mm);mm/vmstat.c +1
-1@@ -1018,6 +1018,7 @@ const char * const vmstat_text[] = {"drop_pagecache" ,"drop_slab" , +"oom_kill" , #ifdef CONFIG_NUMA_BALANCING "numa_pte_updates", --To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Michal Hocko
Quoted 8 lines · Konstantin Khlebnikov
Show count of global oom killer invocations in
/proc/vmstatand count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).Also describe difference between "oom" and "
oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.
Quoted 8 lines
Quoted 2 lines
These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
Have you considered adding memcg's oom alternative for the global case as well. It would be useful to see how many times we hit the OOM condition without killing anything. That could help debugging issues when the OOM killer cannot be invoked (e.g. GFP_NO{FS,IO} contextx) and the system cannot get out of the oom situation.
I think present warn_alloc() should be enough for debugging,
maybe it should taint kernel in some cases to give a hint for future warnings/bugs.
Quoted 110 lines
Quoted 2 lines
Signed-off-by Konstantin Khlebnikov <[email protected]>Acked-by Michal Hocko <[email protected]>Quoted 105 lines
--- Documentation/cgroup-v2.txt | 12 +++++++++++- include/linux/memcontrol.h | 1 + include/linux/vm_event_item.h | 1 + mm/memcontrol.c | 2 ++ mm/oom_kill.c | 6 ++++++ mm/vmstat.c | 1 + 6 files changed, 22 insertions(+), 1 deletion(-)Documentation/cgroup-v2.txt +11
-1@@ -830,9 +830,19 @@ PAGE_SIZE multiple when read back. oom + The number of time the cgroup's memory usage was + reached the limit and allocation was about to fail. + Result could be oom kill, -ENOMEM from any syscall or + completely ignored in cases like disk readahead. + For now oom in memory cgroup kills tasks iff shortage + has happened inside page fault. + + oom_kill + The number of times the OOM killer has been invoked in the cgroup. This may not exactly match the number of - processes killed but should generally be close. + processes killed but should generally be close: each + invocation could kill several processes at once. memory.statinclude/linux/memcontrol.h +1
-0@@ -55,6 +55,7 @@ enum memcg_event_item {MEMCG_HIGH ,MEMCG_MAX ,MEMCG_OOM , +MEMCG_OOM_KILL , MEMCG_NR_EVENTS, };include/linux/vm_event_item.h +1
-0@@ -41,6 +41,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,KSWAPD_LOW_WMARK_HIT_QUICKLY ,KSWAPD_HIGH_WMARK_HIT_QUICKLY ,PAGEOUTRUN ,PGROTATED ,DROP_PAGECACHE ,DROP_SLAB , +OOM_KILL , #ifdef CONFIG_NUMA_BALANCINGNUMA_PTE_UPDATES , NUMA_HUGE_PTE_UPDATES,mm/memcontrol.c +2
-0@@ -3574,6 +3574,7 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)seq_printf (sf,"oom_kill_disable %d\n" , memcg->oom_kill_disable);seq_printf (sf,"under_oom %d\n" , (bool )memcg->under_oom); +seq_printf (sf,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }@@ -5165,6 +5166,7 @@ static int memory_events_show(struct seq_file *m, void *v)seq_printf (m,"high %lu\n" ,memcg_sum_events (memcg,MEMCG_HIGH ));seq_printf (m,"max %lu\n" ,memcg_sum_events (memcg,MEMCG_MAX ));seq_printf (m,"oom %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM )); +seq_printf (m,"oom_kill %lu\n" ,memcg_sum_events (memcg,MEMCG_OOM_KILL ));return 0 ; }mm/oom_kill.c +6
-0@@ -873,6 +873,12 @@ static void oom_kill_process(struct oom_control *oc, const char *message) victim = p; } +/* Raise event before sending signal: reaper must see this */ +if (!is_memcg_oom (oc)) +count_vm_event (OOM_KILL ); +else +mem_cgroup_event (oc->memcg,MEMCG_OOM_KILL ); +/* Get a reference to safely compare mm after task_unlock(victim) */ mm = victim->mm;mmgrab (mm);mm/vmstat.c +1
-0@@ -1018,6 +1018,7 @@ const char * const vmstat_text[] = {"drop_pagecache" ,"drop_slab" , + "oom_kill",
Quoted 9 lines
Quoted 8 lines
mm/vmstat.c +0
-1#ifdef CONFIG_NUMA_BALANCING "numa_pte_updates", --To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · Konstantin Khlebnikov
Quoted 12 lines · Michal Hocko
Quoted 10 lines · Konstantin Khlebnikov
Show count of global oom killer invocations in
/proc/vmstatand count of oom kills inside memory cgroup in knob "memory.events" (in memory.oom_control for v1 cgroup).Also describe difference between "oom" and "
oom_kill" in memory cgroup documentation. Currently oom in memory cgroup kills tasks iff shortage has happened inside page fault.These counters helps in monitoring oom kills - for now the only way is grepping for magic words in kernel log.
Quoted 9 lines
Quoted 5 lines
Have you considered adding memcg's oom alternative for the global case as well. It would be useful to see how many times we hit the OOM condition without killing anything. That could help debugging issues when the OOM killer cannot be invoked (e.g. GFP_NO{FS,IO} contextx) and the system cannot get out of the oom situation.
I think present
warn_alloc()should be enough for debugging,
maybe it should taint kernel in some cases to give a hint for future warnings/bugs.
I don't think warn_alloc() is enough. We can fail to warn using warn_alloc(), see
http://lkml.kernel.org/r/1495331504-12480-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp .
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>