Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1696888 > unrolled thread
| Started by | Michal Hocko <mhocko@kernel.org> |
|---|---|
| First post | 2017-07-26 10:40 +0200 |
| Last post | 2017-07-28 14:10 +0200 |
| Articles | 8 — 2 participants |
Back to article view | Back to linux.kernel
[RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory Michal Hocko <mhocko@kernel.org> - 2017-07-26 10:40 +0200
[RFC PATCH 4/5] mm, sparse: complain about implicit altmap usage in vmemmap_populate Michal Hocko <mhocko@kernel.org> - 2017-07-26 10:40 +0200
[RFC PATCH 1/5] mm, memory_hotplug: cleanup memory offline path Michal Hocko <mhocko@kernel.org> - 2017-07-26 10:40 +0200
Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory Michal Hocko <mhocko@kernel.org> - 2017-07-26 13:50 +0200
Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory Jerome Glisse <jglisse@redhat.com> - 2017-07-26 23:10 +0200
Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory Michal Hocko <mhocko@kernel.org> - 2017-07-27 09:00 +0200
Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory Michal Hocko <mhocko@kernel.org> - 2017-07-28 14:20 +0200
Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory Michal Hocko <mhocko@kernel.org> - 2017-07-28 14:10 +0200
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-26 10:40 +0200 |
| Subject | [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory |
| Message-ID | <u7q1j-6pF-3@gated-at.bofh.it> |
Hi,
this is another step to make the memory hotplug more usable. The primary
goal of this patchset is to reduce memory overhead of the hot added
memory (at least for SPARSE_VMEMMAP memory model). Currently we use
kmalloc to poppulate memmap (struct page array) which has two main
drawbacks a) it consumes an additional memory until the hotadded memory
itslef is onlined and b) memmap might end up on a different numa node
which is especially true for movable_node configuration.
a) is problem especially for memory hotplug based memory "ballooning"
solutions when the delay between physical memory hotplug and the
onlining can lead to OOM and that led to introduction of hacks like auto
onlining (see 31bc3858ea3e ("memory-hotplug: add automatic onlining
policy for the newly added memory")).
b) can have performance drawbacks.
One way to mitigate both issues is to simply allocate memmap array
(which is the largest memory footprint of the physical memory hotplug)
from the hotadded memory itself. VMEMMAP memory model allows us to map
any pfn range so the memory doesn't need to be online to be usable
for the array. See patch 3 for more details. In short I am reusing an
existing vmem_altmap which wants to achieve the same thing for nvdim
device memory.
I am sending this as an RFC because this has seen only a very limited
testing and I am mostly interested about opinions on the chosen
approach. I had to touch some arch code and I have no idea whether my
changes make sense there (especially ppc). Therefore I would highly
appreciate arch maintainers to check patch 2.
Patches 4 and 5 should be straightforward cleanups.
There is also one potential drawback, though. If somebody uses memory
hotplug for 1G (gigantic) hugetlb pages then this scheme will not work
for them obviously because each memory section will contain 2MB reserved
area. I am not really sure somebody does that and how reliable that
can work actually. Nevertheless, I _believe_ that onlining more memory
into virtual machines is much more common usecase. Anyway if there ever
is a strong demand for such a usecase we have basically 3 options a)
enlarge memory sections b) enhance altmap allocation strategy and reuse
low memory sections to host memmaps of other sections on the same NUMA
node c) have the memmap allocation strategy configurable to fallback to
the current allocation.
Are there any other concerns, ideas, comments?
The patches is based on the current mmotm tree (mmotm-2017-07-12-15-11)
Diffstat says
arch/arm64/mm/mmu.c | 9 ++++--
arch/ia64/mm/discontig.c | 4 ++-
arch/powerpc/mm/init_64.c | 34 ++++++++++++++++------
arch/s390/mm/vmem.c | 7 +++--
arch/sparc/mm/init_64.c | 6 ++--
arch/x86/mm/init_64.c | 13 +++++++--
include/linux/memory_hotplug.h | 7 +++--
include/linux/memremap.h | 34 +++++++++++++++-------
include/linux/mm.h | 25 ++++++++++++++--
include/linux/page-flags.h | 18 ++++++++++++
kernel/memremap.c | 6 ----
mm/compaction.c | 3 ++
mm/memory_hotplug.c | 66 +++++++++++++++++++-----------------------
mm/page_alloc.c | 25 ++++++++++++++--
mm/page_isolation.c | 11 ++++++-
mm/sparse-vmemmap.c | 13 +++++++--
mm/sparse.c | 36 ++++++++++++++++-------
17 files changed, 223 insertions(+), 94 deletions(-)
Shortlog
Michal Hocko (5):
mm, memory_hotplug: cleanup memory offline path
mm, arch: unify vmemmap_populate altmap handling
mm, memory_hotplug: allocate memmap from the added memory range for sparse-vmemmap
mm, sparse: complain about implicit altmap usage in vmemmap_populate
mm, sparse: rename kmalloc_section_memmap, __kfree_section_memmap
[toc] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-26 10:40 +0200 |
| Subject | [RFC PATCH 4/5] mm, sparse: complain about implicit altmap usage in vmemmap_populate |
| Message-ID | <u7q1k-6pF-27@gated-at.bofh.it> |
| In reply to | #1696888 |
From: Michal Hocko <mhocko@suse.com>
All current users of the altmap are in the memory hotplug code and
they use __vmemmap_populate explicitly (via __sparse_mem_map_populate).
Complain if somebody uses vmemmap_populate with altmap registered
because that could be an unexpected usage. Also call __vmemmap_populate
with NULL from that code path.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
include/linux/mm.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 3ce673570fb8..ae1fa053d09e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2456,8 +2456,12 @@ int __vmemmap_populate(unsigned long start, unsigned long end, int node,
static inline int vmemmap_populate(unsigned long start, unsigned long end,
int node)
{
- struct vmem_altmap *altmap = to_vmem_altmap(start);
- return __vmemmap_populate(start, end, node, altmap);
+ /*
+ * All users of the altmap have to be explicit and use
+ * __vmemmap_populate directly
+ */
+ WARN_ON(to_vmem_altmap(start));
+ return __vmemmap_populate(start, end, node, NULL);
}
void vmemmap_populate_print_last(void);
--
2.13.2
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-26 10:40 +0200 |
| Subject | [RFC PATCH 1/5] mm, memory_hotplug: cleanup memory offline path |
| Message-ID | <u7q1k-6pF-31@gated-at.bofh.it> |
| In reply to | #1696888 |
From: Michal Hocko <mhocko@suse.com>
check_pages_isolated_cb currently accounts the whole pfn range as being
offlined if test_pages_isolated suceeds on the range. This is based on
the assumption that all pages in the range are freed which is currently
the case in most cases but it won't be with later changes. I haven't
double checked but if the range contains invalid pfns we could
theoretically over account and underflow zone's managed pages.
Move the offlined pages counting to offline_isolated_pages_cb and
rely on __offline_isolated_pages to return the correct value.
check_pages_isolated_cb will still do it's primary job and check the pfn
range.
While we are at it remove check_pages_isolated and offline_isolated_pages
and use directly walk_system_ram_range as do in online_pages.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
include/linux/memory_hotplug.h | 2 +-
mm/memory_hotplug.c | 43 ++++++++++--------------------------------
mm/page_alloc.c | 11 +++++++++--
3 files changed, 20 insertions(+), 36 deletions(-)
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index c8a5056a5ae0..8e8738a6e76d 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -101,7 +101,7 @@ extern int add_one_highpage(struct page *page, int pfn, int bad_ppro);
extern int online_pages(unsigned long, unsigned long, int);
extern int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn,
unsigned long *valid_start, unsigned long *valid_end);
-extern void __offline_isolated_pages(unsigned long, unsigned long);
+extern unsigned long __offline_isolated_pages(unsigned long, unsigned long);
typedef void (*online_page_callback_t)(struct page *page);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index d620d0427b6b..260139f2581c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1474,17 +1474,12 @@ static int
offline_isolated_pages_cb(unsigned long start, unsigned long nr_pages,
void *data)
{
- __offline_isolated_pages(start, start + nr_pages);
+ unsigned long offlined_pages;
+ offlined_pages = __offline_isolated_pages(start, start + nr_pages);
+ *(unsigned long *)data += offlined_pages;
return 0;
}
-static void
-offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
-{
- walk_system_ram_range(start_pfn, end_pfn - start_pfn, NULL,
- offline_isolated_pages_cb);
-}
-
/*
* Check all pages in range, recoreded as memory resource, are isolated.
*/
@@ -1492,26 +1487,7 @@ static int
check_pages_isolated_cb(unsigned long start_pfn, unsigned long nr_pages,
void *data)
{
- int ret;
- long offlined = *(long *)data;
- ret = test_pages_isolated(start_pfn, start_pfn + nr_pages, true);
- offlined = nr_pages;
- if (!ret)
- *(long *)data += offlined;
- return ret;
-}
-
-static long
-check_pages_isolated(unsigned long start_pfn, unsigned long end_pfn)
-{
- long offlined = 0;
- int ret;
-
- ret = walk_system_ram_range(start_pfn, end_pfn - start_pfn, &offlined,
- check_pages_isolated_cb);
- if (ret < 0)
- offlined = (long)ret;
- return offlined;
+ return test_pages_isolated(start_pfn, start_pfn + nr_pages, true);
}
static int __init cmdline_parse_movable_node(char *p)
@@ -1620,7 +1596,7 @@ static int __ref __offline_pages(unsigned long start_pfn,
unsigned long end_pfn, unsigned long timeout)
{
unsigned long pfn, nr_pages, expire;
- long offlined_pages;
+ unsigned long offlined_pages = 0;
int ret, drain, retry_max, node;
unsigned long flags;
unsigned long valid_start, valid_end;
@@ -1703,15 +1679,16 @@ static int __ref __offline_pages(unsigned long start_pfn,
if (ret)
goto failed_removal;
/* check again */
- offlined_pages = check_pages_isolated(start_pfn, end_pfn);
- if (offlined_pages < 0) {
+ if (walk_system_ram_range(start_pfn, end_pfn - start_pfn, NULL,
+ check_pages_isolated_cb)) {
ret = -EBUSY;
goto failed_removal;
}
- pr_info("Offlined Pages %ld\n", offlined_pages);
/* Ok, all of our target is isolated.
We cannot do rollback at this point. */
- offline_isolated_pages(start_pfn, end_pfn);
+ walk_system_ram_range(start_pfn, end_pfn - start_pfn, &offlined_pages,
+ offline_isolated_pages_cb);
+ pr_info("Offlined Pages %ld\n", offlined_pages);
/* reset pagetype flags and makes migrate type to be MOVABLE */
undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
/* removal success */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 80e4adb4c360..63a59864a21d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7754,7 +7754,7 @@ void zone_pcp_reset(struct zone *zone)
* All pages in the range must be in a single zone and isolated
* before calling this.
*/
-void
+unsigned long
__offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
{
struct page *page;
@@ -7762,12 +7762,15 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
unsigned int order, i;
unsigned long pfn;
unsigned long flags;
+ unsigned long offlined_pages = 0;
+
/* find the first valid pfn */
for (pfn = start_pfn; pfn < end_pfn; pfn++)
if (pfn_valid(pfn))
break;
if (pfn == end_pfn)
- return;
+ return offlined_pages;
+
offline_mem_sections(pfn, end_pfn);
zone = page_zone(pfn_to_page(pfn));
spin_lock_irqsave(&zone->lock, flags);
@@ -7785,12 +7788,14 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
if (unlikely(!PageBuddy(page) && PageHWPoison(page))) {
pfn++;
SetPageReserved(page);
+ offlined_pages++;
continue;
}
BUG_ON(page_count(page));
BUG_ON(!PageBuddy(page));
order = page_order(page);
+ offlined_pages += 1 << order;
#ifdef CONFIG_DEBUG_VM
pr_info("remove from free list %lx %d %lx\n",
pfn, 1 << order, end_pfn);
@@ -7803,6 +7808,8 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
pfn += (1 << order);
}
spin_unlock_irqrestore(&zone->lock, flags);
+
+ return offlined_pages;
}
#endif
--
2.13.2
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-26 13:50 +0200 |
| Subject | Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory |
| Message-ID | <u7sZc-8do-19@gated-at.bofh.it> |
| In reply to | #1696888 |
On Wed 26-07-17 10:33:28, Michal Hocko wrote: > The patches is based on the current mmotm tree (mmotm-2017-07-12-15-11) Btw. the patchset is also git://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git branch attempts/memmap-in-section-hotplug -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Jerome Glisse <jglisse@redhat.com> |
|---|---|
| Date | 2017-07-26 23:10 +0200 |
| Subject | Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory |
| Message-ID | <u7BJ8-5vg-29@gated-at.bofh.it> |
| In reply to | #1696888 |
On Wed, Jul 26, 2017 at 10:33:28AM +0200, Michal Hocko wrote:
> Hi,
> this is another step to make the memory hotplug more usable. The primary
> goal of this patchset is to reduce memory overhead of the hot added
> memory (at least for SPARSE_VMEMMAP memory model). Currently we use
> kmalloc to poppulate memmap (struct page array) which has two main
> drawbacks a) it consumes an additional memory until the hotadded memory
> itslef is onlined and b) memmap might end up on a different numa node
> which is especially true for movable_node configuration.
>
> a) is problem especially for memory hotplug based memory "ballooning"
> solutions when the delay between physical memory hotplug and the
> onlining can lead to OOM and that led to introduction of hacks like auto
> onlining (see 31bc3858ea3e ("memory-hotplug: add automatic onlining
> policy for the newly added memory")).
> b) can have performance drawbacks.
>
> One way to mitigate both issues is to simply allocate memmap array
> (which is the largest memory footprint of the physical memory hotplug)
> from the hotadded memory itself. VMEMMAP memory model allows us to map
> any pfn range so the memory doesn't need to be online to be usable
> for the array. See patch 3 for more details. In short I am reusing an
> existing vmem_altmap which wants to achieve the same thing for nvdim
> device memory.
>
> I am sending this as an RFC because this has seen only a very limited
> testing and I am mostly interested about opinions on the chosen
> approach. I had to touch some arch code and I have no idea whether my
> changes make sense there (especially ppc). Therefore I would highly
> appreciate arch maintainers to check patch 2.
>
> Patches 4 and 5 should be straightforward cleanups.
>
> There is also one potential drawback, though. If somebody uses memory
> hotplug for 1G (gigantic) hugetlb pages then this scheme will not work
> for them obviously because each memory section will contain 2MB reserved
> area. I am not really sure somebody does that and how reliable that
> can work actually. Nevertheless, I _believe_ that onlining more memory
> into virtual machines is much more common usecase. Anyway if there ever
> is a strong demand for such a usecase we have basically 3 options a)
> enlarge memory sections b) enhance altmap allocation strategy and reuse
> low memory sections to host memmaps of other sections on the same NUMA
> node c) have the memmap allocation strategy configurable to fallback to
> the current allocation.
>
> Are there any other concerns, ideas, comments?
>
This does not seems to be an opt-in change ie if i am reading patch 3
correctly if an altmap is not provided to __add_pages() you fallback
to allocating from begining of zone. This will not work with HMM ie
device private memory. So at very least i would like to see some way
to opt-out of this. Maybe a new argument like bool forbid_altmap ?
Cheers,
Jérôme
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-27 09:00 +0200 |
| Subject | Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory |
| Message-ID | <u7KW5-2LK-7@gated-at.bofh.it> |
| In reply to | #1697562 |
On Wed 26-07-17 17:06:59, Jerome Glisse wrote: [...] > This does not seems to be an opt-in change ie if i am reading patch 3 > correctly if an altmap is not provided to __add_pages() you fallback > to allocating from begining of zone. This will not work with HMM ie > device private memory. So at very least i would like to see some way > to opt-out of this. Maybe a new argument like bool forbid_altmap ? OK, I see! I will think about how to make a sane api for that. Thanks! -- Michal Hocko SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-28 14:20 +0200 |
| Subject | Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory |
| Message-ID | <u8cpj-3E3-3@gated-at.bofh.it> |
| In reply to | #1697755 |
On Thu 27-07-17 08:56:52, Michal Hocko wrote:
> On Wed 26-07-17 17:06:59, Jerome Glisse wrote:
> [...]
> > This does not seems to be an opt-in change ie if i am reading patch 3
> > correctly if an altmap is not provided to __add_pages() you fallback
> > to allocating from begining of zone. This will not work with HMM ie
> > device private memory. So at very least i would like to see some way
> > to opt-out of this. Maybe a new argument like bool forbid_altmap ?
>
> OK, I see! I will think about how to make a sane api for that.
This is what I came up with. s390 guys mentioned that I cannot simply
use the new range at this stage yet. This will need probably some other
changes but I guess we want an opt-in approach with an arch veto in general.
So what do you think about the following? Only x86 is update now and I
will split it into two parts but the idea should be clear at least.
---
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e4f749e5652f..a4a29af28bcf 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -772,7 +772,8 @@ static void update_end_of_memory_vars(u64 start, u64 size)
}
}
-int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
+int arch_add_memory(int nid, u64 start, u64 size,
+ struct mhp_restrictions *restrictions)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
@@ -780,7 +781,9 @@ int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock)
init_memory_mapping(start, start + size);
- ret = __add_pages(nid, start_pfn, nr_pages, want_memblock);
+ /* newly hotadded memory range is ready to be used for the memmap */
+ restrictions->flags |= MHP_RANGE_ACCESSIBLE;
+ ret = __add_pages(nid, start_pfn, nr_pages, restrictions);
WARN_ON_ONCE(ret);
/* update max_pfn, max_low_pfn and high_memory */
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index f2636ad2d00f..928d93e2a555 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -129,9 +129,29 @@ extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);
#endif /* CONFIG_MEMORY_HOTREMOVE */
+/*
+ * Do we want sysfs memblock files created. This will allow userspace to online
+ * and offline memory explicitly. Lack of this bit means that the caller has to
+ * call move_pfn_range_to_zone to finish the initialization.
+ */
+#define MHP_MEMBLOCK_API 1<<0
+
+/*
+ * Is the hotadded memory accessible directly or it needs a special handling.
+ * We will try to allocate the memmap for the range from within the added memory
+ * if the bit is set.
+ */
+#define MHP_RANGE_ACCESSIBLE 1<<1
+
+/* Restrictions for the memory hotplug */
+struct mhp_restrictions {
+ unsigned long flags; /* MHP_ flags */
+ struct vmem_altmap *altmap; /* use this alternative allocatro for memmaps */
+};
+
/* reasonably generic interface to expand the physical pages */
extern int __add_pages(int nid, unsigned long start_pfn,
- unsigned long nr_pages, bool want_memblock);
+ unsigned long nr_pages, struct mhp_restrictions *restrictions);
#ifdef CONFIG_NUMA
extern int memory_add_physaddr_to_nid(u64 start);
@@ -306,7 +326,8 @@ extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
void *arg, int (*func)(struct memory_block *, void *));
extern int add_memory(int nid, u64 start, u64 size);
extern int add_memory_resource(int nid, struct resource *resource, bool online);
-extern int arch_add_memory(int nid, u64 start, u64 size, bool want_memblock);
+extern int arch_add_memory(int nid, u64 start, u64 size,
+ struct mhp_restrictions *restrictions);
extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);
extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
diff --git a/kernel/memremap.c b/kernel/memremap.c
index a72eb5932d2f..cf0998cfcb13 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -286,6 +286,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
struct dev_pagemap *pgmap;
struct page_map *page_map;
int error, nid, is_ram;
+ struct mhp_restrictions restrictions = {};
unsigned long pfn;
align_start = res->start & ~(SECTION_SIZE - 1);
@@ -357,8 +358,11 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
if (error)
goto err_pfn_remap;
+ /* We do not want any optional features only our own memmap */
+ restrictions.altmap = to_vmem_altmap((unsigned long) pfn_to_page(phys_start_pfn));
+
mem_hotplug_begin();
- error = arch_add_memory(nid, align_start, align_size, false);
+ error = arch_add_memory(nid, align_start, align_size, &restrictions);
if (!error)
move_pfn_range_to_zone(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
align_start >> PAGE_SHIFT,
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 19037d0191e5..9d11c3b5b448 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -287,12 +287,13 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
* add the new pages.
*/
int __ref __add_pages(int nid, unsigned long phys_start_pfn,
- unsigned long nr_pages, bool want_memblock)
+ unsigned long nr_pages,
+ struct mhp_restrictions *restrictions)
{
unsigned long i;
int err = 0;
int start_sec, end_sec;
- struct vmem_altmap *altmap;
+ struct vmem_altmap *altmap = restrictions->altmap;
struct vmem_altmap __section_altmap = {.base_pfn = phys_start_pfn};
/* during initialize mem_map, align hot-added range to section */
@@ -301,10 +302,9 @@ int __ref __add_pages(int nid, unsigned long phys_start_pfn,
/*
* Check device specific altmap and fallback to allocating from the
- * begining of the section otherwise
+ * begining of the added range otherwise
*/
- altmap = to_vmem_altmap((unsigned long) pfn_to_page(phys_start_pfn));
- if (!altmap) {
+ if (!altmap && restrictions->flags & MHP_RANGE_ACCESSIBLE) {
__section_altmap.free = nr_pages;
__section_altmap.flush_alloc_pfns = mark_vmemmap_pages;
altmap = &__section_altmap;
@@ -324,7 +324,9 @@ int __ref __add_pages(int nid, unsigned long phys_start_pfn,
}
for (i = start_sec; i <= end_sec; i++) {
- err = __add_section(nid, section_nr_to_pfn(i), want_memblock, altmap);
+ err = __add_section(nid, section_nr_to_pfn(i),
+ restrictions->flags & MHP_MEMBLOCK_API,
+ altmap);
/*
* EEXIST is finally dealt with by ioresource collision
@@ -1160,6 +1162,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
bool new_pgdat;
bool new_node;
int ret;
+ struct mhp_restrictions restrictions = {};
start = res->start;
size = resource_size(res);
@@ -1191,8 +1194,10 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
goto error;
}
+ restrictions.flags = MHP_MEMBLOCK_API;
+
/* call arch's memory hotadd */
- ret = arch_add_memory(nid, start, size, true);
+ ret = arch_add_memory(nid, start, size, &restrictions);
if (ret < 0)
goto error;
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2017-07-28 14:10 +0200 |
| Subject | Re: [RFC PATCH 0/5] mm, memory_hotplug: allocate memmap from hotadded memory |
| Message-ID | <u8cfD-3AM-1@gated-at.bofh.it> |
| In reply to | #1696888 |
On Wed 26-07-17 10:33:28, Michal Hocko wrote: [...] > There is also one potential drawback, though. If somebody uses memory > hotplug for 1G (gigantic) hugetlb pages then this scheme will not work > for them obviously because each memory section will contain 2MB reserved > area. Actually I am wrong here. It is not each section in general. I have completely forgot that we do large memblocks on x86_64 with a lot of memory and then we hotadd 2GB memblocks and the altmap will allocate from the beginign of the _memblock_ and so all the memmaps will end up in the first memory section. -- Michal Hocko SUSE Labs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web