diff options
author | Richard Braun <rbraun@sceen.net> | 2016-02-20 00:48:38 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2016-02-20 00:48:38 +0100 |
commit | e3cdb6f6ad3f2ef690cc5822178efb3bde93fa9a (patch) | |
tree | 711130cd6f53d0ae641ea70c4699bd11d7361082 /kern/slab.h | |
parent | f9ac76867be8c7f6943ca42d93521e5ad97e42a4 (diff) | |
download | gnumach-e3cdb6f6ad3f2ef690cc5822178efb3bde93fa9a.tar.gz gnumach-e3cdb6f6ad3f2ef690cc5822178efb3bde93fa9a.tar.bz2 gnumach-e3cdb6f6ad3f2ef690cc5822178efb3bde93fa9a.zip |
Avoid slab allocation failures caused by memory fragmentation
Since the slab allocator has been changed to sit directly on top of the
physical allocator, failures caused by fragmentation have been observed,
as one could expect. This change makes the slab allocator revert to
kernel virtual memory when allocating larger-than-page slabs. This
solution is motivated in part to avoid the complexity of other solutions
such as page mobility, and also because a microkernel cannot be extended
to new arbitrary uncontrolled usage patterns such as a monolithic kernel
with loadable modules. As such, large objects are rare, and their use
infrequent, which is compatible with the use of kernel virtual memory.
* kern/slab.c: Update module description.
(KMEM_CF_SLAB_EXTERNAL, KMEM_CF_VERIFY): Update values.
(KMEM_CF_DIRECT): Remove macro.
(KMEM_CF_DIRECTMAP): New macro.
(kmem_pagealloc_directmap, kmem_pagefree_directmap,
kmem_pagealloc_virtual, kmem_pagefree_virtual): New functions.
(kmem_pagealloc, kmem_pagefree, kmem_slab_create, kmem_slab_destroy,
kalloc, kfree): Update to use the new pagealloc functions.
(kmem_cache_compute_sizes): Update the algorithm used to determine slab
size and other cache properties.
(kmem_slab_use_tree, kmem_cache_free_to_slab, host_slab_info): Update to
correctly use the cache flags.
(slab_init): Add KMEM_CACHE_DIRECTMAP to the kmem_slab_cache init flags.
* kern/slab.h (KMEM_CACHE_VERIFY): Change value.
(KMEM_CACHE_DIRECTMAP): New macro.
* vm/vm_map.c (vm_map_init): Add KMEM_CACHE_DIRECTMAP to the
vm_map_entry_cache init flags.
Diffstat (limited to 'kern/slab.h')
-rw-r--r-- | kern/slab.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kern/slab.h b/kern/slab.h index 51f29a90..a9978fdb 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -196,7 +196,8 @@ typedef struct kmem_cache *kmem_cache_t; * Cache initialization flags. */ #define KMEM_CACHE_NOOFFSLAB 0x1 /* Don't allocate external slab data */ -#define KMEM_CACHE_VERIFY 0x2 /* Use debugging facilities */ +#define KMEM_CACHE_DIRECTMAP 0x2 /* Allocate from physical memory */ +#define KMEM_CACHE_VERIFY 0x4 /* Use debugging facilities */ /* * Initialize a cache. |