From: Peng Liu liupeng256@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4EG0R CVE: NA
-----------------------------------------------
Add cmdline to disable "place pages to tail" when online memory.
Signed-off-by: Peng Liu liupeng256@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../admin-guide/kernel-parameters.txt | 9 +++++++ mm/page_alloc.c | 27 ++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 425015359b5ce..420f7317aa6af 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1254,6 +1254,15 @@ Warning: use of this parameter will taint the kernel and may cause unknown problems.
+ fpi_to_tail=off + [KNL] Place pages to front in __free_pages_core(). + This kernel start-up parameter can be just used as + "fpi_to_tail=off", which means memory is online to + the front of freelist. Dynamic open is not supportted, + in other words, "fpi_to_tail=on" will be ignored by + kernel. This is just an ugly solution for circumvention + for some latent bugs revealed by "place pages to tail". + ftrace=[tracer] [FTRACE] will set and start the specified tracer as early as possible in order to facilitate early diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 935435e03cdd4..4cad86f1e3a91 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -102,6 +102,17 @@ typedef int __bitwise fpi_t; */ #define FPI_TO_TAIL ((__force fpi_t)BIT(1))
+static bool fpi_to_tail = true; + +static int __init early_fpi_to_tail(char *str) +{ + if (str && !strcmp(str, "off")) + fpi_to_tail = false; + + return 0; +} +early_param("fpi_to_tail", early_fpi_to_tail); + /* prevent >1 _updater_ of zone percpu pageset ->high and ->batch fields */ static DEFINE_MUTEX(pcp_batch_high_lock); #define MIN_PERCPU_PAGELIST_FRACTION (8) @@ -1342,12 +1353,16 @@ void __free_pages_core(struct page *page, unsigned int order) } __ClearPageReserved(p); set_page_count(p, 0); - - /* - * Bypass PCP and place fresh pages right to the tail, primarily - * relevant for memory onlining. - */ - __free_pages_ok(page, order, FPI_TO_TAIL); + if (fpi_to_tail) { + /* + * Bypass PCP and place fresh pages right to the tail, primarily + * relevant for memory onlining. + */ + __free_pages_ok(page, order, FPI_TO_TAIL); + } else { + set_page_refcounted(page); + __free_pages(page, order); + } }
#if defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) || \