forked from Minki/linux
memblock: use memblock_free for freeing virtual pointers
Rename memblock_free_ptr() to memblock_free() and use memblock_free() when freeing a virtual pointer so that memblock_free() will be a counterpart of memblock_alloc() The callers are updated with the below semantic patch and manual addition of (void *) casting to pointers that are represented by unsigned long variables. @@ identifier vaddr; expression size; @@ ( - memblock_phys_free(__pa(vaddr), size); + memblock_free(vaddr, size); | - memblock_free_ptr(vaddr, size); + memblock_free(vaddr, size); ) [sfr@canb.auug.org.au: fixup] Link: https://lkml.kernel.org/r/20211018192940.3d1d532f@canb.auug.org.au Link: https://lkml.kernel.org/r/20210930185031.18648-7-rppt@kernel.org Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Juergen Gross <jgross@suse.com> Cc: Shahab Vahedi <Shahab.Vahedi@synopsys.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3ecc68349b
commit
4421cca0a3
@ -233,8 +233,7 @@ albacore_init_arch(void)
|
||||
unsigned long size;
|
||||
|
||||
size = initrd_end - initrd_start;
|
||||
memblock_phys_free(__pa(initrd_start),
|
||||
PAGE_ALIGN(size));
|
||||
memblock_free((void *)initrd_start, PAGE_ALIGN(size));
|
||||
if (!move_initrd(pci_mem))
|
||||
printk("irongate_init_arch: initrd too big "
|
||||
"(%ldK)\ndisabling initrd\n",
|
||||
|
@ -529,7 +529,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size,
|
||||
|
||||
static void __init pcpu_fc_free(void *ptr, size_t size)
|
||||
{
|
||||
memblock_phys_free(__pa(ptr), size);
|
||||
memblock_free(ptr, size);
|
||||
}
|
||||
|
||||
void __init setup_per_cpu_areas(void)
|
||||
|
@ -1095,8 +1095,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char
|
||||
|
||||
cpufeatures_setup_finished();
|
||||
|
||||
memblock_phys_free(__pa(dt_cpu_features),
|
||||
sizeof(struct dt_cpu_feature) * nr_dt_cpu_features);
|
||||
memblock_free(dt_cpu_features,
|
||||
sizeof(struct dt_cpu_feature) * nr_dt_cpu_features);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -825,7 +825,7 @@ static void __init smp_setup_pacas(void)
|
||||
set_hard_smp_processor_id(cpu, cpu_to_phys_id[cpu]);
|
||||
}
|
||||
|
||||
memblock_phys_free(__pa(cpu_to_phys_id), nr_cpu_ids * sizeof(u32));
|
||||
memblock_free(cpu_to_phys_id, nr_cpu_ids * sizeof(u32));
|
||||
cpu_to_phys_id = NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -812,7 +812,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size,
|
||||
|
||||
static void __init pcpu_free_bootmem(void *ptr, size_t size)
|
||||
{
|
||||
memblock_phys_free(__pa(ptr), size);
|
||||
memblock_free(ptr, size);
|
||||
}
|
||||
|
||||
static int pcpu_cpu_distance(unsigned int from, unsigned int to)
|
||||
|
@ -2981,7 +2981,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
|
||||
if (!phb->hose) {
|
||||
pr_err(" Can't allocate PCI controller for %pOF\n",
|
||||
np);
|
||||
memblock_phys_free(__pa(phb), sizeof(struct pnv_phb));
|
||||
memblock_free(phb, sizeof(struct pnv_phb));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,7 @@ void __init svm_swiotlb_init(void)
|
||||
return;
|
||||
|
||||
|
||||
memblock_phys_free(__pa(vstart),
|
||||
PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
|
||||
memblock_free(vstart, PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
|
||||
panic("SVM: Cannot allocate SWIOTLB buffer");
|
||||
}
|
||||
|
||||
|
@ -230,14 +230,13 @@ static void __init init_resources(void)
|
||||
|
||||
/* Clean-up any unused pre-allocated resources */
|
||||
if (res_idx >= 0)
|
||||
memblock_phys_free(__pa(mem_res),
|
||||
(res_idx + 1) * sizeof(*mem_res));
|
||||
memblock_free(mem_res, (res_idx + 1) * sizeof(*mem_res));
|
||||
return;
|
||||
|
||||
error:
|
||||
/* Better an empty resource tree than an inconsistent one */
|
||||
release_child_resources(&iomem_resource);
|
||||
memblock_phys_free(__pa(mem_res), mem_res_sz);
|
||||
memblock_free(mem_res, mem_res_sz);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1567,7 +1567,7 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size,
|
||||
|
||||
static void __init pcpu_free_bootmem(void *ptr, size_t size)
|
||||
{
|
||||
memblock_phys_free(__pa(ptr), size);
|
||||
memblock_free(ptr, size);
|
||||
}
|
||||
|
||||
static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
|
||||
|
@ -47,7 +47,7 @@ void __init mem_init(void)
|
||||
*/
|
||||
brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
|
||||
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
|
||||
memblock_phys_free(__pa(brk_end), uml_reserved - brk_end);
|
||||
memblock_free((void *)brk_end, uml_reserved - brk_end);
|
||||
uml_reserved = brk_end;
|
||||
|
||||
/* this will put all low memory onto the freelists */
|
||||
|
@ -135,7 +135,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
|
||||
|
||||
static void __init pcpu_fc_free(void *ptr, size_t size)
|
||||
{
|
||||
memblock_free_ptr(ptr, size);
|
||||
memblock_free(ptr, size);
|
||||
}
|
||||
|
||||
static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
|
||||
|
@ -49,7 +49,7 @@ static void __init kasan_populate_pmd(pmd_t *pmd, unsigned long addr,
|
||||
p = early_alloc(PMD_SIZE, nid, false);
|
||||
if (p && pmd_set_huge(pmd, __pa(p), PAGE_KERNEL))
|
||||
return;
|
||||
memblock_free_ptr(p, PMD_SIZE);
|
||||
memblock_free(p, PMD_SIZE);
|
||||
}
|
||||
|
||||
p = early_alloc(PAGE_SIZE, nid, true);
|
||||
@ -85,7 +85,7 @@ static void __init kasan_populate_pud(pud_t *pud, unsigned long addr,
|
||||
p = early_alloc(PUD_SIZE, nid, false);
|
||||
if (p && pud_set_huge(pud, __pa(p), PAGE_KERNEL))
|
||||
return;
|
||||
memblock_free_ptr(p, PUD_SIZE);
|
||||
memblock_free(p, PUD_SIZE);
|
||||
}
|
||||
|
||||
p = early_alloc(PAGE_SIZE, nid, true);
|
||||
|
@ -355,7 +355,7 @@ void __init numa_reset_distance(void)
|
||||
|
||||
/* numa_distance could be 1LU marking allocation failure, test cnt */
|
||||
if (numa_distance_cnt)
|
||||
memblock_free_ptr(numa_distance, size);
|
||||
memblock_free(numa_distance, size);
|
||||
numa_distance_cnt = 0;
|
||||
numa_distance = NULL; /* enable table creation */
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
|
||||
}
|
||||
|
||||
/* free the copied physical distance table */
|
||||
memblock_free_ptr(phys_dist, phys_size);
|
||||
memblock_free(phys_dist, phys_size);
|
||||
return;
|
||||
|
||||
no_emu:
|
||||
|
@ -1151,7 +1151,7 @@ static void __init xen_pagetable_p2m_free(void)
|
||||
xen_cleanhighmap(addr, addr + size);
|
||||
size = PAGE_ALIGN(xen_start_info->nr_pages *
|
||||
sizeof(unsigned long));
|
||||
memblock_phys_free(__pa(addr), size);
|
||||
memblock_free((void *)addr, size);
|
||||
} else {
|
||||
xen_cleanmfnmap(addr);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ static void * __ref alloc_p2m_page(void)
|
||||
static void __ref free_p2m_page(void *p)
|
||||
{
|
||||
if (unlikely(!slab_is_available())) {
|
||||
memblock_free_ptr(p, PAGE_SIZE);
|
||||
memblock_free(p, PAGE_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size,
|
||||
|
||||
static void __init pcpu_fc_free(void *ptr, size_t size)
|
||||
{
|
||||
memblock_phys_free(__pa(ptr), size);
|
||||
memblock_free(ptr, size);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
|
||||
@ -326,7 +326,7 @@ void __init numa_free_distance(void)
|
||||
size = numa_distance_cnt * numa_distance_cnt *
|
||||
sizeof(numa_distance[0]);
|
||||
|
||||
memblock_free_ptr(numa_distance, size);
|
||||
memblock_free(numa_distance, size);
|
||||
numa_distance_cnt = 0;
|
||||
numa_distance = NULL;
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ fail_msg_node:
|
||||
fail_db_node:
|
||||
of_node_put(smu->db_node);
|
||||
fail_bootmem:
|
||||
memblock_free_ptr(smu, sizeof(struct smu_device));
|
||||
memblock_free(smu, sizeof(struct smu_device));
|
||||
smu = NULL;
|
||||
fail_np:
|
||||
of_node_put(np);
|
||||
|
@ -241,7 +241,7 @@ retry:
|
||||
*/
|
||||
rc = xen_swiotlb_fixup(start, nslabs);
|
||||
if (rc) {
|
||||
memblock_phys_free(__pa(start), PAGE_ALIGN(bytes));
|
||||
memblock_free(start, PAGE_ALIGN(bytes));
|
||||
if (nslabs > 1024 && repeat--) {
|
||||
/* Min is 2MB */
|
||||
nslabs = max(1024UL, ALIGN(nslabs >> 1, IO_TLB_SEGSIZE));
|
||||
|
@ -118,7 +118,7 @@ int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
|
||||
int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
|
||||
|
||||
void memblock_free_all(void);
|
||||
void memblock_free_ptr(void *ptr, size_t size);
|
||||
void memblock_free(void *ptr, size_t size);
|
||||
void reset_node_managed_pages(pg_data_t *pgdat);
|
||||
void reset_all_zones_managed_pages(void);
|
||||
|
||||
|
@ -607,7 +607,7 @@ void __weak __init free_initrd_mem(unsigned long start, unsigned long end)
|
||||
unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE);
|
||||
unsigned long aligned_end = ALIGN(end, PAGE_SIZE);
|
||||
|
||||
memblock_phys_free(__pa(aligned_start), aligned_end - aligned_start);
|
||||
memblock_free((void *)aligned_start, aligned_end - aligned_start);
|
||||
#endif
|
||||
|
||||
free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
|
||||
|
@ -382,7 +382,7 @@ static char * __init xbc_make_cmdline(const char *key)
|
||||
ret = xbc_snprint_cmdline(new_cmdline, len + 1, root);
|
||||
if (ret < 0 || ret > len) {
|
||||
pr_err("Failed to print extra kernel cmdline.\n");
|
||||
memblock_free_ptr(new_cmdline, len + 1);
|
||||
memblock_free(new_cmdline, len + 1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -925,7 +925,7 @@ static void __init print_unknown_bootoptions(void)
|
||||
end += sprintf(end, " %s", *p);
|
||||
|
||||
pr_notice("Unknown command line parameters:%s\n", unknown_options);
|
||||
memblock_free_ptr(unknown_options, len);
|
||||
memblock_free(unknown_options, len);
|
||||
}
|
||||
|
||||
asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
|
||||
|
@ -247,7 +247,7 @@ swiotlb_init(int verbose)
|
||||
return;
|
||||
|
||||
fail_free_mem:
|
||||
memblock_phys_free(__pa(tlb), bytes);
|
||||
memblock_free(tlb, bytes);
|
||||
fail:
|
||||
pr_warn("Cannot allocate buffer");
|
||||
}
|
||||
|
@ -1166,9 +1166,9 @@ void __init setup_log_buf(int early)
|
||||
return;
|
||||
|
||||
err_free_descs:
|
||||
memblock_free_ptr(new_descs, new_descs_size);
|
||||
memblock_free(new_descs, new_descs_size);
|
||||
err_free_log_buf:
|
||||
memblock_free_ptr(new_log_buf, new_log_buf_len);
|
||||
memblock_free(new_log_buf, new_log_buf_len);
|
||||
}
|
||||
|
||||
static bool __read_mostly ignore_loglevel;
|
||||
|
@ -792,7 +792,7 @@ void __init xbc_destroy_all(void)
|
||||
xbc_data = NULL;
|
||||
xbc_data_size = 0;
|
||||
xbc_node_num = 0;
|
||||
memblock_free_ptr(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX);
|
||||
memblock_free(xbc_nodes, sizeof(struct xbc_node) * XBC_NODE_MAX);
|
||||
xbc_nodes = NULL;
|
||||
brace_index = 0;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ EXPORT_SYMBOL(free_cpumask_var);
|
||||
*/
|
||||
void __init free_bootmem_cpumask_var(cpumask_var_t mask)
|
||||
{
|
||||
memblock_phys_free(__pa(mask), cpumask_size());
|
||||
memblock_free(mask, cpumask_size());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -472,7 +472,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
|
||||
kfree(old_array);
|
||||
else if (old_array != memblock_memory_init_regions &&
|
||||
old_array != memblock_reserved_init_regions)
|
||||
memblock_free_ptr(old_array, old_alloc_size);
|
||||
memblock_free(old_array, old_alloc_size);
|
||||
|
||||
/*
|
||||
* Reserve the new array if that comes from the memblock. Otherwise, we
|
||||
@ -796,14 +796,14 @@ int __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
|
||||
}
|
||||
|
||||
/**
|
||||
* memblock_free_ptr - free boot memory allocation
|
||||
* memblock_free - free boot memory allocation
|
||||
* @ptr: starting address of the boot memory allocation
|
||||
* @size: size of the boot memory block in bytes
|
||||
*
|
||||
* Free boot memory block previously allocated by memblock_alloc_xx() API.
|
||||
* The freeing memory will not be released to the buddy allocator.
|
||||
*/
|
||||
void __init_memblock memblock_free_ptr(void *ptr, size_t size)
|
||||
void __init_memblock memblock_free(void *ptr, size_t size)
|
||||
{
|
||||
if (ptr)
|
||||
memblock_phys_free(__pa(ptr), size);
|
||||
|
@ -2472,7 +2472,7 @@ struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
|
||||
*/
|
||||
void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai)
|
||||
{
|
||||
memblock_phys_free(__pa(ai), ai->__ai_size);
|
||||
memblock_free(ai, ai->__ai_size);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3134,7 +3134,7 @@ out_free_areas:
|
||||
out_free:
|
||||
pcpu_free_alloc_info(ai);
|
||||
if (areas)
|
||||
memblock_phys_free(__pa(areas), areas_size);
|
||||
memblock_free(areas, areas_size);
|
||||
return rc;
|
||||
}
|
||||
#endif /* BUILD_EMBED_FIRST_CHUNK */
|
||||
@ -3256,7 +3256,7 @@ enomem:
|
||||
free_fn(page_address(pages[j]), PAGE_SIZE);
|
||||
rc = -ENOMEM;
|
||||
out_free_ar:
|
||||
memblock_phys_free(__pa(pages), pages_size);
|
||||
memblock_free(pages, pages_size);
|
||||
pcpu_free_alloc_info(ai);
|
||||
return rc;
|
||||
}
|
||||
@ -3286,7 +3286,7 @@ static void * __init pcpu_dfl_fc_alloc(unsigned int cpu, size_t size,
|
||||
|
||||
static void __init pcpu_dfl_fc_free(void *ptr, size_t size)
|
||||
{
|
||||
memblock_phys_free(__pa(ptr), size);
|
||||
memblock_free(ptr, size);
|
||||
}
|
||||
|
||||
void __init setup_per_cpu_areas(void)
|
||||
|
@ -451,7 +451,7 @@ static void *sparsemap_buf_end __meminitdata;
|
||||
static inline void __meminit sparse_buffer_free(unsigned long size)
|
||||
{
|
||||
WARN_ON(!sparsemap_buf || size == 0);
|
||||
memblock_phys_free(__pa(sparsemap_buf), size);
|
||||
memblock_free(sparsemap_buf, size);
|
||||
}
|
||||
|
||||
static void __init sparse_buffer_init(unsigned long size, int nid)
|
||||
|
Loading…
Reference in New Issue
Block a user