Skip to content

Commit 9055c64

Browse files
committed
Merge tag 'memblock-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
Pull memblock updates from Mike Rapoport: - improve debuggability of reserve_mem kernel parameter handling with print outs in case of a failure and debugfs info showing what was actually reserved - Make memblock_free_late() and free_reserved_area() use the same core logic for freeing the memory to buddy and ensure it takes care of updating memblock arrays when ARCH_KEEP_MEMBLOCK is enabled. * tag 'memblock-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock: x86/alternative: delay freeing of smp_locks section memblock: warn when freeing reserved memory before memory map is initialized memblock, treewide: make memblock_free() handle late freeing memblock: make free_reserved_area() update memblock if ARCH_KEEP_MEMBLOCK=y memblock: extract page freeing from free_reserved_area() into a helper memblock: make free_reserved_area() more robust mm: move free_reserved_area() to mm/memblock.c powerpc: opal-core: pair alloc_pages_exact() with free_pages_exact() powerpc: fadump: pair alloc_pages_exact() with free_pages_exact() memblock: reserve_mem: fix end caclulation in reserve_mem_release_by_name() memblock: move reserve_bootmem_range() to memblock.c and make it static memblock: Add reserve_mem debugfs info memblock: Print out errors on reserve_mem parser
2 parents fba676b + d575951 commit 9055c64

25 files changed

Lines changed: 271 additions & 198 deletions

File tree

arch/arm64/mm/init.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@ void free_initmem(void)
397397
WARN_ON(!IS_ALIGNED((unsigned long)lm_init_begin, PAGE_SIZE));
398398
WARN_ON(!IS_ALIGNED((unsigned long)lm_init_end, PAGE_SIZE));
399399

400-
/* Delete __init region from memblock.reserved. */
401-
memblock_free(lm_init_begin, lm_init_end - lm_init_begin);
402-
403400
free_reserved_area(lm_init_begin, lm_init_end,
404401
POISON_FREE_INITMEM, "unused kernel");
405402
/*

arch/powerpc/kernel/fadump.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -775,24 +775,12 @@ void __init fadump_update_elfcore_header(char *bufp)
775775

776776
static void *__init fadump_alloc_buffer(unsigned long size)
777777
{
778-
unsigned long count, i;
779-
struct page *page;
780-
void *vaddr;
781-
782-
vaddr = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
783-
if (!vaddr)
784-
return NULL;
785-
786-
count = PAGE_ALIGN(size) / PAGE_SIZE;
787-
page = virt_to_page(vaddr);
788-
for (i = 0; i < count; i++)
789-
mark_page_reserved(page + i);
790-
return vaddr;
778+
return alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
791779
}
792780

793781
static void fadump_free_buffer(unsigned long vaddr, unsigned long size)
794782
{
795-
free_reserved_area((void *)vaddr, (void *)(vaddr + size), -1, NULL);
783+
free_pages_exact((void *)vaddr, size);
796784
}
797785

798786
s32 __init fadump_setup_cpu_notes_buf(u32 num_cpus)

arch/powerpc/platforms/powernv/opal-core.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ static int __init create_opalcore(void)
303303
struct device_node *dn;
304304
struct opalcore *new;
305305
loff_t opalcore_off;
306-
struct page *page;
307306
Elf64_Phdr *phdr;
308307
Elf64_Ehdr *elf;
309308
int i, ret;
@@ -328,11 +327,6 @@ static int __init create_opalcore(void)
328327
oc_conf->opalcorebuf_sz = 0;
329328
return -ENOMEM;
330329
}
331-
count = oc_conf->opalcorebuf_sz / PAGE_SIZE;
332-
page = virt_to_page(oc_conf->opalcorebuf);
333-
for (i = 0; i < count; i++)
334-
mark_page_reserved(page + i);
335-
336330
pr_debug("opalcorebuf = 0x%llx\n", (u64)oc_conf->opalcorebuf);
337331

338332
/* Read OPAL related device-tree entries */
@@ -437,10 +431,7 @@ static void opalcore_cleanup(void)
437431

