aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2009-09-21 20:01:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-22 10:17:27 -0400
commitc6a7f5728a1db45d30df55a01adc130b4ab0327c (patch)
tree36649bc6ebb959841a5097c699968722cfd99c4d /kernel/fork.c
parent71de1ccbe1fb40203edd3beb473f8580d917d2ca (diff)
mm: oom analysis: Show kernel stack usage in /proc/meminfo and OOM log output
The amount of memory allocated to kernel stacks can become significant and cause OOM conditions. However, we do not display the amount of memory consumed by stacks. Add code to display the amount of memory used for stacks in /proc/meminfo. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reviewed-by: Christoph Lameter <cl@linux-foundation.org> Reviewed-by: Minchan Kim <minchan.kim@gmail.com> Reviewed-by: Rik van Riel <riel@redhat.com> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 2cebfb23b0b8..d4638c8cc19e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -136,9 +136,17 @@ struct kmem_cache *vm_area_cachep;
136/* SLAB cache for mm_struct structures (tsk->mm) */ 136/* SLAB cache for mm_struct structures (tsk->mm) */
137static struct kmem_cache *mm_cachep; 137static struct kmem_cache *mm_cachep;
138 138
139static void account_kernel_stack(struct thread_info *ti, int account)
140{
141 struct zone *zone = page_zone(virt_to_page(ti));
142
143 mod_zone_page_state(zone, NR_KERNEL_STACK, account);
144}
145
139void free_task(struct task_struct *tsk) 146void free_task(struct task_struct *tsk)
140{ 147{
141 prop_local_destroy_single(&tsk->dirties); 148 prop_local_destroy_single(&tsk->dirties);
149 account_kernel_stack(tsk->stack, -1);
142 free_thread_info(tsk->stack); 150 free_thread_info(tsk->stack);
143 rt_mutex_debug_task_free(tsk); 151 rt_mutex_debug_task_free(tsk);
144 ftrace_graph_exit_task(tsk); 152 ftrace_graph_exit_task(tsk);
@@ -253,6 +261,9 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
253 tsk->btrace_seq = 0; 261 tsk->btrace_seq = 0;
254#endif 262#endif
255 tsk->splice_pipe = NULL; 263 tsk->splice_pipe = NULL;
264
265 account_kernel_stack(ti, 1);
266
256 return tsk; 267 return tsk;
257 268
258out: 269out: