aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/memcontrol.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/memcontrol.h')
-rw-r--r--include/linux/memcontrol.h105
1 files changed, 94 insertions, 11 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 6c6fb116e925..652f602167df 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -112,6 +112,15 @@ struct lruvec_stat {
112}; 112};
113 113
114/* 114/*
115 * Bitmap of shrinker::id corresponding to memcg-aware shrinkers,
116 * which have elements charged to this memcg.
117 */
118struct memcg_shrinker_map {
119 struct rcu_head rcu;
120 unsigned long map[0];
121};
122
123/*
115 * per-zone information in memory controller. 124 * per-zone information in memory controller.
116 */ 125 */
117struct mem_cgroup_per_node { 126struct mem_cgroup_per_node {
@@ -124,6 +133,9 @@ struct mem_cgroup_per_node {
124 133
125 struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1]; 134 struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1];
126 135
136#ifdef CONFIG_MEMCG_KMEM
137 struct memcg_shrinker_map __rcu *shrinker_map;
138#endif
127 struct rb_node tree_node; /* RB tree node */ 139 struct rb_node tree_node; /* RB tree node */
128 unsigned long usage_in_excess;/* Set to the value by which */ 140 unsigned long usage_in_excess;/* Set to the value by which */
129 /* the soft limit is exceeded*/ 141 /* the soft limit is exceeded*/
@@ -213,6 +225,11 @@ struct mem_cgroup {
213 */ 225 */
214 bool use_hierarchy; 226 bool use_hierarchy;
215 227
228 /*
229 * Should the OOM killer kill all belonging tasks, had it kill one?
230 */
231 bool oom_group;
232
216 /* protected by memcg_oom_lock */ 233 /* protected by memcg_oom_lock */
217 bool oom_lock; 234 bool oom_lock;
218 int under_oom; 235 int under_oom;
@@ -271,7 +288,7 @@ struct mem_cgroup {
271 bool tcpmem_active; 288 bool tcpmem_active;
272 int tcpmem_pressure; 289 int tcpmem_pressure;
273 290
274#ifndef CONFIG_SLOB 291#ifdef CONFIG_MEMCG_KMEM
275 /* Index in the kmem_cache->memcg_params.memcg_caches array */ 292 /* Index in the kmem_cache->memcg_params.memcg_caches array */
276 int kmemcg_id; 293 int kmemcg_id;
277 enum memcg_kmem_state kmem_state; 294 enum memcg_kmem_state kmem_state;
@@ -306,6 +323,11 @@ struct mem_cgroup {
306 323
307extern struct mem_cgroup *root_mem_cgroup; 324extern struct mem_cgroup *root_mem_cgroup;
308 325
326static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)
327{
328 return (memcg == root_mem_cgroup);
329}
330
309static inline bool mem_cgroup_disabled(void) 331static inline bool mem_cgroup_disabled(void)
310{ 332{
311 return !cgroup_subsys_enabled(memory_cgrp_subsys); 333 return !cgroup_subsys_enabled(memory_cgrp_subsys);
@@ -317,6 +339,9 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
317int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, 339int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
318 gfp_t gfp_mask, struct mem_cgroup **memcgp, 340 gfp_t gfp_mask, struct mem_cgroup **memcgp,
319 bool compound); 341 bool compound);
342int mem_cgroup_try_charge_delay(struct page *page, struct mm_struct *mm,
343 gfp_t gfp_mask, struct mem_cgroup **memcgp,
344 bool compound);
320void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg, 345void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg,
321 bool lrucare, bool compound); 346 bool lrucare, bool compound);
322void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg, 347void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg,
@@ -370,11 +395,21 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *, struct pglist_data *);
370bool task_in_mem_cgroup(struct task_struct *task, struct mem_cgroup *memcg); 395bool task_in_mem_cgroup(struct task_struct *task, struct mem_cgroup *memcg);
371struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); 396struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
372 397
398struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm);
399
400struct mem_cgroup *get_mem_cgroup_from_page(struct page *page);
401
373static inline 402static inline
374struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){ 403struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){
375 return css ? container_of(css, struct mem_cgroup, css) : NULL; 404 return css ? container_of(css, struct mem_cgroup, css) : NULL;
376} 405}
377 406
407static inline void mem_cgroup_put(struct mem_cgroup *memcg)
408{
409 if (memcg)
410 css_put(&memcg->css);
411}
412
378#define mem_cgroup_from_counter(counter, member) \ 413#define mem_cgroup_from_counter(counter, member) \
379 container_of(counter, struct mem_cgroup, member) 414 container_of(counter, struct mem_cgroup, member)
380 415
@@ -494,16 +529,16 @@ unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg);
494void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, 529void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
495 struct task_struct *p); 530 struct task_struct *p);
496 531
497static inline void mem_cgroup_oom_enable(void) 532static inline void mem_cgroup_enter_user_fault(void)
498{ 533{
499 WARN_ON(current->memcg_may_oom); 534 WARN_ON(current->in_user_fault);
500 current->memcg_may_oom = 1; 535 current->in_user_fault = 1;
501} 536}
502 537
503static inline void mem_cgroup_oom_disable(void) 538static inline void mem_cgroup_exit_user_fault(void)
504{ 539{
505 WARN_ON(!current->memcg_may_oom); 540 WARN_ON(!current->in_user_fault);
506 current->memcg_may_oom = 0; 541 current->in_user_fault = 0;
507} 542}
508 543
509static inline bool task_in_memcg_oom(struct task_struct *p) 544static inline bool task_in_memcg_oom(struct task_struct *p)
@@ -512,6 +547,9 @@ static inline bool task_in_memcg_oom(struct task_struct *p)
512} 547}
513 548
514bool mem_cgroup_oom_synchronize(bool wait); 549bool mem_cgroup_oom_synchronize(bool wait);
550struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim,
551 struct mem_cgroup *oom_domain);
552void mem_cgroup_print_oom_group(struct mem_cgroup *memcg);
515 553
516#ifdef CONFIG_MEMCG_SWAP 554#ifdef CONFIG_MEMCG_SWAP
517extern int do_swap_account; 555extern int do_swap_account;
@@ -759,6 +797,11 @@ void mem_cgroup_split_huge_fixup(struct page *head);
759 797
760struct mem_cgroup; 798struct mem_cgroup;
761 799
800static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg)
801{
802 return true;
803}
804
762static inline bool mem_cgroup_disabled(void) 805static inline bool mem_cgroup_disabled(void)
763{ 806{
764 return true; 807 return true;
@@ -789,6 +832,16 @@ static inline int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
789 return 0; 832 return 0;
790} 833}
791 834
835static inline int mem_cgroup_try_charge_delay(struct page *page,
836 struct mm_struct *mm,
837 gfp_t gfp_mask,
838 struct mem_cgroup **memcgp,
839 bool compound)
840{
841 *memcgp = NULL;
842 return 0;
843}
844
792static inline void mem_cgroup_commit_charge(struct page *page, 845static inline void mem_cgroup_commit_charge(struct page *page,
793 struct mem_cgroup *memcg, 846 struct mem_cgroup *memcg,
794 bool lrucare, bool compound) 847 bool lrucare, bool compound)
@@ -837,6 +890,20 @@ static inline bool task_in_mem_cgroup(struct task_struct *task,
837 return true; 890 return true;
838} 891}
839 892
893static inline struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
894{
895 return NULL;
896}
897
898static inline struct mem_cgroup *get_mem_cgroup_from_page(struct page *page)
899{
900 return NULL;
901}
902
903static inline void mem_cgroup_put(struct mem_cgroup *memcg)
904{
905}
906
840static inline struct mem_cgroup * 907static inline struct mem_cgroup *
841mem_cgroup_iter(struct mem_cgroup *root, 908mem_cgroup_iter(struct mem_cgroup *root,
842 struct mem_cgroup *prev, 909 struct mem_cgroup *prev,
@@ -924,11 +991,11 @@ static inline void mem_cgroup_handle_over_high(void)
924{ 991{
925} 992}
926 993
927static inline void mem_cgroup_oom_enable(void) 994static inline void mem_cgroup_enter_user_fault(void)
928{ 995{
929} 996}
930 997
931static inline void mem_cgroup_oom_disable(void) 998static inline void mem_cgroup_exit_user_fault(void)
932{ 999{
933} 1000}
934 1001
@@ -942,6 +1009,16 @@ static inline bool mem_cgroup_oom_synchronize(bool wait)
942 return false; 1009 return false;
943} 1010}
944 1011
1012static inline struct mem_cgroup *mem_cgroup_get_oom_group(
1013 struct task_struct *victim, struct mem_cgroup *oom_domain)
1014{
1015 return NULL;
1016}
1017
1018static inline void mem_cgroup_print_oom_group(struct mem_cgroup *memcg)
1019{
1020}
1021
945static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, 1022static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
946 int idx) 1023 int idx)
947{ 1024{
@@ -1194,7 +1271,7 @@ int memcg_kmem_charge_memcg(struct page *page, gfp_t gfp, int order,
1194int memcg_kmem_charge(struct page *page, gfp_t gfp, int order); 1271int memcg_kmem_charge(struct page *page, gfp_t gfp, int order);
1195void memcg_kmem_uncharge(struct page *page, int order); 1272void memcg_kmem_uncharge(struct page *page, int order);
1196 1273
1197#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) 1274#ifdef CONFIG_MEMCG_KMEM
1198extern struct static_key_false memcg_kmem_enabled_key; 1275extern struct static_key_false memcg_kmem_enabled_key;
1199extern struct workqueue_struct *memcg_kmem_cache_wq; 1276extern struct workqueue_struct *memcg_kmem_cache_wq;
1200 1277
@@ -1225,6 +1302,10 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg)
1225 return memcg ? memcg->kmemcg_id : -1; 1302 return memcg ? memcg->kmemcg_id : -1;
1226} 1303}
1227 1304
1305extern int memcg_expand_shrinker_maps(int new_id);
1306
1307extern void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
1308 int nid, int shrinker_id);
1228#else 1309#else
1229#define for_each_memcg_cache_index(_idx) \ 1310#define for_each_memcg_cache_index(_idx) \
1230 for (; NULL; ) 1311 for (; NULL; )
@@ -1247,6 +1328,8 @@ static inline void memcg_put_cache_ids(void)
1247{ 1328{
1248} 1329}
1249 1330
1250#endif /* CONFIG_MEMCG && !CONFIG_SLOB */ 1331static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg,
1332 int nid, int shrinker_id) { }
1333#endif /* CONFIG_MEMCG_KMEM */
1251 1334
1252#endif /* _LINUX_MEMCONTROL_H */ 1335#endif /* _LINUX_MEMCONTROL_H */