diff options
| author | Tony Lindgren <tony@atomide.com> | 2018-08-28 12:58:03 -0400 |
|---|---|---|
| committer | Tony Lindgren <tony@atomide.com> | 2018-08-28 12:58:03 -0400 |
| commit | ea4d65f14f6aaa53e379b93c5544245ef081b3e7 (patch) | |
| tree | a15485f4f1cf547a52b31fa8e16e14b9579b7200 /include/linux/memcontrol.h | |
| parent | ce32d59ee2cd036f6e8a6ed17a06a0b0bec5c67c (diff) | |
| parent | 496f3347d834aec91c38b45d6249ed00f58ad233 (diff) | |
Merge branch 'perm-fix' into omap-for-v4.19/fixes-v2
Diffstat (limited to 'include/linux/memcontrol.h')
| -rw-r--r-- | include/linux/memcontrol.h | 105 |
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 | */ | ||
| 118 | struct 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 | */ |
| 117 | struct mem_cgroup_per_node { | 126 | struct 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 | ||
| 307 | extern struct mem_cgroup *root_mem_cgroup; | 324 | extern struct mem_cgroup *root_mem_cgroup; |
| 308 | 325 | ||
| 326 | static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) | ||
| 327 | { | ||
| 328 | return (memcg == root_mem_cgroup); | ||
| 329 | } | ||
| 330 | |||
| 309 | static inline bool mem_cgroup_disabled(void) | 331 | static 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, | |||
| 317 | int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm, | 339 | int 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); |
| 342 | int mem_cgroup_try_charge_delay(struct page *page, struct mm_struct *mm, | ||
| 343 | gfp_t gfp_mask, struct mem_cgroup **memcgp, | ||
| 344 | bool compound); | ||
| 320 | void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg, | 345 | void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg, |
| 321 | bool lrucare, bool compound); | 346 | bool lrucare, bool compound); |
| 322 | void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg, | 347 | void 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 *); | |||
| 370 | bool task_in_mem_cgroup(struct task_struct *task, struct mem_cgroup *memcg); | 395 | bool task_in_mem_cgroup(struct task_struct *task, struct mem_cgroup *memcg); |
| 371 | struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); | 396 | struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); |
| 372 | 397 | ||
| 398 | struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm); | ||
| 399 | |||
| 400 | struct mem_cgroup *get_mem_cgroup_from_page(struct page *page); | ||
| 401 | |||
| 373 | static inline | 402 | static inline |
| 374 | struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){ | 403 | struct 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 | ||
| 407 | static 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); | |||
| 494 | void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, | 529 | void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, |
| 495 | struct task_struct *p); | 530 | struct task_struct *p); |
| 496 | 531 | ||
| 497 | static inline void mem_cgroup_oom_enable(void) | 532 | static 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 | ||
| 503 | static inline void mem_cgroup_oom_disable(void) | 538 | static 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 | ||
| 509 | static inline bool task_in_memcg_oom(struct task_struct *p) | 544 | static 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 | ||
| 514 | bool mem_cgroup_oom_synchronize(bool wait); | 549 | bool mem_cgroup_oom_synchronize(bool wait); |
| 550 | struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, | ||
| 551 | struct mem_cgroup *oom_domain); | ||
| 552 | void mem_cgroup_print_oom_group(struct mem_cgroup *memcg); | ||
| 515 | 553 | ||
| 516 | #ifdef CONFIG_MEMCG_SWAP | 554 | #ifdef CONFIG_MEMCG_SWAP |
| 517 | extern int do_swap_account; | 555 | extern int do_swap_account; |
| @@ -759,6 +797,11 @@ void mem_cgroup_split_huge_fixup(struct page *head); | |||
| 759 | 797 | ||
| 760 | struct mem_cgroup; | 798 | struct mem_cgroup; |
| 761 | 799 | ||
| 800 | static inline bool mem_cgroup_is_root(struct mem_cgroup *memcg) | ||
| 801 | { | ||
| 802 | return true; | ||
| 803 | } | ||
| 804 | |||
| 762 | static inline bool mem_cgroup_disabled(void) | 805 | static 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 | ||
| 835 | static 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 | |||
| 792 | static inline void mem_cgroup_commit_charge(struct page *page, | 845 | static 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 | ||
| 893 | static inline struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm) | ||
| 894 | { | ||
| 895 | return NULL; | ||
| 896 | } | ||
| 897 | |||
| 898 | static inline struct mem_cgroup *get_mem_cgroup_from_page(struct page *page) | ||
| 899 | { | ||
| 900 | return NULL; | ||
| 901 | } | ||
| 902 | |||
| 903 | static inline void mem_cgroup_put(struct mem_cgroup *memcg) | ||
| 904 | { | ||
| 905 | } | ||
| 906 | |||
| 840 | static inline struct mem_cgroup * | 907 | static inline struct mem_cgroup * |
| 841 | mem_cgroup_iter(struct mem_cgroup *root, | 908 | mem_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 | ||
| 927 | static inline void mem_cgroup_oom_enable(void) | 994 | static inline void mem_cgroup_enter_user_fault(void) |
| 928 | { | 995 | { |
| 929 | } | 996 | } |
| 930 | 997 | ||
| 931 | static inline void mem_cgroup_oom_disable(void) | 998 | static 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 | ||
| 1012 | static 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 | |||
| 1018 | static inline void mem_cgroup_print_oom_group(struct mem_cgroup *memcg) | ||
| 1019 | { | ||
| 1020 | } | ||
| 1021 | |||
| 945 | static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, | 1022 | static 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, | |||
| 1194 | int memcg_kmem_charge(struct page *page, gfp_t gfp, int order); | 1271 | int memcg_kmem_charge(struct page *page, gfp_t gfp, int order); |
| 1195 | void memcg_kmem_uncharge(struct page *page, int order); | 1272 | void memcg_kmem_uncharge(struct page *page, int order); |
| 1196 | 1273 | ||
| 1197 | #if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) | 1274 | #ifdef CONFIG_MEMCG_KMEM |
| 1198 | extern struct static_key_false memcg_kmem_enabled_key; | 1275 | extern struct static_key_false memcg_kmem_enabled_key; |
| 1199 | extern struct workqueue_struct *memcg_kmem_cache_wq; | 1276 | extern 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 | ||
| 1305 | extern int memcg_expand_shrinker_maps(int new_id); | ||
| 1306 | |||
| 1307 | extern 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 */ | 1331 | static 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 */ |
