aboutsummaryrefslogtreecommitdiffstats
path: root/mm/rmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/rmap.c')
-rw-r--r--mm/rmap.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/mm/rmap.c b/mm/rmap.c
index 4a3487921eff..a0e92a263d12 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -302,7 +302,8 @@ out:
302 return referenced; 302 return referenced;
303} 303}
304 304
305static int page_referenced_anon(struct page *page) 305static int page_referenced_anon(struct page *page,
306 struct mem_cgroup *mem_cont)
306{ 307{
307 unsigned int mapcount; 308 unsigned int mapcount;
308 struct anon_vma *anon_vma; 309 struct anon_vma *anon_vma;
@@ -315,6 +316,13 @@ static int page_referenced_anon(struct page *page)
315 316
316 mapcount = page_mapcount(page); 317 mapcount = page_mapcount(page);
317 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) { 318 list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
319 /*
320 * If we are reclaiming on behalf of a cgroup, skip
321 * counting on behalf of references from different
322 * cgroups
323 */
324 if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont))
325 continue;
318 referenced += page_referenced_one(page, vma, &mapcount); 326 referenced += page_referenced_one(page, vma, &mapcount);
319 if (!mapcount) 327 if (!mapcount)
320 break; 328 break;
@@ -335,7 +343,8 @@ static int page_referenced_anon(struct page *page)
335 * 343 *
336 * This function is only called from page_referenced for object-based pages. 344 * This function is only called from page_referenced for object-based pages.
337 */ 345 */
338static int page_referenced_file(struct page *page) 346static int page_referenced_file(struct page *page,
347 struct mem_cgroup *mem_cont)
339{ 348{
340 unsigned int mapcount; 349 unsigned int mapcount;
341 struct address_space *mapping = page->mapping; 350 struct address_space *mapping = page->mapping;
@@ -368,6 +377,13 @@ static int page_referenced_file(struct page *page)
368 mapcount = page_mapcount(page); 377 mapcount = page_mapcount(page);
369 378
370 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { 379 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
380 /*
381 * If we are reclaiming on behalf of a cgroup, skip
382 * counting on behalf of references from different
383 * cgroups
384 */
385 if (mem_cont && (mm_cgroup(vma->vm_mm) != mem_cont))
386 continue;
371 if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE)) 387 if ((vma->vm_flags & (VM_LOCKED|VM_MAYSHARE))
372 == (VM_LOCKED|VM_MAYSHARE)) { 388 == (VM_LOCKED|VM_MAYSHARE)) {
373 referenced++; 389 referenced++;
@@ -390,7 +406,8 @@ static int page_referenced_file(struct page *page)
390 * Quick test_and_clear_referenced for all mappings to a page, 406 * Quick test_and_clear_referenced for all mappings to a page,
391 * returns the number of ptes which referenced the page. 407 * returns the number of ptes which referenced the page.
392 */ 408 */
393int page_referenced(struct page *page, int is_locked) 409int page_referenced(struct page *page, int is_locked,
410 struct mem_cgroup *mem_cont)
394{ 411{
395 int referenced = 0; 412 int referenced = 0;
396 413
@@ -402,14 +419,15 @@ int page_referenced(struct page *page, int is_locked)
402 419
403 if (page_mapped(page) && page->mapping) { 420 if (page_mapped(page) && page->mapping) {
404 if (PageAnon(page)) 421 if (PageAnon(page))
405 referenced += page_referenced_anon(page); 422 referenced += page_referenced_anon(page, mem_cont);
406 else if (is_locked) 423 else if (is_locked)
407 referenced += page_referenced_file(page); 424 referenced += page_referenced_file(page, mem_cont);
408 else if (TestSetPageLocked(page)) 425 else if (TestSetPageLocked(page))
409 referenced++; 426 referenced++;
410 else { 427 else {
411 if (page->mapping) 428 if (page->mapping)
412 referenced += page_referenced_file(page); 429 referenced +=
430 page_referenced_file(page, mem_cont);
413 unlock_page(page); 431 unlock_page(page);
414 } 432 }
415 } 433 }