diff options
-rw-r--r-- | mm/memcontrol.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index af28e128b749..027c0dd7a83e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -144,6 +144,11 @@ struct mem_cgroup { | |||
144 | */ | 144 | */ |
145 | struct mem_cgroup_lru_info info; | 145 | struct mem_cgroup_lru_info info; |
146 | 146 | ||
147 | /* | ||
148 | protect against reclaim related member. | ||
149 | */ | ||
150 | spinlock_t reclaim_param_lock; | ||
151 | |||
147 | int prev_priority; /* for recording reclaim priority */ | 152 | int prev_priority; /* for recording reclaim priority */ |
148 | 153 | ||
149 | /* | 154 | /* |
@@ -400,18 +405,28 @@ int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) | |||
400 | */ | 405 | */ |
401 | int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem) | 406 | int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem) |
402 | { | 407 | { |
403 | return mem->prev_priority; | 408 | int prev_priority; |
409 | |||
410 | spin_lock(&mem->reclaim_param_lock); | ||
411 | prev_priority = mem->prev_priority; | ||
412 | spin_unlock(&mem->reclaim_param_lock); | ||
413 | |||
414 | return prev_priority; | ||
404 | } | 415 | } |
405 | 416 | ||
406 | void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, int priority) | 417 | void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, int priority) |
407 | { | 418 | { |
419 | spin_lock(&mem->reclaim_param_lock); | ||
408 | if (priority < mem->prev_priority) | 420 | if (priority < mem->prev_priority) |
409 | mem->prev_priority = priority; | 421 | mem->prev_priority = priority; |
422 | spin_unlock(&mem->reclaim_param_lock); | ||
410 | } | 423 | } |
411 | 424 | ||
412 | void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, int priority) | 425 | void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, int priority) |
413 | { | 426 | { |
427 | spin_lock(&mem->reclaim_param_lock); | ||
414 | mem->prev_priority = priority; | 428 | mem->prev_priority = priority; |
429 | spin_unlock(&mem->reclaim_param_lock); | ||
415 | } | 430 | } |
416 | 431 | ||
417 | int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone) | 432 | int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone) |
@@ -2076,6 +2091,7 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) | |||
2076 | } | 2091 | } |
2077 | mem_cgroup_set_inactive_ratio(mem); | 2092 | mem_cgroup_set_inactive_ratio(mem); |
2078 | mem->last_scanned_child = NULL; | 2093 | mem->last_scanned_child = NULL; |
2094 | spin_lock_init(&mem->reclaim_param_lock); | ||
2079 | 2095 | ||
2080 | return &mem->css; | 2096 | return &mem->css; |
2081 | free_out: | 2097 | free_out: |