diff for duplicates of <20180712235240.GH2070@MiWiFi-R3L-srv> diff --git a/a/1.txt b/N1/1.txt index e6257c2..9cc2c6a 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -59,3 +59,64 @@ movable, in fact there's only 5G available for movable, just after kernel. I made a v4 patch which possibly can fix it. + + +From dbcac3631863aed556dc2c4ff1839772dfd02d18 Mon Sep 17 00:00:00 2001 +From: Baoquan He <bhe@redhat.com> +Date: Fri, 13 Jul 2018 07:49:29 +0800 +Subject: [PATCH v4] mm, page_alloc: find movable zone after kernel text + +In find_zone_movable_pfns_for_nodes(), when try to find the starting +PFN movable zone begins at in each node, kernel text position is not +considered. KASLR may put kernel after which movable zone begins. + +Fix it by finding movable zone after kernel text on that node. + +Signed-off-by: Baoquan He <bhe@redhat.com> +--- + mm/page_alloc.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/mm/page_alloc.c b/mm/page_alloc.c +index 1521100f1e63..5bc1a47dafda 100644 +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -6547,7 +6547,7 @@ static unsigned long __init early_calculate_totalpages(void) + static void __init find_zone_movable_pfns_for_nodes(void) + { + int i, nid; +- unsigned long usable_startpfn; ++ unsigned long usable_startpfn, kernel_endpfn, arch_startpfn; + unsigned long kernelcore_node, kernelcore_remaining; + /* save the state before borrow the nodemask */ + nodemask_t saved_node_state = node_states[N_MEMORY]; +@@ -6649,8 +6649,9 @@ static void __init find_zone_movable_pfns_for_nodes(void) + if (!required_kernelcore || required_kernelcore >= totalpages) + goto out; + ++ kernel_endpfn = PFN_UP(__pa_symbol(_end)); + /* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */ +- usable_startpfn = arch_zone_lowest_possible_pfn[movable_zone]; ++ arch_startpfn = arch_zone_lowest_possible_pfn[movable_zone]; + + restart: + /* Spread kernelcore memory as evenly as possible throughout nodes */ +@@ -6659,6 +6660,16 @@ static void __init find_zone_movable_pfns_for_nodes(void) + unsigned long start_pfn, end_pfn; + + /* ++ * KASLR may put kernel near tail of node memory, ++ * start after kernel on that node to find PFN ++ * at which zone begins. ++ */ ++ if (pfn_to_nid(kernel_endpfn) == nid) ++ usable_startpfn = max(arch_startpfn, kernel_endpfn); ++ else ++ usable_startpfn = arch_startpfn; ++ ++ /* + * Recalculate kernelcore_node if the division per node + * now exceeds what is necessary to satisfy the requested + * amount of memory for the kernel +-- +2.13.6 diff --git a/a/content_digest b/N1/content_digest index 96a3d36..d02774c 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -83,6 +83,67 @@ "movable, in fact there's only 5G available for movable, just after\n" "kernel.\n" "\n" - I made a v4 patch which possibly can fix it. + "I made a v4 patch which possibly can fix it.\n" + "\n" + "\n" + "From dbcac3631863aed556dc2c4ff1839772dfd02d18 Mon Sep 17 00:00:00 2001\n" + "From: Baoquan He <bhe@redhat.com>\n" + "Date: Fri, 13 Jul 2018 07:49:29 +0800\n" + "Subject: [PATCH v4] mm, page_alloc: find movable zone after kernel text\n" + "\n" + "In find_zone_movable_pfns_for_nodes(), when try to find the starting\n" + "PFN movable zone begins at in each node, kernel text position is not\n" + "considered. KASLR may put kernel after which movable zone begins.\n" + "\n" + "Fix it by finding movable zone after kernel text on that node.\n" + "\n" + "Signed-off-by: Baoquan He <bhe@redhat.com>\n" + "---\n" + " mm/page_alloc.c | 15 +++++++++++++--\n" + " 1 file changed, 13 insertions(+), 2 deletions(-)\n" + "\n" + "diff --git a/mm/page_alloc.c b/mm/page_alloc.c\n" + "index 1521100f1e63..5bc1a47dafda 100644\n" + "--- a/mm/page_alloc.c\n" + "+++ b/mm/page_alloc.c\n" + "@@ -6547,7 +6547,7 @@ static unsigned long __init early_calculate_totalpages(void)\n" + " static void __init find_zone_movable_pfns_for_nodes(void)\n" + " {\n" + " \tint i, nid;\n" + "-\tunsigned long usable_startpfn;\n" + "+\tunsigned long usable_startpfn, kernel_endpfn, arch_startpfn;\n" + " \tunsigned long kernelcore_node, kernelcore_remaining;\n" + " \t/* save the state before borrow the nodemask */\n" + " \tnodemask_t saved_node_state = node_states[N_MEMORY];\n" + "@@ -6649,8 +6649,9 @@ static void __init find_zone_movable_pfns_for_nodes(void)\n" + " \tif (!required_kernelcore || required_kernelcore >= totalpages)\n" + " \t\tgoto out;\n" + " \n" + "+\tkernel_endpfn = PFN_UP(__pa_symbol(_end));\n" + " \t/* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */\n" + "-\tusable_startpfn = arch_zone_lowest_possible_pfn[movable_zone];\n" + "+\tarch_startpfn = arch_zone_lowest_possible_pfn[movable_zone];\n" + " \n" + " restart:\n" + " \t/* Spread kernelcore memory as evenly as possible throughout nodes */\n" + "@@ -6659,6 +6660,16 @@ static void __init find_zone_movable_pfns_for_nodes(void)\n" + " \t\tunsigned long start_pfn, end_pfn;\n" + " \n" + " \t\t/*\n" + "+\t\t * KASLR may put kernel near tail of node memory,\n" + "+\t\t * start after kernel on that node to find PFN\n" + "+\t\t * at which zone begins.\n" + "+\t\t */\n" + "+\t\tif (pfn_to_nid(kernel_endpfn) == nid)\n" + "+\t\t usable_startpfn = max(arch_startpfn, kernel_endpfn);\n" + "+\t\telse\n" + "+\t\t usable_startpfn = arch_startpfn;\n" + "+\n" + "+\t\t/*\n" + " \t\t * Recalculate kernelcore_node if the division per node\n" + " \t\t * now exceeds what is necessary to satisfy the requested\n" + " \t\t * amount of memory for the kernel\n" + "-- \n" + 2.13.6 -5486c96ecd9a5528167e1b8fd8b17959c2d05d69edb393820e9be1a7293d185d +8df30981e4d7f8f144e291a7b01bf4a2d6d626d2893dae107e244a4be3bcea2b
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.