diff options
author | Andi Kleen <ak@suse.de> | 2005-11-05 11:25:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-14 22:55:13 -0500 |
commit | a2f1b424900715ed9d1699c3bb88a434a2b42bc0 (patch) | |
tree | 8ef440f840656365166ff2d71aa445c224c53546 /include/linux | |
parent | 56720367cd89ef5265f39da2d674c5b92cd4cd87 (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 'include/linux')
-rw-r--r-- | include/linux/gfp.h | 11 | ||||
-rw-r--r-- | include/linux/mmzone.h | 16 |
2 files changed, 20 insertions, 7 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index c3779432a723..4351e6bb5a79 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h | |||
@@ -14,6 +14,13 @@ struct vm_area_struct; | |||
14 | /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */ | 14 | /* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */ |
15 | #define __GFP_DMA ((__force gfp_t)0x01u) | 15 | #define __GFP_DMA ((__force gfp_t)0x01u) |
16 | #define __GFP_HIGHMEM ((__force gfp_t)0x02u) | 16 | #define __GFP_HIGHMEM ((__force gfp_t)0x02u) |
17 | #ifdef CONFIG_DMA_IS_DMA32 | ||
18 | #define __GFP_DMA32 ((__force gfp_t)0x01) /* ZONE_DMA is ZONE_DMA32 */ | ||
19 | #elif BITS_PER_LONG < 64 | ||
20 | #define __GFP_DMA32 ((__force gfp_t)0x00) /* ZONE_NORMAL is ZONE_DMA32 */ | ||
21 | #else | ||
22 | #define __GFP_DMA32 ((__force gfp_t)0x04) /* Has own ZONE_DMA32 */ | ||
23 | #endif | ||
17 | 24 | ||
18 | /* | 25 | /* |
19 | * Action modifiers - doesn't change the zoning | 26 | * Action modifiers - doesn't change the zoning |
@@ -64,6 +71,10 @@ struct vm_area_struct; | |||
64 | 71 | ||
65 | #define GFP_DMA __GFP_DMA | 72 | #define GFP_DMA __GFP_DMA |
66 | 73 | ||
74 | /* 4GB DMA on some platforms */ | ||
75 | #define GFP_DMA32 __GFP_DMA32 | ||
76 | |||
77 | |||
67 | #define gfp_zone(mask) ((__force int)((mask) & (__force gfp_t)GFP_ZONEMASK)) | 78 | #define gfp_zone(mask) ((__force int)((mask) & (__force gfp_t)GFP_ZONEMASK)) |
68 | 79 | ||
69 | /* | 80 | /* |
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index f5fa3082fd6a..da7a829f8561 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -71,10 +71,11 @@ struct per_cpu_pageset { | |||
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #define ZONE_DMA 0 | 73 | #define ZONE_DMA 0 |
74 | #define ZONE_NORMAL 1 | 74 | #define ZONE_DMA32 1 |
75 | #define ZONE_HIGHMEM 2 | 75 | #define ZONE_NORMAL 2 |
76 | #define ZONE_HIGHMEM 3 | ||
76 | 77 | ||
77 | #define MAX_NR_ZONES 3 /* Sync this with ZONES_SHIFT */ | 78 | #define MAX_NR_ZONES 4 /* Sync this with ZONES_SHIFT */ |
78 | #define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ | 79 | #define ZONES_SHIFT 2 /* ceil(log2(MAX_NR_ZONES)) */ |
79 | 80 | ||
80 | 81 | ||
@@ -108,9 +109,10 @@ struct per_cpu_pageset { | |||
108 | 109 | ||
109 | /* | 110 | /* |
110 | * On machines where it is needed (eg PCs) we divide physical memory | 111 | * On machines where it is needed (eg PCs) we divide physical memory |
111 | * into multiple physical zones. On a PC we have 3 zones: | 112 | * into multiple physical zones. On a PC we have 4 zones: |
112 | * | 113 | * |
113 | * ZONE_DMA < 16 MB ISA DMA capable memory | 114 | * ZONE_DMA < 16 MB ISA DMA capable memory |
115 | * ZONE_DMA32 0 MB Empty | ||
114 | * ZONE_NORMAL 16-896 MB direct mapped by the kernel | 116 | * ZONE_NORMAL 16-896 MB direct mapped by the kernel |
115 | * ZONE_HIGHMEM > 896 MB only page cache and user processes | 117 | * ZONE_HIGHMEM > 896 MB only page cache and user processes |
116 | */ | 118 | */ |
@@ -455,10 +457,10 @@ extern struct pglist_data contig_page_data; | |||
455 | 457 | ||
456 | #if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED) | 458 | #if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED) |
457 | /* | 459 | /* |
458 | * with 32 bit page->flags field, we reserve 8 bits for node/zone info. | 460 | * with 32 bit page->flags field, we reserve 9 bits for node/zone info. |
459 | * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. | 461 | * there are 4 zones (3 bits) and this leaves 9-3=6 bits for nodes. |
460 | */ | 462 | */ |
461 | #define FLAGS_RESERVED 8 | 463 | #define FLAGS_RESERVED 9 |
462 | 464 | ||
463 | #elif BITS_PER_LONG == 64 | 465 | #elif BITS_PER_LONG == 64 |
464 | /* | 466 | /* |