Skip to content

Commit 6c7835f

Browse files
rppttorvalds
authored andcommitted
mm: nobootmem: remove bootmem allocation APIs
The bootmem compatibility APIs are not used and can be removed. Link: http://lkml.kernel.org/r/1536927045-23536-23-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Jonas Bonn <jonas@southpole.se> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ley Foon Tan <lftan@altera.com> Cc: Mark Salter <msalter@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Serge Semin <fancer.lancer@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2a5bda5 commit 6c7835f

File tree

2 files changed

+0
-271
lines changed

2 files changed

+0
-271
lines changed

include/linux/bootmem.h

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -36,60 +36,13 @@ extern void free_bootmem_node(pg_data_t *pgdat,
3636
extern void free_bootmem(unsigned long physaddr, unsigned long size);
3737
extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
3838

39-
extern void *__alloc_bootmem(unsigned long size,
40-
unsigned long align,
41-
unsigned long goal);
42-
extern void *__alloc_bootmem_nopanic(unsigned long size,
43-
unsigned long align,
44-
unsigned long goal) __malloc;
45-
extern void *__alloc_bootmem_node(pg_data_t *pgdat,
46-
unsigned long size,
47-
unsigned long align,
48-
unsigned long goal) __malloc;
49-
void *__alloc_bootmem_node_high(pg_data_t *pgdat,
50-
unsigned long size,
51-
unsigned long align,
52-
unsigned long goal) __malloc;
53-
extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
54-
unsigned long size,
55-
unsigned long align,
56-
unsigned long goal) __malloc;
57-
void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
58-
unsigned long size,
59-
unsigned long align,
60-
unsigned long goal,
61-
unsigned long limit) __malloc;
62-
extern void *__alloc_bootmem_low(unsigned long size,
63-
unsigned long align,
64-
unsigned long goal) __malloc;
65-
6639
/* We are using top down, so it is safe to use 0 here */
6740
#define BOOTMEM_LOW_LIMIT 0
6841

6942
#ifndef ARCH_LOW_ADDRESS_LIMIT
7043
#define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
7144
#endif
7245

