[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191205021403.25606-5-richardw.yang@linux.intel.com>
Date: Thu, 5 Dec 2019 10:14:01 +0800
From: Wei Yang <richardw.yang@...ux.intel.com>
To: x86@...nel.org, linux-kernel@...r.kernel.org
Cc: richard.weiyang@...il.com, dave.hansen@...ux.intel.com,
luto@...nel.org, peterz@...radead.or, tglx@...utronix.de,
Wei Yang <richardw.yang@...ux.intel.com>
Subject: [Patch v2 4/6] x86/mm: Refine debug print string retrieval function
Generally, the mapping page size are:
4K, 2M, 1G
except in case 32-bit without PAE, the mapping page size are:
4K, 4M
Based on PG_LEVEL_X definition and mr->page_size_mask, we can calculate
the mapping page size from a predefined string array.
Signed-off-by: Wei Yang <richardw.yang@...ux.intel.com>
---
arch/x86/mm/init.c | 39 +++++++++++++--------------------------
1 file changed, 13 insertions(+), 26 deletions(-)
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 0eb5edb63fa2..ded58a31c679 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -308,29 +308,20 @@ static void __ref adjust_range_page_size_mask(struct map_range *mr,
}
}
-static const char *page_size_string(struct map_range *mr)
+static void __meminit mr_print(struct map_range *mr, unsigned int maxidx)
{
- static const char str_1g[] = "1G";
- static const char str_2m[] = "2M";
- static const char str_4m[] = "4M";
- static const char str_4k[] = "4k";
-
- if (mr->page_size_mask & (1U<<PG_LEVEL_1G))
- return str_1g;
- /*
- * 32-bit without PAE has a 4M large page size.
- * PG_LEVEL_2M is misnamed, but we can at least
- * print out the right size in the string.
- */
- if (IS_ENABLED(CONFIG_X86_32) &&
- !IS_ENABLED(CONFIG_X86_PAE) &&
- mr->page_size_mask & (1U<<PG_LEVEL_2M))
- return str_4m;
-
- if (mr->page_size_mask & (1U<<PG_LEVEL_2M))
- return str_2m;
+#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
+ static const char *sz[2] = { "4K", "4M" };
+#else
+ static const char *sz[4] = { "4K", "2M", "1G", "" };
+#endif
+ unsigned int idx, s;
- return str_4k;
+ for (idx = 0; idx < maxidx; idx++, mr++) {
+ s = (mr->page_size_mask >> PG_LEVEL_2M) & (ARRAY_SIZE(sz) - 1);
+ pr_debug(" [mem %#010lx-%#010lx] page size %s\n",
+ mr->start, mr->end - 1, sz[s]);
+ }
}
static int __meminit split_mem_range(struct map_range *mr,
@@ -425,11 +416,7 @@ static int __meminit split_mem_range(struct map_range *mr,
nr_range--;
}
- for (i = 0; i < nr_range; i++)
- pr_debug(" [mem %#010lx-%#010lx] page %s\n",
- mr[i].start, mr[i].end - 1,
- page_size_string(&mr[i]));
-
+ mr_print(mr, nr_range);
return nr_range;
}
--
2.17.1
Powered by blists - more mailing lists