diff options
Diffstat (limited to 'include/linux/memcontrol.h')
-rw-r--r-- | include/linux/memcontrol.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index a355f61a2ed3..c5a51039df57 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -249,6 +249,10 @@ struct mem_cgroup { | |||
249 | struct wb_domain cgwb_domain; | 249 | struct wb_domain cgwb_domain; |
250 | #endif | 250 | #endif |
251 | 251 | ||
252 | #ifdef CONFIG_INET | ||
253 | unsigned long socket_pressure; | ||
254 | #endif | ||
255 | |||
252 | /* List of events which userspace want to receive */ | 256 | /* List of events which userspace want to receive */ |
253 | struct list_head event_list; | 257 | struct list_head event_list; |
254 | spinlock_t event_list_lock; | 258 | spinlock_t event_list_lock; |
@@ -290,18 +294,34 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *, struct zone *); | |||
290 | 294 | ||
291 | bool task_in_mem_cgroup(struct task_struct *task, struct mem_cgroup *memcg); | 295 | bool task_in_mem_cgroup(struct task_struct *task, struct mem_cgroup *memcg); |
292 | struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); | 296 | struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); |
293 | struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg); | ||
294 | 297 | ||
295 | static inline | 298 | static inline |
296 | struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){ | 299 | struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){ |
297 | return css ? container_of(css, struct mem_cgroup, css) : NULL; | 300 | return css ? container_of(css, struct mem_cgroup, css) : NULL; |
298 | } | 301 | } |
299 | 302 | ||
303 | #define mem_cgroup_from_counter(counter, member) \ | ||
304 | container_of(counter, struct mem_cgroup, member) | ||
305 | |||
300 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, | 306 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, |
301 | struct mem_cgroup *, | 307 | struct mem_cgroup *, |
302 | struct mem_cgroup_reclaim_cookie *); | 308 | struct mem_cgroup_reclaim_cookie *); |
303 | void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *); | 309 | void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *); |
304 | 310 | ||
311 | /** | ||
312 | * parent_mem_cgroup - find the accounting parent of a memcg | ||
313 | * @memcg: memcg whose parent to find | ||
314 | * | ||
315 | * Returns the parent memcg, or NULL if this is the root or the memory | ||
316 | * controller is in legacy no-hierarchy mode. | ||
317 | */ | ||
318 | static inline struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg) | ||
319 | { | ||
320 | if (!memcg->memory.parent) | ||
321 | return NULL; | ||
322 | return mem_cgroup_from_counter(memcg->memory.parent, memory); | ||
323 | } | ||
324 | |||
305 | static inline bool mem_cgroup_is_descendant(struct mem_cgroup *memcg, | 325 | static inline bool mem_cgroup_is_descendant(struct mem_cgroup *memcg, |
306 | struct mem_cgroup *root) | 326 | struct mem_cgroup *root) |
307 | { | 327 | { |
@@ -689,10 +709,14 @@ extern struct static_key memcg_sockets_enabled_key; | |||
689 | static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) | 709 | static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) |
690 | { | 710 | { |
691 | #ifdef CONFIG_MEMCG_KMEM | 711 | #ifdef CONFIG_MEMCG_KMEM |
692 | return memcg->tcp_mem.memory_pressure; | 712 | if (memcg->tcp_mem.memory_pressure) |
693 | #else | 713 | return true; |
694 | return false; | ||
695 | #endif | 714 | #endif |
715 | do { | ||
716 | if (time_before(jiffies, memcg->socket_pressure)) | ||
717 | return true; | ||
718 | } while ((memcg = parent_mem_cgroup(memcg))); | ||
719 | return false; | ||
696 | } | 720 | } |
697 | #else | 721 | #else |
698 | #define mem_cgroup_sockets_enabled 0 | 722 | #define mem_cgroup_sockets_enabled 0 |