linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Cgroup: Fix memory accounting scalability in shrink_page_list
@ 2012-07-19 23:34 Tim Chen
  2012-07-20  3:19 ` Kamezawa Hiroyuki
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Tim Chen @ 2012-07-19 23:34 UTC (permalink / raw)
  To: Andrew Morton, Mel Gorman, KAMEZAWA Hiroyuki, Minchan Kim,
	Johannes Weiner
  Cc: Kirill A. Shutemov, andi.kleen, linux-mm, linux-kernel

Hi,

I noticed in a multi-process parallel files reading benchmark I ran on a
8 socket machine,  throughput slowed down by a factor of 8 when I ran
the benchmark within a cgroup container.  I traced the problem to the
following code path (see below) when we are trying to reclaim memory
from file cache.  The res_counter_uncharge function is called on every
page that's reclaimed and created heavy lock contention.  The patch
below allows the reclaimed pages to be uncharged from the resource
counter in batch and recovered the regression. 

Tim

     40.67%           usemem  [kernel.kallsyms]                   [k] _raw_spin_lock
                      |
                      --- _raw_spin_lock
                         |
                         |--92.61%-- res_counter_uncharge
                         |          |
                         |          |--100.00%-- __mem_cgroup_uncharge_common
                         |          |          |
                         |          |          |--100.00%-- mem_cgroup_uncharge_cache_page
                         |          |          |          __remove_mapping
                         |          |          |          shrink_page_list
                         |          |          |          shrink_inactive_list
                         |          |          |          shrink_mem_cgroup_zone
                         |          |          |          shrink_zone
                         |          |          |          do_try_to_free_pages
                         |          |          |          try_to_free_pages
                         |          |          |          __alloc_pages_nodemask
                         |          |          |          alloc_pages_current


---
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 33dc256..aac5672 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -779,6 +779,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
 
 	cond_resched();
 
+	mem_cgroup_uncharge_start();
 	while (!list_empty(page_list)) {
 		enum page_references references;
 		struct address_space *mapping;
@@ -1026,6 +1027,7 @@ keep_lumpy:
 
 	list_splice(&ret_pages, page_list);
 	count_vm_events(PGACTIVATE, pgactivate);
+	mem_cgroup_uncharge_end();
 	*ret_nr_dirty += nr_dirty;
 	*ret_nr_writeback += nr_writeback;
 	return nr_reclaimed;


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-07-20 16:38 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-19 23:34 [PATCH] Cgroup: Fix memory accounting scalability in shrink_page_list Tim Chen
2012-07-20  3:19 ` Kamezawa Hiroyuki
2012-07-20  4:25   ` Minchan Kim
2012-07-20 16:38   ` Tim Chen
2012-07-20  6:27 ` Johannes Weiner
2012-07-20 11:19 ` Kirill A. Shutemov
2012-07-20 13:53 ` Michal Hocko
2012-07-20 14:16   ` Johannes Weiner
2012-07-20 14:38     ` Michal Hocko
2012-07-20 15:12       ` Johannes Weiner
2012-07-20 16:31         ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).