aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/memcontrol.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 216659d4441a..706f7bc16db2 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -382,15 +382,10 @@ struct mem_cgroup {
382 382
383/* internal only representation about the status of kmem accounting. */ 383/* internal only representation about the status of kmem accounting. */
384enum { 384enum {
385 KMEM_ACCOUNTED_ACTIVE = 0, /* accounted by this cgroup itself */ 385 KMEM_ACCOUNTED_ACTIVE, /* accounted by this cgroup itself */
386 KMEM_ACCOUNTED_ACTIVATED, /* static key enabled. */
387 KMEM_ACCOUNTED_DEAD, /* dead memcg with pending kmem charges */ 386 KMEM_ACCOUNTED_DEAD, /* dead memcg with pending kmem charges */
388}; 387};
389 388
390/* We account when limit is on, but only after call sites are patched */
391#define KMEM_ACCOUNTED_MASK \
392 ((1 << KMEM_ACCOUNTED_ACTIVE) | (1 << KMEM_ACCOUNTED_ACTIVATED))
393
394#ifdef CONFIG_MEMCG_KMEM 389#ifdef CONFIG_MEMCG_KMEM
395static inline void memcg_kmem_set_active(struct mem_cgroup *memcg) 390static inline void memcg_kmem_set_active(struct mem_cgroup *memcg)
396{ 391{
@@ -402,16 +397,6 @@ static bool memcg_kmem_is_active(struct mem_cgroup *memcg)
402 return test_bit(KMEM_ACCOUNTED_ACTIVE, &memcg->kmem_account_flags); 397 return test_bit(KMEM_ACCOUNTED_ACTIVE, &memcg->kmem_account_flags);
403} 398}
404 399
405static void memcg_kmem_set_activated(struct mem_cgroup *memcg)
406{
407 set_bit(KMEM_ACCOUNTED_ACTIVATED, &memcg->kmem_account_flags);
408}
409
410static void memcg_kmem_clear_activated(struct mem_cgroup *memcg)
411{
412 clear_bit(KMEM_ACCOUNTED_ACTIVATED, &memcg->kmem_account_flags);
413}
414
415static void memcg_kmem_mark_dead(struct mem_cgroup *memcg) 400static void memcg_kmem_mark_dead(struct mem_cgroup *memcg)
416{ 401{
417 /* 402 /*
@@ -2995,8 +2980,7 @@ static DEFINE_MUTEX(set_limit_mutex);
2995static inline bool memcg_can_account_kmem(struct mem_cgroup *memcg) 2980static inline bool memcg_can_account_kmem(struct mem_cgroup *memcg)
2996{ 2981{
2997 return !mem_cgroup_disabled() && !mem_cgroup_is_root(memcg) && 2982 return !mem_cgroup_disabled() && !mem_cgroup_is_root(memcg) &&
2998 (memcg->kmem_account_flags & KMEM_ACCOUNTED_MASK) == 2983 memcg_kmem_is_active(memcg);
2999 KMEM_ACCOUNTED_MASK;
3000} 2984}
3001 2985
3002/* 2986/*
@@ -3120,19 +3104,10 @@ static int memcg_update_cache_sizes(struct mem_cgroup *memcg)
3120 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL); 3104 0, MEMCG_CACHES_MAX_SIZE, GFP_KERNEL);
3121 if (num < 0) 3105 if (num < 0)
3122 return num; 3106 return num;
3123 /*
3124 * After this point, kmem_accounted (that we test atomically in
3125 * the beginning of this conditional), is no longer 0. This
3126 * guarantees only one process will set the following boolean
3127 * to true. We don't need test_and_set because we're protected
3128 * by the set_limit_mutex anyway.
3129 */
3130 memcg_kmem_set_activated(memcg);
3131 3107
3132 ret = memcg_update_all_caches(num+1); 3108 ret = memcg_update_all_caches(num+1);
3133 if (ret) { 3109 if (ret) {
3134 ida_simple_remove(&kmem_limited_groups, num); 3110 ida_simple_remove(&kmem_limited_groups, num);
3135 memcg_kmem_clear_activated(memcg);
3136 return ret; 3111 return ret;
3137 } 3112 }
3138 3113