Commit 87ce9e83 authored by Mike Rapoport (Microsoft)'s avatar Mike Rapoport (Microsoft)
Browse files

memblock, treewide: make memblock_free() handle late freeing

It shouldn't be responsibility of memblock users to detect if they free
memory allocated from memblock late and should use memblock_free_late().

Make memblock_free() and memblock_phys_free() take care of late memory
freeing and drop memblock_free_late().

Link: https://patch.msgid.link/20260323074836.3653702-9-rppt@kernel.org


Signed-off-by: default avatarMike Rapoport (Microsoft) <rppt@kernel.org>
parent b2129a39
Loading
Loading
Loading
Loading
+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 = {
+1 −1
Original line number Diff line number Diff line
@@ -426,7 +426,7 @@ int __init ima_free_kexec_buffer(void)
	if (!ima_kexec_buffer_size)
		return -ENOENT;

	memblock_free_late(ima_kexec_buffer_phys,
	memblock_phys_free(ima_kexec_buffer_phys,
			   ima_kexec_buffer_size);

	ima_kexec_buffer_phys = 0;
+1 −4
Original line number Diff line number Diff line
@@ -34,9 +34,6 @@ static
void __init __efi_memmap_free(u64 phys, unsigned long size, unsigned long flags)
{
	if (flags & EFI_MEMMAP_MEMBLOCK) {
		if (slab_is_available())
			memblock_free_late(phys, size);
		else
		memblock_phys_free(phys, size);
	} else if (flags & EFI_MEMMAP_SLAB) {
		struct page *p = pfn_to_page(PHYS_PFN(phys));
+1 −1
Original line number Diff line number Diff line
@@ -372,7 +372,7 @@ void __init efi_reserve_boot_services(void)
		 * doesn't make sense as far as the firmware is
		 * concerned, but it does provide us with a way to tag
		 * those regions that must not be paired with
		 * memblock_free_late().
		 * memblock_phys_free().
		 */
		md->attribute |= EFI_MEMORY_RUNTIME;
	}
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ static int __init map_properties(void)
		 */
		data->len = 0;
		memunmap(data);
		memblock_free_late(pa_data + sizeof(*data), data_len);
		memblock_phys_free(pa_data + sizeof(*data), data_len);

		return ret;
	}
Loading