Commit 9055c645 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents fba676bd d5759519
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -397,9 +397,6 @@ void free_initmem(void)
	WARN_ON(!IS_ALIGNED((unsigned long)lm_init_begin, PAGE_SIZE));
	WARN_ON(!IS_ALIGNED((unsigned long)lm_init_end, PAGE_SIZE));

	/* Delete __init region from memblock.reserved. */
	memblock_free(lm_init_begin, lm_init_end - lm_init_begin);

	free_reserved_area(lm_init_begin, lm_init_end,
			   POISON_FREE_INITMEM, "unused kernel");
	/*
+2 −14
Original line number Diff line number Diff line
@@ -775,24 +775,12 @@ void __init fadump_update_elfcore_header(char *bufp)

static void *__init fadump_alloc_buffer(unsigned long size)
{
	unsigned long count, i;
	struct page *page;
	void *vaddr;

	vaddr = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
	if (!vaddr)
		return NULL;

	count = PAGE_ALIGN(size) / PAGE_SIZE;
	page = virt_to_page(vaddr);
	for (i = 0; i < count; i++)
		mark_page_reserved(page + i);
	return vaddr;
	return  alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
}

static void fadump_free_buffer(unsigned long vaddr, unsigned long size)
{
	free_reserved_area((void *)vaddr, (void *)(vaddr + size), -1, NULL);
	free_pages_exact((void *)vaddr, size);
}

s32 __init fadump_setup_cpu_notes_buf(u32 num_cpus)
+1 −10
Original line number Diff line number Diff line
@@ -303,7 +303,6 @@ static int __init create_opalcore(void)
	struct device_node *dn;
	struct opalcore *new;
	loff_t opalcore_off;
	struct page *page;
	Elf64_Phdr *phdr;
	Elf64_Ehdr *elf;
	int i, ret;
@@ -328,11 +327,6 @@ static int __init create_opalcore(void)
		oc_conf->opalcorebuf_sz = 0;
		return -ENOMEM;
	}
	count = oc_conf->opalcorebuf_sz / PAGE_SIZE;
	page = virt_to_page(oc_conf->opalcorebuf);
	for (i = 0; i < count; i++)
		mark_page_reserved(page + i);

	pr_debug("opalcorebuf = 0x%llx\n", (u64)oc_conf->opalcorebuf);

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

	/* free the buffer used for setting up OPAL core */
	if (oc_conf->opalcorebuf) {
		void *end = (void *)((u64)oc_conf->opalcorebuf +
				     oc_conf->opalcorebuf_sz);

		free_reserved_area(oc_conf->opalcorebuf, end, -1, NULL);
		free_pages_exact(oc_conf->opalcorebuf, oc_conf->opalcorebuf_sz);
		oc_conf->opalcorebuf = NULL;
		oc_conf->opalcorebuf_sz = 0;
	}
+1 −3
Original line number Diff line number Diff line
@@ -183,14 +183,12 @@ static struct mdesc_handle * __init mdesc_memblock_alloc(unsigned int mdesc_size
static void __init mdesc_memblock_free(struct mdesc_handle *hp)
{
	unsigned int alloc_size;
	unsigned long start;

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

	alloc_size = PAGE_ALIGN(hp->handle_size);
	start = __pa(hp);
	memblock_free_late(start, alloc_size);
	memblock_free(hp, alloc_size);
}

static struct mdesc_mem_ops memblock_mdesc_ops = {
+17 −5
Original line number Diff line number Diff line
@@ -2448,19 +2448,31 @@ void __init alternative_instructions(void)
					    __smp_locks, __smp_locks_end,
					    _text, _etext);
	}
#endif

	restart_nmi();
	alternatives_patched = 1;

	alt_reloc_selftest();
}

#ifdef CONFIG_SMP
/*
 * With CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled we can free_init_pages() only
 * after the deferred initialization of the memory map is complete.
 */
static int __init free_smp_locks(void)
{
	if (!uniproc_patched || num_possible_cpus() == 1) {
		free_init_pages("SMP alternatives",
				(unsigned long)__smp_locks,
				(unsigned long)__smp_locks_end);
	}
#endif

	restart_nmi();
	alternatives_patched = 1;

	alt_reloc_selftest();
	return 0;
}
arch_initcall(free_smp_locks);
#endif

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