diff options
-rw-r--r-- | Documentation/cgroup-v2.txt | 4 | ||||
-rw-r--r-- | include/linux/memcontrol.h | 3 | ||||
-rw-r--r-- | kernel/fork.c | 10 | ||||
-rw-r--r-- | mm/memcontrol.c | 2 |
4 files changed, 17 insertions, 2 deletions
diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index e4e0c1d78cee..e2f4e7948a66 100644 --- a/Documentation/cgroup-v2.txt +++ b/Documentation/cgroup-v2.txt | |||
@@ -843,6 +843,10 @@ PAGE_SIZE multiple when read back. | |||
843 | Amount of memory used to cache filesystem data, | 843 | Amount of memory used to cache filesystem data, |
844 | including tmpfs and shared memory. | 844 | including tmpfs and shared memory. |
845 | 845 | ||
846 | kernel_stack | ||
847 | |||
848 | Amount of memory allocated to kernel stacks. | ||
849 | |||
846 | slab | 850 | slab |
847 | 851 | ||
848 | Amount of memory used for storing in-kernel data | 852 | Amount of memory used for storing in-kernel data |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index e7af4834ffea..d6300313b298 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -52,9 +52,10 @@ enum mem_cgroup_stat_index { | |||
52 | MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */ | 52 | MEM_CGROUP_STAT_SWAP, /* # of pages, swapped out */ |
53 | MEM_CGROUP_STAT_NSTATS, | 53 | MEM_CGROUP_STAT_NSTATS, |
54 | /* default hierarchy stats */ | 54 | /* default hierarchy stats */ |
55 | MEMCG_SOCK = MEM_CGROUP_STAT_NSTATS, | 55 | MEMCG_KERNEL_STACK = MEM_CGROUP_STAT_NSTATS, |
56 | MEMCG_SLAB_RECLAIMABLE, | 56 | MEMCG_SLAB_RECLAIMABLE, |
57 | MEMCG_SLAB_UNRECLAIMABLE, | 57 | MEMCG_SLAB_UNRECLAIMABLE, |
58 | MEMCG_SOCK, | ||
58 | MEMCG_NR_STAT, | 59 | MEMCG_NR_STAT, |
59 | }; | 60 | }; |
60 | 61 | ||
diff --git a/kernel/fork.c b/kernel/fork.c index 2e391c754ae7..accb7221d547 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -164,12 +164,20 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, | |||
164 | struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP, | 164 | struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP, |
165 | THREAD_SIZE_ORDER); | 165 | THREAD_SIZE_ORDER); |
166 | 166 | ||
167 | if (page) | ||
168 | memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK, | ||
169 | 1 << THREAD_SIZE_ORDER); | ||
170 | |||
167 | return page ? page_address(page) : NULL; | 171 | return page ? page_address(page) : NULL; |
168 | } | 172 | } |
169 | 173 | ||
170 | static inline void free_thread_info(struct thread_info *ti) | 174 | static inline void free_thread_info(struct thread_info *ti) |
171 | { | 175 | { |
172 | free_kmem_pages((unsigned long)ti, THREAD_SIZE_ORDER); | 176 | struct page *page = virt_to_page(ti); |
177 | |||
178 | memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK, | ||
179 | -(1 << THREAD_SIZE_ORDER)); | ||
180 | __free_kmem_pages(page, THREAD_SIZE_ORDER); | ||
173 | } | 181 | } |
174 | # else | 182 | # else |
175 | static struct kmem_cache *thread_info_cache; | 183 | static struct kmem_cache *thread_info_cache; |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3ad64bf464fd..4b7dda7c2e74 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -5106,6 +5106,8 @@ static int memory_stat_show(struct seq_file *m, void *v) | |||
5106 | (u64)stat[MEM_CGROUP_STAT_RSS] * PAGE_SIZE); | 5106 | (u64)stat[MEM_CGROUP_STAT_RSS] * PAGE_SIZE); |
5107 | seq_printf(m, "file %llu\n", | 5107 | seq_printf(m, "file %llu\n", |
5108 | (u64)stat[MEM_CGROUP_STAT_CACHE] * PAGE_SIZE); | 5108 | (u64)stat[MEM_CGROUP_STAT_CACHE] * PAGE_SIZE); |
5109 | seq_printf(m, "kernel_stack %llu\n", | ||
5110 | (u64)stat[MEMCG_KERNEL_STACK] * PAGE_SIZE); | ||
5109 | seq_printf(m, "slab %llu\n", | 5111 | seq_printf(m, "slab %llu\n", |
5110 | (u64)(stat[MEMCG_SLAB_RECLAIMABLE] + | 5112 | (u64)(stat[MEMCG_SLAB_RECLAIMABLE] + |
5111 | stat[MEMCG_SLAB_UNRECLAIMABLE]) * PAGE_SIZE); | 5113 | stat[MEMCG_SLAB_UNRECLAIMABLE]) * PAGE_SIZE); |