73-
#define alloc_bootmem(x) \
74-
__alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
75-
#define alloc_bootmem_align(x, align) \
76-
__alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT)
77-
#define alloc_bootmem_pages(x) \
78-
__alloc_bootmem(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
79-
#define alloc_bootmem_pages_nopanic(x) \
80-
__alloc_bootmem_nopanic(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
81-
#define alloc_bootmem_node(pgdat, x) \
82-
__alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
83-
#define alloc_bootmem_node_nopanic(pgdat, x) \
84-
__alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
85-
#define alloc_bootmem_pages_node(pgdat, x) \
86-
__alloc_bootmem_node(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
87-
88-
#define alloc_bootmem_low(x) \
89-
__alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
90-
#define alloc_bootmem_low_pages(x) \
91-
__alloc_bootmem_low(x, PAGE_SIZE, 0)
92-
9346
/* FIXME: use MEMBLOCK_ALLOC_* variants here */
9447
#define BOOTMEM_ALLOC_ACCESSIBLE 0
9548
#define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0)

mm/nobootmem.c

Lines changed: 0 additions & 224 deletions
Original file line numberDiff line numberDiff line change
@@ -33,41 +33,6 @@ unsigned long min_low_pfn;
3333
unsigned long max_pfn;
3434
unsigned long long max_possible_pfn;
3535

36-
static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
37-
u64 goal, u64 limit)
38-
{
39-
void *ptr;
40-
u64 addr;
41-
enum memblock_flags flags = choose_memblock_flags();
42-
43-
if (limit > memblock.current_limit)
44-
limit = memblock.current_limit;
45-
46-
again:
47-
addr = memblock_find_in_range_node(size, align, goal, limit, nid,
48-
flags);
49-
if (!addr && (flags & MEMBLOCK_MIRROR)) {
50-
flags &= ~MEMBLOCK_MIRROR;
51-
pr_warn("Could not allocate %pap bytes of mirrored memory\n",
52-
&size);
53-
goto again;
54-
}
55-
if (!addr)
56-
return NULL;
57-
58-
if (memblock_reserve(addr, size))
59-
return NULL;
60-
61-
ptr = phys_to_virt(addr);
62-
memset(ptr, 0, size);
63-
/*
64-
* The min_count is set to 0 so that bootmem allocated blocks
65-
* are never reported as leaks.
66-
*/
67-
kmemleak_alloc(ptr, size, 0, 0);
68-
return ptr;
69-
}
70-
7136
/**
7237
* free_bootmem_late - free bootmem pages directly to page allocator
7338
* @addr: starting address of the range
@@ -215,192 +180,3 @@ void __init free_bootmem(unsigned long addr, unsigned long size)
215180
{
216181
memblock_free(addr, size);
217182
}
218-
219-
static void * __init ___alloc_bootmem_nopanic(unsigned long size,
220-
unsigned long align,
221-
unsigned long goal,
222-
unsigned long limit)
223-
{
224-
void *ptr;
225-
226-
if (WARN_ON_ONCE(slab_is_available()))
227-
return kzalloc(size, GFP_NOWAIT);
228-
229-
restart:
230-
231-
ptr = __alloc_memory_core_early(NUMA_NO_NODE, size, align, goal, limit);
232-
233-
if (ptr)
234-
return ptr;
235-
236-
if (goal != 0) {
237-
goal = 0;
238-
goto restart;
239-
}
240-
241-
return NULL;
242-
}
243-
244-
/**
245-
* __alloc_bootmem_nopanic - allocate boot memory without panicking
246-
* @size: size of the request in bytes
247-
* @align: alignment of the region
248-
* @goal: preferred starting address of the region
249-
*
250-
* The goal is dropped if it can not be satisfied and the allocation will
251-
* fall back to memory below @goal.
252-
*
253-
* Allocation may happen on any node in the system.
254-
*
255-
* Return: address of the allocated region or %NULL on failure.
256-
*/
257-
void * __init __alloc_bootmem_nopanic(unsigned long size, unsigned long align,
258-
unsigned long goal)
259-
{
260-
unsigned long limit = -1UL;
261-
262-
return ___alloc_bootmem_nopanic(size, align, goal, limit);
263-
}
264-
265-
static void * __init ___alloc_bootmem(unsigned long size, unsigned long align,
266-
unsigned long goal, unsigned long limit)
267-
{
268-
void *mem = ___alloc_bootmem_nopanic(size, align, goal, limit);
269-
270-
if (mem)
271-
return mem;
272-
/*
273-
* Whoops, we cannot satisfy the allocation request.
274-
*/
275-
pr_alert("bootmem alloc of %lu bytes failed!\n", size);
276-
panic("Out of memory");
277-
return NULL;
278-
}
279-
280-
/**
281-
* __alloc_bootmem - allocate boot memory
282-
* @size: size of the request in bytes
283-
* @align: alignment of the region
284-
* @goal: preferred starting address of the region
285-
*
286-
* The goal is dropped if it can not be satisfied and the allocation will
287-
* fall back to memory below @goal.
288-
*
289-
* Allocation may happen on any node in the system.
290-
*
291-
* The function panics if the request can not be satisfied.
292-
*
293-
* Return: address of the allocated region.
294-
*/
295-
void * __init __alloc_bootmem(unsigned long size, unsigned long align,
296-
unsigned long goal)
297-
{
298-
unsigned long limit = -1UL;
299-
300-
return ___alloc_bootmem(size, align, goal, limit);
301-
}
302-
303-
void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
304-
unsigned long size,
305-
unsigned long align,
306-
unsigned long goal,
307-
unsigned long limit)
308-
{
309-
void *ptr;
310-
311-
again:
312-
ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
313-
goal, limit);
314-
if (ptr)
315-
return ptr;
316-
317-
ptr = __alloc_memory_core_early(NUMA_NO_NODE, size, align,
318-
goal, limit);
319-
if (ptr)
320-
return ptr;
321-
322-
if (goal) {
323-
goal = 0;
324-
goto again;
325-
}
326-
327-
return NULL;
328-
}
329-
330-
void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
331-
unsigned long align, unsigned long goal)
332-
{
333-
if (WARN_ON_ONCE(slab_is_available()))
334-
return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
335-
336-
return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
337-
}
338-
339-
static void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
340-
unsigned long align, unsigned long goal,
341-
unsigned long limit)
342-
{
343-
void *ptr;
344-
345-
ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, limit);
346-
if (ptr)
347-
return ptr;
348-
349-
pr_alert("bootmem alloc of %lu bytes failed!\n", size);
350-
panic("Out of memory");
351-
return NULL;
352-
}
353-
354-
/**
355-
* __alloc_bootmem_node - allocate boot memory from a specific node
356-
* @pgdat: node to allocate from
357-
* @size: size of the request in bytes
358-
* @align: alignment of the region
359-
* @goal: preferred starting address of the region
360-
*
361-
* The goal is dropped if it can not be satisfied and the allocation will
362-
* fall back to memory below @goal.
363-
*
364-
* Allocation may fall back to any node in the system if the specified node
365-
* can not hold the requested memory.
366-
*
367-
* The function panics if the request can not be satisfied.
368-
*
369-
* Return: address of the allocated region.
370-
*/
371-
void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
372-
unsigned long align, unsigned long goal)
373-
{
374-
if (WARN_ON_ONCE(slab_is_available()))
375-
return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
376-
377-
return ___alloc_bootmem_node(pgdat, size, align, goal, 0);
378-
}
379-
380-
void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
381-
unsigned long align, unsigned long goal)
382-
{
383-
return __alloc_bootmem_node(pgdat, size, align, goal);
384-
}
385-
386-
387-
/**
388-
* __alloc_bootmem_low - allocate low boot memory
389-
* @size: size of the request in bytes
390-
* @align: alignment of the region
391-
* @goal: preferred starting address of the region
392-
*
393-
* The goal is dropped if it can not be satisfied and the allocation will
394-
* fall back to memory below @goal.
395-
*
396-
* Allocation may happen on any node in the system.
397-
*
398-
* The function panics if the request can not be satisfied.
399-
*
400-
* Return: address of the allocated region.
401-
*/
402-
void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
403-
unsigned long goal)
404-
{
405-
return ___alloc_bootmem(size, align, goal, ARCH_LOW_ADDRESS_LIMIT);
406-
}

0 commit comments

Comments
 (0)