Commit 2733c06a authored by KOSAKI Motohiro's avatar KOSAKI Motohiro Committed by Linus Torvalds
Browse files

memcg: protect prev_priority

Currently, mem_cgroup doesn't have own lock and almost its member doesn't
need.  (e.g.  mem_cgroup->info is protected by zone lock, mem_cgroup->stat
is per cpu variable)

However, there is one explict exception.  mem_cgroup->prev_priorit need
lock, but doesn't protect.  Luckly, this is NOT bug because prev_priority
isn't used for current reclaim code.

However, we plan to use prev_priority future again.  Therefore, fixing is

In addition, we plan to reuse this lock for another member.  Then
"reclaim_param_lock" name is better than "prev_priority_lock".
Acked-by: default avatarKAMEZAWA Hiroyuki <>
Signed-off-by: default avatarKOSAKI Motohiro <>
Cc: Balbir Singh <>
Cc: Daisuke Nishimura <>
Cc: Hugh Dickins <>
Cc: KOSAKI Motohiro <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent e72e2bd6
......@@ -144,6 +144,11 @@ struct mem_cgroup {
struct mem_cgroup_lru_info info;
protect against reclaim related member.
spinlock_t reclaim_param_lock;
int prev_priority; /* for recording reclaim priority */
......@@ -400,18 +405,28 @@ int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem)
int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem)
return mem->prev_priority;
int prev_priority;
prev_priority = mem->prev_priority;
return prev_priority;
void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, int priority)
if (priority < mem->prev_priority)
mem->prev_priority = priority;
void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, int priority)
mem->prev_priority = priority;
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)
mem->last_scanned_child = NULL;
return &mem->css;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment