From: Pingfan Liu <kernelfans@gmail.com>
To: x86@kernel.org, linux-acpi@vger.kernel.org
Cc: Pingfan Liu <kernelfans@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/4] x86/mm: set allowed range for memblock allocator
Date: Mon, 7 Jan 2019 16:24:44 +0800 [thread overview]
Message-ID: <1546849485-27933-4-git-send-email-kernelfans@gmail.com> (raw)
In-Reply-To: <1546849485-27933-1-git-send-email-kernelfans@gmail.com>
Due to the incoming divergence of x86_32 and x86_64, there is requirement
to set the allowed allocating range at the early boot stage.
This patch also includes minor change to remove redundat cond check, refer
to memblock_find_in_range_node(), memblock_find_in_range() has already
protect itself from the case: start > end.
Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-kernel@vger.kernel.org
---
arch/x86/mm/init.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index f905a23..84baa66 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -76,6 +76,14 @@ static unsigned long min_pfn_mapped;
static bool __initdata can_use_brk_pgt = true;
+static unsigned long min_pfn_allowed;
+static unsigned long max_pfn_allowed;
+void set_alloc_range(unsigned long low, unsigned long high)
+{
+ min_pfn_allowed = low;
+ max_pfn_allowed = high;
+}
+
/*
* Pages returned are already directly mapped.
*
@@ -100,12 +108,10 @@ __ref void *alloc_low_pages(unsigned int num)
if ((pgt_buf_end + num) > pgt_buf_top || !can_use_brk_pgt) {
unsigned long ret = 0;
- if (min_pfn_mapped < max_pfn_mapped) {
- ret = memblock_find_in_range(
- min_pfn_mapped << PAGE_SHIFT,
- max_pfn_mapped << PAGE_SHIFT,
- PAGE_SIZE * num , PAGE_SIZE);
- }
+ ret = memblock_find_in_range(
+ min_pfn_allowed << PAGE_SHIFT,
+ max_pfn_allowed << PAGE_SHIFT,
+ PAGE_SIZE * num, PAGE_SIZE);
if (ret)
memblock_reserve(ret, PAGE_SIZE * num);
else if (can_use_brk_pgt)
@@ -588,14 +594,17 @@ static void __init memory_map_top_down(unsigned long map_start,
start = map_start;
mapped_ram_size += init_range_memory_mapping(start,
last_start);
+ set_alloc_range(min_pfn_mapped, max_pfn_mapped);
last_start = start;
min_pfn_mapped = last_start >> PAGE_SHIFT;
if (mapped_ram_size >= step_size)
step_size = get_new_step_size(step_size);
}
- if (real_end < map_end)
+ if (real_end < map_end) {
init_range_memory_mapping(real_end, map_end);
+ set_alloc_range(min_pfn_mapped, max_pfn_mapped);
+ }
}
/**
@@ -636,6 +645,7 @@ static void __init memory_map_bottom_up(unsigned long map_start,
}
mapped_ram_size += init_range_memory_mapping(start, next);
+ set_alloc_range(min_pfn_mapped, max_pfn_mapped);
start = next;
if (mapped_ram_size >= step_size)
--
2.7.4
next prev parent reply other threads:[~2019-01-07 8:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-07 8:24 [RFC PATCH 0/4] x86_64/mm: remove bottom-up allocation style by pushing forward the parsing of mem hotplug info Pingfan Liu
2019-01-07 8:24 ` [RFC PATCH 1/4] acpi: change the topo of acpi_table_upgrade() Pingfan Liu
2019-01-07 10:55 ` Rafael J. Wysocki
2019-01-07 8:24 ` [RFC PATCH 2/4] x86/setup: parse acpi to get hotplug info before init_mem_mapping() Pingfan Liu
2019-01-07 12:52 ` Pingfan Liu
2019-01-07 17:11 ` Dave Hansen
2019-01-08 6:30 ` Pingfan Liu
2019-01-07 8:24 ` Pingfan Liu [this message]
2019-01-07 8:24 ` [RFC PATCH 4/4] x86/mm: remove bottom-up allocation style for x86_64 Pingfan Liu
2019-01-07 17:42 ` Dave Hansen
2019-01-08 6:13 ` Pingfan Liu
2019-01-08 6:37 ` Juergen Gross
2019-01-08 17:32 ` Dave Hansen
2019-01-09 2:44 ` Pingfan Liu
2019-01-07 17:03 ` [RFC PATCH 0/4] x86_64/mm: remove bottom-up allocation style by pushing forward the parsing of mem hotplug info Dave Hansen
2019-01-08 5:49 ` Pingfan Liu
2019-01-08 10:05 ` Chao Fan
2019-01-08 13:27 ` Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1546849485-27933-4-git-send-email-kernelfans@gmail.com \
--to=kernelfans@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox