Skip to content

Commit 658922e

Browse files
committed
libnvdimm, pfn: fix memmap reservation sizing
When configuring a pfn-device instance to allocate the memmap array it needs to account for the fact that vmemmap_populate_hugepages() allocates struct page blocks in HPAGE_SIZE chunks. We need to align the reserved area size to 2MB otherwise arch_add_memory() runs out of memory while establishing the memmap: WARNING: CPU: 0 PID: 496 at arch/x86/mm/init_64.c:704 arch_add_memory+0xe7/0xf0 [..] Call Trace: [<ffffffff8148bdb3>] dump_stack+0x85/0xc2 [<ffffffff810a749b>] __warn+0xcb/0xf0 [<ffffffff810a75cd>] warn_slowpath_null+0x1d/0x20 [<ffffffff8106a497>] arch_add_memory+0xe7/0xf0 [<ffffffff811d2097>] devm_memremap_pages+0x287/0x450 [<ffffffff811d1ffa>] ? devm_memremap_pages+0x1ea/0x450 [<ffffffffa0000298>] __wrap_devm_memremap_pages+0x58/0x70 [nfit_test_iomap] [<ffffffffa0047a58>] pmem_attach_disk+0x318/0x420 [nd_pmem] [<ffffffffa0047bcf>] nd_pmem_probe+0x6f/0x90 [nd_pmem] [<ffffffffa0009469>] nvdimm_bus_probe+0x69/0x110 [libnvdimm] [..] ndbus0: nd_pmem.probe(pfn3.0) = -12 nd_pmem: probe of pfn3.0 failed with error -12 libndctl: ndctl_pfn_enable: pfn3.0: failed to enable Reported-by: Namratha Kothapalli <[email protected]> Cc: <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 02da2d7 commit 658922e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/nvdimm/pmem.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,17 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
397397
*/
398398
start += start_pad;
399399
npfns = (pmem->size - start_pad - end_trunc - SZ_8K) / SZ_4K;
400-
if (nd_pfn->mode == PFN_MODE_PMEM)
401-
offset = ALIGN(start + SZ_8K + 64 * npfns, nd_pfn->align)
400+
if (nd_pfn->mode == PFN_MODE_PMEM) {
401+
unsigned long memmap_size;
402+
403+
/*
404+
* vmemmap_populate_hugepages() allocates the memmap array in
405+
* HPAGE_SIZE chunks.
406+
*/
407+
memmap_size = ALIGN(64 * npfns, HPAGE_SIZE);
408+
offset = ALIGN(start + SZ_8K + memmap_size, nd_pfn->align)
402409
- start;
403-
else if (nd_pfn->mode == PFN_MODE_RAM)
410+
} else if (nd_pfn->mode == PFN_MODE_RAM)
404411
offset = ALIGN(start + SZ_8K, nd_pfn->align) - start;
405412
else
406413
goto err;

0 commit comments

Comments
 (0)