diff options
author | Jes Sorensen <jes@wildopensource.com> | 2005-06-21 20:15:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-21 21:46:18 -0400 |
commit | f14f75b81187cdbe10cc53a521bf9fdf97b59f8c (patch) | |
tree | 5c0d48c8a3338e6f1747e6cd55f699be96ffef1a /include/linux/genalloc.h | |
parent | 2caaad41e4aa8f5dd999695b4ddeaa0e7f3912a4 (diff) |
[PATCH] ia64 uncached alloc
This patch contains the ia64 uncached page allocator and the generic
allocator (genalloc). The uncached allocator was formerly part of the SN2
mspec driver but there are several other users of it so it has been split
off from the driver.
The generic allocator can be used by device driver to manage special memory
etc. The generic allocator is based on the allocator from the sym53c8xx_2
driver.
Various users on ia64 needs uncached memory. The SGI SN architecture requires
it for inter-partition communication between partitions within a large NUMA
cluster. The specific user for this is the XPC code. Another application is
large MPI style applications which use it for synchronization, on SN this can
be done using special 'fetchop' operations but it also benefits non SN
hardware which may use regular uncached memory for this purpose. Performance
of doing this through uncached vs cached memory is pretty substantial. This
is handled by the mspec driver which I will push out in a seperate patch.
Rather than creating a specific allocator for just uncached memory I came up
with genalloc which is a generic purpose allocator that can be used by device
drivers and other subsystems as they please. For instance to handle onboard
device memory. It was derived from the sym53c7xx_2 driver's allocator which
is also an example of a potential user (I am refraining from modifying sym2
right now as it seems to have been under fairly heavy development recently).
On ia64 memory has various properties within a granule, ie. it isn't safe to
access memory as uncached within the same granule as currently has memory
accessed in cached mode. The regular system therefore doesn't utilize memory
in the lower granules which is mixed in with device PAL code etc. The
uncached driver walks the EFI memmap and pulls out the spill uncached pages
and sticks them into the uncached pool. Only after these chunks have been
utilized, will it start converting regular cached memory into uncached memory.
Hence the reason for the EFI related code additions.
Signed-off-by: Jes Sorensen <jes@wildopensource.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/genalloc.h')
-rw-r--r-- | include/linux/genalloc.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h new file mode 100644 index 000000000000..7fd0576a4454 --- /dev/null +++ b/include/linux/genalloc.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * Basic general purpose allocator for managing special purpose memory | ||
3 | * not managed by the regular kmalloc/kfree interface. | ||
4 | * Uses for this includes on-device special memory, uncached memory | ||
5 | * etc. | ||
6 | * | ||
7 | * This code is based on the buddy allocator found in the sym53c8xx_2 | ||
8 | * driver, adapted for general purpose use. | ||
9 | * | ||
10 | * This source code is licensed under the GNU General Public License, | ||
11 | * Version 2. See the file COPYING for more details. | ||
12 | */ | ||
13 | |||
14 | #include <linux/spinlock.h> | ||
15 | |||
16 | #define ALLOC_MIN_SHIFT 5 /* 32 bytes minimum */ | ||
17 | /* | ||
18 | * Link between free memory chunks of a given size. | ||
19 | */ | ||
20 | struct gen_pool_link { | ||
21 | struct gen_pool_link *next; | ||
22 | }; | ||
23 | |||
24 | /* | ||
25 | * Memory pool descriptor. | ||
26 | */ | ||
27 | struct gen_pool { | ||
28 | spinlock_t lock; | ||
29 | unsigned long (*get_new_chunk)(struct gen_pool *); | ||
30 | struct gen_pool *next; | ||
31 | struct gen_pool_link *h; | ||
32 | unsigned long private; | ||
33 | int max_chunk_shift; | ||
34 | }; | ||
35 | |||
36 | unsigned long gen_pool_alloc(struct gen_pool *poolp, int size); | ||
37 | void gen_pool_free(struct gen_pool *mp, unsigned long ptr, int size); | ||
38 | struct gen_pool *gen_pool_create(int nr_chunks, int max_chunk_shift, | ||
39 | unsigned long (*fp)(struct gen_pool *), | ||
40 | unsigned long data); | ||