diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3b83957b6439..c6bd28edd533 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -3121,7 +3121,7 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups) | |||
3121 | ssize_t size = memcg_caches_array_size(num_groups); | 3121 | ssize_t size = memcg_caches_array_size(num_groups); |
3122 | 3122 | ||
3123 | size *= sizeof(void *); | 3123 | size *= sizeof(void *); |
3124 | size += sizeof(struct memcg_cache_params); | 3124 | size += offsetof(struct memcg_cache_params, memcg_caches); |
3125 | 3125 | ||
3126 | s->memcg_params = kzalloc(size, GFP_KERNEL); | 3126 | s->memcg_params = kzalloc(size, GFP_KERNEL); |
3127 | if (!s->memcg_params) { | 3127 | if (!s->memcg_params) { |
@@ -3164,13 +3164,16 @@ int memcg_update_cache_size(struct kmem_cache *s, int num_groups) | |||
3164 | int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s, | 3164 | int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s, |
3165 | struct kmem_cache *root_cache) | 3165 | struct kmem_cache *root_cache) |
3166 | { | 3166 | { |
3167 | size_t size = sizeof(struct memcg_cache_params); | 3167 | size_t size; |
3168 | 3168 | ||
3169 | if (!memcg_kmem_enabled()) | 3169 | if (!memcg_kmem_enabled()) |
3170 | return 0; | 3170 | return 0; |
3171 | 3171 | ||
3172 | if (!memcg) | 3172 | if (!memcg) { |
3173 | size = offsetof(struct memcg_cache_params, memcg_caches); | ||
3173 | size += memcg_limited_groups_array_size * sizeof(void *); | 3174 | size += memcg_limited_groups_array_size * sizeof(void *); |
3175 | } else | ||
3176 | size = sizeof(struct memcg_cache_params); | ||
3174 | 3177 | ||
3175 | s->memcg_params = kzalloc(size, GFP_KERNEL); | 3178 | s->memcg_params = kzalloc(size, GFP_KERNEL); |
3176 | if (!s->memcg_params) | 3179 | if (!s->memcg_params) |
@@ -5588,7 +5591,13 @@ static int compare_thresholds(const void *a, const void *b) | |||
5588 | const struct mem_cgroup_threshold *_a = a; | 5591 | const struct mem_cgroup_threshold *_a = a; |
5589 | const struct mem_cgroup_threshold *_b = b; | 5592 | const struct mem_cgroup_threshold *_b = b; |
5590 | 5593 | ||
5591 | return _a->threshold - _b->threshold; | 5594 | if (_a->threshold > _b->threshold) |
5595 | return 1; | ||
5596 | |||
5597 | if (_a->threshold < _b->threshold) | ||
5598 | return -1; | ||
5599 | |||
5600 | return 0; | ||
5592 | } | 5601 | } |
5593 | 5602 | ||
5594 | static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg) | 5603 | static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg) |