438432
/* free the buffer used for setting up OPAL core */
439433
if (oc_conf->opalcorebuf) {
440-
void *end = (void *)((u64)oc_conf->opalcorebuf +
441-
oc_conf->opalcorebuf_sz);
442-
443-
free_reserved_area(oc_conf->opalcorebuf, end, -1, NULL);
434+
free_pages_exact(oc_conf->opalcorebuf, oc_conf->opalcorebuf_sz);
444435
oc_conf->opalcorebuf = NULL;
445436
oc_conf->opalcorebuf_sz = 0;
446437
}

arch/sparc/kernel/mdesc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,12 @@ static struct mdesc_handle * __init mdesc_memblock_alloc(unsigned int mdesc_size
183183
static void __init mdesc_memblock_free(struct mdesc_handle *hp)
184184
{
185185
unsigned int alloc_size;
186-
unsigned long start;
187186

188187
BUG_ON(refcount_read(&hp->refcnt) != 0);
189188
BUG_ON(!list_empty(&hp->list));
190189

191190
alloc_size = PAGE_ALIGN(hp->handle_size);
192-
start = __pa(hp);
193-
memblock_free_late(start, alloc_size);
191+
memblock_free(hp, alloc_size);
194192
}
195193

196194
static struct mdesc_mem_ops memblock_mdesc_ops = {

arch/x86/kernel/alternative.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,19 +2448,31 @@ void __init alternative_instructions(void)
24482448
__smp_locks, __smp_locks_end,
24492449
_text, _etext);
24502450
}
2451+
#endif
24512452

2453+
restart_nmi();
2454+
alternatives_patched = 1;
2455+
2456+
alt_reloc_selftest();
2457+
}
2458+
2459+
#ifdef CONFIG_SMP
2460+
/*
2461+
* With CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled we can free_init_pages() only
2462+
* after the deferred initialization of the memory map is complete.
2463+
*/
2464+
static int __init free_smp_locks(void)
2465+
{
24522466
if (!uniproc_patched || num_possible_cpus() == 1) {
24532467
free_init_pages("SMP alternatives",
24542468
(unsigned long)__smp_locks,
24552469
(unsigned long)__smp_locks_end);
24562470
}
2457-
#endif
24582471

2459-
restart_nmi();
2460-
alternatives_patched = 1;
2461-
2462-
alt_reloc_selftest();
2472+
return 0;
24632473
}
2474+
arch_initcall(free_smp_locks);
2475+
#endif
24642476

24652477
/**
24662478
* text_poke_early - Update instructions on a live kernel at boot time

arch/x86/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ int __init ima_free_kexec_buffer(void)
426426
if (!ima_kexec_buffer_size)
427427
return -ENOENT;
428428

429-
memblock_free_late(ima_kexec_buffer_phys,
429+
memblock_phys_free(ima_kexec_buffer_phys,
430430
ima_kexec_buffer_size);
431431

432432
ima_kexec_buffer_phys = 0;

arch/x86/platform/efi/memmap.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ static
3434
void __init __efi_memmap_free(u64 phys, unsigned long size, unsigned long flags)
3535
{
3636
if (flags & EFI_MEMMAP_MEMBLOCK) {
37-
if (slab_is_available())
38-
memblock_free_late(phys, size);
39-
else
40-
memblock_phys_free(phys, size);
37+
memblock_phys_free(phys, size);
4138
} else if (flags & EFI_MEMMAP_SLAB) {
4239
struct page *p = pfn_to_page(PHYS_PFN(phys));
4340
unsigned int order = get_order(size);

arch/x86/platform/efi/quirks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void __init efi_reserve_boot_services(void)
372372
* doesn't make sense as far as the firmware is
373373
* concerned, but it does provide us with a way to tag
374374
* those regions that must not be paired with
375-
* memblock_free_late().
375+
* memblock_phys_free().
376376
*/
377377
md->attribute |= EFI_MEMORY_RUNTIME;
378378
}

drivers/firmware/efi/apple-properties.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static int __init map_properties(void)
226226
*/
227227
data->len = 0;
228228
memunmap(data);
229-
memblock_free_late(pa_data + sizeof(*data), data_len);
229+
memblock_phys_free(pa_data + sizeof(*data), data_len);
230230

231231
return ret;
232232
}

drivers/of/kexec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int __init ima_free_kexec_buffer(void)
175175
if (ret)
176176
return ret;
177177

178-
memblock_free_late(addr, size);
178+
memblock_phys_free(addr, size);
179179
return 0;
180180
}
181181
#endif

0 commit comments

Comments
 (0)