[Devel] [PATCH rh7 02/14] Port diff-vzstat-mem_free_areas_show-fix-nr_free-per-order-computation

Vladimir Davydov vdavydov at parallels.com
Tue Jun 23 09:29:38 PDT 2015


Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: vzstat: mem_free_areas_show: fix nr_free per order computation
Date: Mon, 26 May 2014 18:22:48 +0400

To find the number of free pages of each order we walk over page free
lists. On large machines with hundred of GBs of RAM this can take huge
time. Since this is done with zone->lock held, this will result in
serious latency degradation.

Actually, there is no need to iterate over per-order free lists to find
out how many pages are on them, because the numbers are stored in
free_area->nr_free. So let's just get them from there.

https://jira.sw.ru/browse/PSBM-26984

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
=============================================================================

Related to https://jira.sw.ru/browse/PSBM-33650

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 kernel/ve/vzstat.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/kernel/ve/vzstat.c b/kernel/ve/vzstat.c
index 4fd0a2f4df6a..650010d770dd 100644
--- a/kernel/ve/vzstat.c
+++ b/kernel/ve/vzstat.c
@@ -432,7 +432,7 @@ static void mem_free_areas_show(struct seq_file *m, void *v)
 	struct zonestat zones[MAX_NR_ZONES];
 	struct zonestat *zdst;
 	struct zone *zsrc;
-	int type, mtype, order;
+	int type, order;
 
 	memset(zones, 0, sizeof(zones));
 
@@ -454,19 +454,8 @@ static void mem_free_areas_show(struct seq_file *m, void *v)
 					type, zsrc->name, zdst->name);
 
 			spin_lock_irqsave(&zsrc->lock, flags);
-			for_each_migratetype_order(order, mtype) {
-				struct list_head *head, *curr;
-				head = &(zsrc->free_area + order)->free_list[mtype];
-				curr = head;
-
-				for (;;) {
-					if (!curr)
-						break;
-					if ((curr = curr->next) == head)
-						break;
-					zdst->nr_free[order]++;
-				}
-			}
+			for (order = 0; order < MAX_ORDER; order++)
+				zdst->nr_free[order] += zsrc->free_area[order].nr_free;
 			spin_unlock_irqrestore(&zsrc->lock, flags);
 
 			zdst->nr_active     += zone_page_state(zsrc, NR_ACTIVE_ANON) +
-- 
2.1.4




More information about the Devel mailing list