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
4343 extern unsigned long __init bootmem_bootmap_pages (unsigned long);
4444 extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend);
4545 extern void __init free_bootmem (unsigned long addr, unsigned long size);
46−extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
46+extern void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, unsigned long limit);
4747 #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
4848 extern void __init reserve_bootmem (unsigned long addr, unsigned long size);
4949 #define alloc_bootmem(x) \
@@ -54,6 +54,16 @@ extern void __init reserve_bootmem (unsigned long addr, unsigned long size); · 4 unmodified lines
5454 __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
5555 #define alloc_bootmem_low_pages(x) \
5656 __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+
5767 #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
5868 extern unsigned long __init free_all_bootmem (void);
5969
@@ -61,7 +71,7 @@ extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long f · 1 unmodified line
6171 extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size);
6272 extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size);
6373 extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat);
64−extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal);
74+extern void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal, unsigned long limit);
6575 #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
6676 #define alloc_bootmem_node(pgdat, x) \
6777 __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
6979 __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
7080 #define alloc_bootmem_low_pages_node(pgdat, x) \
7181 __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+
7290 #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
7391
7492 #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
@@ -105,5 +123,15 @@ extern void *__init alloc_large_system_hash(const char *tablename, · 30 unmodified lines
105123 #endif
106124 extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */
107125
126+static 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+
131+static 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+}
108136
109137 #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