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: David Rientjes <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Adrian Bunk <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
David Rientjes 2008-02-09 00:10:15 -08:00 • committed by Linus Torvalds
commit 60c12b1202
3 changed files with 7 additions and 9 deletions

View file

@ -321,7 +321,7 @@ static int page_referenced_anon(struct page *page,
* counting on behalf of references from different
* cgroups
*/
if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont))
if (mem_cont && !vm_match_cgroup(vma->vm_mm, mem_cont))
continue;
referenced += page_referenced_one(page, vma, &mapcount);
if (!mapcount)
@ -382,7 +382,7 @@ static int page_referenced_file(struct page *page,
* counting on behalf of references from different
* cgroups
*/
if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont))
if (mem_cont && !vm_match_cgroup(vma->vm_mm, mem_cont))
continue;
if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE))
== (VM_LOCKED|VM_MAYSHARE)) {