History

[PATCH] swiotlb: make sure initial DMA allocations really are in DMA memory

This introduces a limit parameter to the core bootmem allocator; The new parameter indicates that physical memory allocated by the bootmem allocator should be within the requested limit. We also introduce alloc_bootmem_low_pages_limit, alloc_bootmem_node_limit, alloc_bootmem_low_pages_node_limit apis, but alloc_bootmem_low_pages_limit is the only api used for swiotlb. The existing alloc_bootmem_low_pages() api could instead have been changed and made to pass right limit to the core allocator. But that would make the patch more intrusive for 2.6.14, as other arches use alloc_bootmem_low_pages(). We may be done that post 2.6.14 as a cleanup. With this, swiotlb gets memory within 4G for both x86_64 and ia64 arches.

Yasunori Goto committed 21 years ago

Commit 281dd251 parent 51b190b3 files · +53 −14Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/bootmem.h+30−2
@@ -43,7 +43,7 @@ typedef struct bootmem_data { · 42 unmodified lines
43extern unsigned long __init bootmem_bootmap_pages (unsigned long);43extern unsigned long __init bootmem_bootmap_pages (unsigned long);
44extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);44extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
45extern void __init free_bootmem (unsigned long addr, unsigned long size);45extern void __init free_bootmem (unsigned long addr, unsigned long size);
46extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);46extern void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, unsigned long limit);
47#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE47#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
48extern void __init reserve_bootmem (unsigned long addr, unsigned long size);48extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
49#define alloc_bootmem(x) \49#define alloc_bootmem(x) \
@@ -54,6 +54,16 @@ extern void __init reserve_bootmem (unsigned long addr, unsigned long size); · 4 unmodified lines
54 __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))54 __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
55#define alloc_bootmem_low_pages(x) \55#define alloc_bootmem_low_pages(x) \
56 __alloc_bootmem((x), PAGE_SIZE, 0)56 __alloc_bootmem((x), PAGE_SIZE, 0)
57
58#define alloc_bootmem_limit(x, limit) \
59 __alloc_bootmem_limit((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit))
60#define alloc_bootmem_low_limit(x, limit) \
61 __alloc_bootmem_limit((x), SMP_CACHE_BYTES, 0, (limit))
62#define alloc_bootmem_pages_limit(x, limit) \
63 __alloc_bootmem_limit((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit))
64#define alloc_bootmem_low_pages_limit(x, limit) \
65 __alloc_bootmem_limit((x), PAGE_SIZE, 0, (limit))
66
57#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */67#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
58extern unsigned long __init free_all_bootmem (void);68extern unsigned long __init free_all_bootmem (void);
59 69
@@ -61,7 +71,7 @@ extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long f · 1 unmodified line
61extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size);71extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size);
62extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size);72extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size);
63extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat);73extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat);
64extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal);74extern void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal, unsigned long limit);
65#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE75#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
66#define alloc_bootmem_node(pgdat, x) \76#define alloc_bootmem_node(pgdat, x) \
67 __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))77 __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
@@ -69,6 +79,14 @@ extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, · 1 unmodified line
69 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))79 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
70#define alloc_bootmem_low_pages_node(pgdat, x) \80#define alloc_bootmem_low_pages_node(pgdat, x) \
71 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)81 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0)
82
83#define alloc_bootmem_node_limit(pgdat, x, limit) \
84 __alloc_bootmem_node_limit((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit))
85#define alloc_bootmem_pages_node_limit(pgdat, x, limit) \
86 __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit))
87#define alloc_bootmem_low_pages_node_limit(pgdat, x, limit) \
88 __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, 0, (limit))
89
72#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */90#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
73 91
74#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP92#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
@@ -105,5 +123,15 @@ extern void *__init alloc_large_system_hash(const char *tablename, · 30 unmodified lines
105#endif123#endif
106extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */124extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */
107 125
126static inline void *__alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal)
127{
128 return __alloc_bootmem_limit(size, align, goal, 0);
129}
130
131static inline void *__alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align,
132 unsigned long goal)
133{
134 return __alloc_bootmem_node_limit(pgdat, size, align, goal, 0);
135}
108 136
109#endif /* _LINUX_BOOTMEM_H */137#endif /* _LINUX_BOOTMEM_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t