提交 60c12b12 编写于 作者: D David Rientjes 提交者: Linus Torvalds

memcontrol: add vm_match_cgroup()

mm_cgroup() is exclusively used to test whether an mm's mem_cgroup pointer
is pointing to a specific cgroup.  Instead of returning the pointer, we can
just do the test itself in a new macro:

	vm_match_cgroup(mm, cgroup)

returns non-zero if the mm's mem_cgroup points to cgroup.  Otherwise it
returns zero.
Signed-off-by: NDavid Rientjes <rientjes@google.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 6966a977
...@@ -51,10 +51,8 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, ...@@ -51,10 +51,8 @@ extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask); gfp_t gfp_mask);
int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm) #define vm_match_cgroup(mm, cgroup) \
{ ((cgroup) == rcu_dereference((mm)->mem_cgroup))
return rcu_dereference(mm->mem_cgroup);
}
extern int mem_cgroup_prepare_migration(struct page *page); extern int mem_cgroup_prepare_migration(struct page *page);
extern void mem_cgroup_end_migration(struct page *page); extern void mem_cgroup_end_migration(struct page *page);
...@@ -123,9 +121,9 @@ static inline int mem_cgroup_cache_charge(struct page *page, ...@@ -123,9 +121,9 @@ static inline int mem_cgroup_cache_charge(struct page *page,
return 0; return 0;
} }
static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm) static inline int vm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem)
{ {
return NULL; return 1;
} }
static inline int task_in_mem_cgroup(struct task_struct *task, static inline int task_in_mem_cgroup(struct task_struct *task,
......
...@@ -399,7 +399,7 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem) ...@@ -399,7 +399,7 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
int ret; int ret;
task_lock(task); task_lock(task);
ret = task->mm && mm_cgroup(task->mm) == mem; ret = task->mm && vm_match_cgroup(task->mm, mem);
task_unlock(task); task_unlock(task);
return ret; return ret;
} }
......
...@@ -321,7 +321,7 @@ static int page_referenced_anon(struct page *page, ...@@ -321,7 +321,7 @@ static int page_referenced_anon(struct page *page,
* counting on behalf of references from different * counting on behalf of references from different
* cgroups * cgroups
*/ */
if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont)) if (mem_cont && !vm_match_cgroup(vma->vm_mm, mem_cont))
continue; continue;
referenced += page_referenced_one(page, vma, &mapcount); referenced += page_referenced_one(page, vma, &mapcount);
if (!mapcount) if (!mapcount)
...@@ -382,7 +382,7 @@ static int page_referenced_file(struct page *page, ...@@ -382,7 +382,7 @@ static int page_referenced_file(struct page *page,
* counting on behalf of references from different * counting on behalf of references from different
* cgroups * cgroups
*/ */
if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont)) if (mem_cont && !vm_match_cgroup(vma->vm_mm, mem_cont))
continue; continue;
if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE)) if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE))
== (VM_LOCKED|VM_MAYSHARE)) { == (VM_LOCKED|VM_MAYSHARE)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册