[Devel] [PATCH RHEL7 COMMIT] vzstat: Port diff-vzstat-mem_free_areas_show-fix-nr_free-per-order-computation

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jun 24 03:41:41 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.17
------>
commit 0cae13553f0698e05ad42c69249ad4b8a7baac4c
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Wed Jun 24 14:41:41 2015 +0400

    vzstat: Port diff-vzstat-mem_free_areas_show-fix-nr_free-per-order-computation
    
    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 4fd0a2f..650010d 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) +



More information about the Devel mailing list