- Improve drain pages performance on large systems
Subsystems (2)
PATCH 1/1 - Improve drain pages performance on large systems
Heavy swapping within a cpuset causes frequent calls to drain_all_pages(). This sends IPIs to all cpus to free PCP pages. In most cases, there are no pages to be freed on cpus outside of the swapping cpuset.
Add checks to minimize locking and updates to potentially hot cachelines. Before acquiring locks, do a quick check to see if any pages are in the PCP queues. Exit if none.
On a 128 node SGI UV system, this reduced the IPI overhead to cpus outside of the swapping cpuset by 38% and improved time to run a pass of the swaping test from 98 sec to 51 sec. These times are obviously test & configuration dependent but the improvements are significant.
--- mm/page_alloc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
mm/page_alloc.c +14 -0
@@ -592,10 +592,24 @@ static void free_pcppages_bulk(struct zoint batch_free =0 ;int to_free = count; +/* +* Quick scan of zones. If all are empty, there is nothing to do. +*/ +for (migratetype =0 ; migratetype <MIGRATE_PCPTYPES ; migratetype++) { +struct list_head *list; + + list = &pcp->lists[migratetype]; +if (!list_empty (list)) +break ; + } +if (migratetype ==MIGRATE_PCPTYPES ) +return ; +spin_lock (&zone->lock); zone->all_unreclaimable =0 ; zone->pages_scanned =0 ; + migratetype =0 ;while (to_free) {struct page *page;struct list_head *list;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Jack Steiner
Heavy swapping within a cpuset causes frequent calls to
drain_all_pages()
Quoted 25 lines · Minchan Kim
Quoted 25 lines
Index:
linux/mm/page_alloc.c
===================================================================mm/page_alloc.c A A A 2011-02-15 16:29:43.085502487 -0600 renamed from mm/page_alloc.c A 2011-02-15 16:28:36.165921713 -0600 +13
-0@@ -592,10 +592,24 @@ static void free_pcppages_bulk(struct zo A A A A int batch_free = 0; A A A A int to_free = count; + A A A /* + A A A A * Quick scan of zones. If all are empty, there is nothing to do. + A A A A */ + A A A for (migratetype = 0; migratetype < MIGRATE_PCPTYPES; migratetype++) { + A A A A A A A struct list_head *list; + + A A A A A A A list = &pcp->lists[migratetype]; + A A A A A A A if (!list_empty(list)) + A A A A A A A A A A A break; + A A A } + A A A if (migratetype == MIGRATE_PCPTYPES) + A A A A A A A return; + A A A A spin_lock(&zone->lock); A A A A zone->all_unreclaimable = 0; A A A A zone->pages_scanned = 0;
Quoted 10 lines
mm/page_alloc.c A A A 2011-02-15 16:29:43.085502487 -0600 static void free_pcppages_bulk(struct zo · line 615
Quoted 4 lines
mm/page_alloc.c A A A 2011-02-15 16:29:43.085502487 -0600 renamed from mm/page_alloc.c A 2011-02-15 16:28:36.165921713 -0600 +1
-0+ A A A migratetype = 0; A A A A while (to_free) { A A A A A A A A struct page *page; A A A A A A A A struct list_head *list;It does make sense to me.
Although new code looks to be rather costly in small box, anyway we use the same logic in while loop so cache would be hot. so cost would be little.
I was going to mention the implications for small machines as well, this doesn't look good for callers that know free_pcppages_bulk() will do something.
Quoted 9 lines
But how about this? This one never affect fast-critical path.
mm/page_alloc.c +0
-0@@ -1095,8 +1095,10 @@ static void drain_pages(unsigned int cpu) pset =per_cpu_ptr (zone->pageset, cpu);
mm/page_alloc.c static void drain_pages(unsigned int cpu) · line 1104
Quoted 10 lines
mm/page_alloc.c +4
-2pcp = &pset->pcp; -free_pcppages_bulk (zone, pcp->count, pcp); - pcp->count =0 ; +if (pcp->count >0 ) { +free_pcppages_bulk (zone, pcp->count, pcp); + pcp->count =0 ; + }local_irq_restore (flags); } }
Right, this is 2ff754fa upstream. I'm wondering if Jack still sees the same problem since 2.6.38-rc3.
Quoted 65 lines · Minchan Kim
Quoted 52 lines · Jack Steiner
Heavy swapping within a cpuset causes frequent calls to
drain_all_pages(). This sends IPIs to all cpus to free PCP pages. In most cases, there are no pages to be freed on cpus outside of the swapping cpuset.Add checks to minimize locking and updates to potentially hot cachelines. Before acquiring locks, do a quick check to see if any pages are in the PCP queues. Exit if none.
On a 128 node SGI UV system, this reduced the IPI overhead to cpus outside of the swapping cpuset by 38% and improved time to run a pass of the swaping test from 98 sec to 51 sec. These times are obviously test & configuration dependent but the improvements are significant.
Signed-off-by Jack Steiner <[email protected]>--- mm/page_alloc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)Index:
linux/mm/page_alloc.c
===================================================================mm/page_alloc.c 2011-02-15 16:29:43.085502487 -0600 renamed from mm/page_alloc.c 2011-02-15 16:28:36.165921713 -0600 +14
-1@@ -592,10 +592,24 @@ static void free_pcppages_bulk(struct zo int batch_free = 0; int to_free = count; + /* + * Quick scan of zones. If all are empty, there is nothing to do. + */ + for (migratetype = 0; migratetype < MIGRATE_PCPTYPES; migratetype++) { + struct list_head *list; + + list = &pcp->lists[migratetype]; + if (!list_empty(list)) + break; + } + if (migratetype == MIGRATE_PCPTYPES) + return; + spin_lock(&zone->lock); zone->all_unreclaimable = 0; zone->pages_scanned = 0; + migratetype = 0; while (to_free) { struct page *page; struct list_head *list; --Quoted 6 lines
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>It does make sense to me.
Although new code looks to be rather costly in small box, anyway we use the same logic in while loop so cache would be hot. so cost would be little.
Quoted 1 line
But how about this? This one never affect fast-critical path.
Yes. Much cleaner. And even better, as David points out it is already in the tree.
I did my original testing on a 2.6.32 distro kernel & missed the fact that this was recently fixed upstream.
My patch from yesterday can be discarded.
Quoted 24 lines
mm/page_alloc.c +4
-2@@ -1095,8 +1095,10 @@ static void drain_pages(unsigned int cpu) pset =per_cpu_ptr (zone->pageset, cpu); pcp = &pset->pcp; -free_pcppages_bulk (zone, pcp->count, pcp); - pcp->count =0 ; +if (pcp->count >0 ) { +free_pcppages_bulk (zone, pcp->count, pcp); + pcp->count =0 ; + }local_irq_restore (flags); } }Signature · 3 lines
-- Kind regards, Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Jack Steiner
Heavy swapping within a cpuset causes frequent calls to
drain_all_pages().
I suspect drain_all_pages should be really made more zone aware in the first place and only drain what is actually needed (e.g. work off a zonelist). I was fighting with this for hwpoison too.
That said your patch looks reasonable.
-Andi
Signature · 8 lines
[email protected] -- Speaking for myself only -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>