diff options
Diffstat (limited to 'include/linux/memcontrol.h')
-rw-r--r-- | include/linux/memcontrol.h | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index a805474df4ab..56e6069d2452 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -97,6 +97,11 @@ enum mem_cgroup_events_target { | |||
97 | #define MEM_CGROUP_ID_SHIFT 16 | 97 | #define MEM_CGROUP_ID_SHIFT 16 |
98 | #define MEM_CGROUP_ID_MAX USHRT_MAX | 98 | #define MEM_CGROUP_ID_MAX USHRT_MAX |
99 | 99 | ||
100 | struct mem_cgroup_id { | ||
101 | int id; | ||
102 | atomic_t ref; | ||
103 | }; | ||
104 | |||
100 | struct mem_cgroup_stat_cpu { | 105 | struct mem_cgroup_stat_cpu { |
101 | long count[MEMCG_NR_STAT]; | 106 | long count[MEMCG_NR_STAT]; |
102 | unsigned long events[MEMCG_NR_EVENTS]; | 107 | unsigned long events[MEMCG_NR_EVENTS]; |
@@ -172,6 +177,9 @@ enum memcg_kmem_state { | |||
172 | struct mem_cgroup { | 177 | struct mem_cgroup { |
173 | struct cgroup_subsys_state css; | 178 | struct cgroup_subsys_state css; |
174 | 179 | ||
180 | /* Private memcg ID. Used to ID objects that outlive the cgroup */ | ||
181 | struct mem_cgroup_id id; | ||
182 | |||
175 | /* Accounted resources */ | 183 | /* Accounted resources */ |
176 | struct page_counter memory; | 184 | struct page_counter memory; |
177 | struct page_counter swap; | 185 | struct page_counter swap; |
@@ -330,22 +338,9 @@ static inline unsigned short mem_cgroup_id(struct mem_cgroup *memcg) | |||
330 | if (mem_cgroup_disabled()) | 338 | if (mem_cgroup_disabled()) |
331 | return 0; | 339 | return 0; |
332 | 340 | ||
333 | return memcg->css.id; | 341 | return memcg->id.id; |
334 | } | ||
335 | |||
336 | /** | ||
337 | * mem_cgroup_from_id - look up a memcg from an id | ||
338 | * @id: the id to look up | ||
339 | * | ||
340 | * Caller must hold rcu_read_lock() and use css_tryget() as necessary. | ||
341 | */ | ||
342 | static inline struct mem_cgroup *mem_cgroup_from_id(unsigned short id) | ||
343 | { | ||
344 | struct cgroup_subsys_state *css; | ||
345 | |||
346 | css = css_from_id(id, &memory_cgrp_subsys); | ||
347 | return mem_cgroup_from_css(css); | ||
348 | } | 342 | } |
343 | struct mem_cgroup *mem_cgroup_from_id(unsigned short id); | ||
349 | 344 | ||
350 | /** | 345 | /** |
351 | * parent_mem_cgroup - find the accounting parent of a memcg | 346 | * parent_mem_cgroup - find the accounting parent of a memcg |