mm: memcontrol: report kernel stack usage in cgroup2 memory.stat
[linux-2.6-block.git] / kernel / fork.c
index 2e391c754ae730bd2d8520c2ab497c403220c6e3..accb7221d54751ecbd8f440e89066116c3ae8586 100644 (file)
@@ -164,12 +164,20 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
        struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP,
                                                  THREAD_SIZE_ORDER);
 
+       if (page)
+               memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
+                                           1 << THREAD_SIZE_ORDER);
+
        return page ? page_address(page) : NULL;
 }
 
 static inline void free_thread_info(struct thread_info *ti)
 {
-       free_kmem_pages((unsigned long)ti, THREAD_SIZE_ORDER);
+       struct page *page = virt_to_page(ti);
+
+       memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
+                                   -(1 << THREAD_SIZE_ORDER));
+       __free_kmem_pages(page, THREAD_SIZE_ORDER);
 }
 # else
 static struct kmem_cache *thread_info_cache;