aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2005-11-05 11:25:53 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-14 22:55:13 -0500
commita2f1b424900715ed9d1699c3bb88a434a2b42bc0 (patch)
tree8ef440f840656365166ff2d71aa445c224c53546 /mm/page_alloc.c
parent56720367cd89ef5265f39da2d674c5b92cd4cd87 (diff)
[PATCH] x86_64: Add 4GB DMA32 zone
Add a new 4GB GFP_DMA32 zone between the GFP_DMA and GFP_NORMAL zones. As a bit of historical background: when the x86-64 port was originally designed we had some discussion if we should use a 16MB DMA zone like i386 or a 4GB DMA zone like IA64 or both. Both was ruled out at this point because it was in early 2.4 when VM is still quite shakey and had bad troubles even dealing with one DMA zone. We settled on the 16MB DMA zone mainly because we worried about older soundcards and the floppy. But this has always caused problems since then because device drivers had trouble getting enough DMA able memory. These days the VM works much better and the wide use of NUMA has proven it can deal with many zones successfully. So this patch adds both zones. This helps drivers who need a lot of memory below 4GB because their hardware is not accessing more (graphic drivers - proprietary and free ones, video frame buffer drivers, sound drivers etc.). Previously they could only use IOMMU+16MB GFP_DMA, which was not enough memory. Another common problem is that hardware who has full memory addressing for >4GB misses it for some control structures in memory (like transmit rings or other metadata). They tended to allocate memory in the 16MB GFP_DMA or the IOMMU/swiotlb then using pci_alloc_consistent, but that can tie up a lot of precious 16MB GFPDMA/IOMMU/swiotlb memory (even on AMD systems the IOMMU tends to be quite small) especially if you have many devices. With the new zone pci_alloc_consistent can just put this stuff into memory below 4GB which works better. One argument was still if the zone should be 4GB or 2GB. The main motivation for 2GB would be an unnamed not so unpopular hardware raid controller (mostly found in older machines from a particular four letter company) who has a strange 2GB restriction in firmware. But that one works ok with swiotlb/IOMMU anyways, so it doesn't really need GFP_DMA32. I chose 4GB to be compatible with IA64 and because it seems to be the most common restriction. The new zone is so far added only for x86-64. For other architectures who don't set up this new zone nothing changes. Architectures can set a compatibility define in Kconfig CONFIG_DMA_IS_DMA32 that will define GFP_DMA32 as GFP_DMA. Otherwise it's a nop because on 32bit architectures it's normally not needed because GFP_NORMAL (=0) is DMA able enough. One problem is still that GFP_DMA means different things on different architectures. e.g. some drivers used to have #ifdef ia64 use GFP_DMA (trusting it to be 4GB) #elif __x86_64__ (use other hacks like the swiotlb because 16MB is not enough) ... . This was quite ugly and is now obsolete. These should be now converted to use GFP_DMA32 unconditionally. I haven't done this yet. Or best only use pci_alloc_consistent/dma_alloc_coherent which will use GFP_DMA32 transparently. Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2dbdd98426fd..9b43511dbefd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -60,8 +60,11 @@ long nr_swap_pages;
60 * NORMAL allocation will leave 784M/256 of ram reserved in the ZONE_DMA 60 * NORMAL allocation will leave 784M/256 of ram reserved in the ZONE_DMA
61 * HIGHMEM allocation will leave 224M/32 of ram reserved in ZONE_NORMAL 61 * HIGHMEM allocation will leave 224M/32 of ram reserved in ZONE_NORMAL
62 * HIGHMEM allocation will (224M+784M)/256 of ram reserved in ZONE_DMA 62 * HIGHMEM allocation will (224M+784M)/256 of ram reserved in ZONE_DMA
63 *
64 * TBD: should special case ZONE_DMA32 machines here - in those we normally
65 * don't need any ZONE_NORMAL reservation
63 */ 66 */
64int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { 256, 32 }; 67int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = { 256, 256, 32 };
65 68
66EXPORT_SYMBOL(totalram_pages); 69EXPORT_SYMBOL(totalram_pages);
67EXPORT_SYMBOL(nr_swap_pages); 70EXPORT_SYMBOL(nr_swap_pages);
@@ -73,7 +76,7 @@ EXPORT_SYMBOL(nr_swap_pages);
73struct zone *zone_table[1 << ZONETABLE_SHIFT] __read_mostly; 76struct zone *zone_table[1 << ZONETABLE_SHIFT] __read_mostly;
74EXPORT_SYMBOL(zone_table); 77EXPORT_SYMBOL(zone_table);
75 78
76static char *zone_names[MAX_NR_ZONES] = { "DMA", "Normal", "HighMem" }; 79static char *zone_names[MAX_NR_ZONES] = { "DMA", "DMA32", "Normal", "HighMem" };
77int min_free_kbytes = 1024; 80int min_free_kbytes = 1024;
78 81
79unsigned long __initdata nr_kernel_pages; 82unsigned long __initdata nr_kernel_pages;
@@ -1442,6 +1445,10 @@ static int __init build_zonelists_node(pg_data_t *pgdat, struct zonelist *zoneli
1442 zone = pgdat->node_zones + ZONE_NORMAL; 1445 zone = pgdat->node_zones + ZONE_NORMAL;
1443 if (zone->present_pages) 1446 if (zone->present_pages)
1444 zonelist->zones[j++] = zone; 1447 zonelist->zones[j++] = zone;
1448 case ZONE_DMA32:
1449 zone = pgdat->node_zones + ZONE_DMA32;
1450 if (zone->present_pages)
1451 zonelist->zones[j++] = zone;
1445 case ZONE_DMA: 1452 case ZONE_DMA:
1446 zone = pgdat->node_zones + ZONE_DMA; 1453 zone = pgdat->node_zones + ZONE_DMA;
1447 if (zone->present_pages) 1454 if (zone->present_pages)
@@ -1456,6 +1463,8 @@ static inline int highest_zone(int zone_bits)
1456 int res = ZONE_NORMAL; 1463 int res = ZONE_NORMAL;
1457 if (zone_bits & (__force int)__GFP_HIGHMEM) 1464 if (zone_bits & (__force int)__GFP_HIGHMEM)
1458 res = ZONE_HIGHMEM; 1465 res = ZONE_HIGHMEM;
1466 if (zone_bits & (__force int)__GFP_DMA32)
1467 res = ZONE_DMA32;
1459 if (zone_bits & (__force int)__GFP_DMA) 1468 if (zone_bits & (__force int)__GFP_DMA)
1460 res = ZONE_DMA; 1469 res = ZONE_DMA;
1461 return res; 1470 return res;
@@ -1976,7 +1985,7 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1976 if (zholes_size) 1985 if (zholes_size)
1977 realsize -= zholes_size[j]; 1986 realsize -= zholes_size[j];
1978 1987
1979 if (j == ZONE_DMA || j == ZONE_NORMAL) 1988 if (j < ZONE_HIGHMEM)
1980 nr_kernel_pages += realsize; 1989 nr_kernel_pages += realsize;
1981 nr_all_pages += realsize; 1990 nr_all_pages += realsize;
1982 1991