Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64958e23 authored by Vinayak Menon's avatar Vinayak Menon
Browse files

mm: avoid taking zone lock in pagetypeinfo_showmixed()

pagetypeinfo_showmixedcount_print is found to take a lot of time to
complete and it does this holding the zone lock and disabling interrupts.
In some cases it is found to take more than a second (On a 2.4GHz,8Gb
RAM,arm64 cpu).  Avoid taking the zone lock similar to what is done by
read_page_owner, which means possibility of inaccurate results.

Link: http://lkml.kernel.org/r/1498045643-12257-1-git-send-email-vinmenon@codeaurora.org


Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: zhongjiang <zhongjiang@huawei.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: David Rientjes <rientjes@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Git-commit: a94b5fd913ac55a32fe05dfba21eb6af0e539781
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git


Change-Id: I11ec4a3a445d602e47fcc18a3e40480b74ad98af
[vinmenon@codeaurora.org: fix trivial merge conflicts]
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 724abfa0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -285,7 +285,11 @@ void pagetypeinfo_showmixedcount_print(struct seq_file *m,
				continue;

			if (PageBuddy(page)) {
				pfn += (1UL << page_order(page)) - 1;
				unsigned long freepage_order;

				freepage_order = page_order_unsafe(page);
				if (freepage_order < MAX_ORDER)
					pfn += (1UL << freepage_order) - 1;
				continue;
			}

+14 −9
Original line number Diff line number Diff line
@@ -1122,6 +1122,7 @@ static void frag_stop(struct seq_file *m, void *arg)

/* Walk all the zones in a node and print using a callback */
static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
		bool nolock,
		void (*print)(struct seq_file *m, pg_data_t *, struct zone *))
{
	struct zone *zone;
@@ -1132,8 +1133,10 @@ static void walk_zones_in_node(struct seq_file *m, pg_data_t *pgdat,
		if (!populated_zone(zone))
			continue;

		if (!nolock)
			spin_lock_irqsave(&zone->lock, flags);
		print(m, pgdat, zone);
		if (!nolock)
			spin_unlock_irqrestore(&zone->lock, flags);
	}
}
@@ -1157,7 +1160,7 @@ static void frag_show_print(struct seq_file *m, pg_data_t *pgdat,
static int frag_show(struct seq_file *m, void *arg)
{
	pg_data_t *pgdat = (pg_data_t *)arg;
	walk_zones_in_node(m, pgdat, frag_show_print);
	walk_zones_in_node(m, pgdat, false, frag_show_print);
	return 0;
}

@@ -1198,7 +1201,7 @@ static int pagetypeinfo_showfree(struct seq_file *m, void *arg)
		seq_printf(m, "%6d ", order);
	seq_putc(m, '\n');

	walk_zones_in_node(m, pgdat, pagetypeinfo_showfree_print);
	walk_zones_in_node(m, pgdat, false, pagetypeinfo_showfree_print);

	return 0;
}
@@ -1250,7 +1253,8 @@ static int pagetypeinfo_showblockcount(struct seq_file *m, void *arg)
	for (mtype = 0; mtype < MIGRATE_TYPES; mtype++)
		seq_printf(m, "%12s ", migratetype_names[mtype]);
	seq_putc(m, '\n');
	walk_zones_in_node(m, pgdat, pagetypeinfo_showblockcount_print);
	walk_zones_in_node(m, pgdat, false,
		pagetypeinfo_showblockcount_print);

	return 0;
}
@@ -1276,7 +1280,8 @@ static void pagetypeinfo_showmixedcount(struct seq_file *m, pg_data_t *pgdat)
		seq_printf(m, "%12s ", migratetype_names[mtype]);
	seq_putc(m, '\n');

	walk_zones_in_node(m, pgdat, pagetypeinfo_showmixedcount_print);
	walk_zones_in_node(m, pgdat, true,
		pagetypeinfo_showmixedcount_print);
#endif /* CONFIG_PAGE_OWNER */
}

@@ -1433,7 +1438,7 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
static int zoneinfo_show(struct seq_file *m, void *arg)
{
	pg_data_t *pgdat = (pg_data_t *)arg;
	walk_zones_in_node(m, pgdat, zoneinfo_show_print);
	walk_zones_in_node(m, pgdat, false, zoneinfo_show_print);
	return 0;
}

@@ -1862,7 +1867,7 @@ static int unusable_show(struct seq_file *m, void *arg)
	if (!node_state(pgdat->node_id, N_MEMORY))
		return 0;

	walk_zones_in_node(m, pgdat, unusable_show_print);
	walk_zones_in_node(m, pgdat, false, unusable_show_print);

	return 0;
}
@@ -1914,7 +1919,7 @@ static int extfrag_show(struct seq_file *m, void *arg)
{
	pg_data_t *pgdat = (pg_data_t *)arg;

	walk_zones_in_node(m, pgdat, extfrag_show_print);
	walk_zones_in_node(m, pgdat, false, extfrag_show_print);

	return 0;
}