delay allocating slab metadata from reservation
parent
74139112d0
commit
fe30f6c2ea
6
malloc.c
6
malloc.c
|
@ -176,7 +176,7 @@ static struct slab_metadata *alloc_metadata(struct size_class *c, size_t slab_si
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
size_t allocate = c->metadata_allocated * 2;
|
size_t allocate = max(c->metadata_allocated * 2, PAGE_SIZE / sizeof(struct slab_metadata));
|
||||||
if (allocate > metadata_max) {
|
if (allocate > metadata_max) {
|
||||||
allocate = metadata_max;
|
allocate = metadata_max;
|
||||||
}
|
}
|
||||||
|
@ -825,10 +825,6 @@ COLD static void init_slow_path(void) {
|
||||||
if (c->slab_info == NULL) {
|
if (c->slab_info == NULL) {
|
||||||
fatal_error("failed to allocate slab metadata");
|
fatal_error("failed to allocate slab metadata");
|
||||||
}
|
}
|
||||||
c->metadata_allocated = PAGE_SIZE / sizeof(struct slab_metadata);
|
|
||||||
if (memory_protect_rw(c->slab_info, c->metadata_allocated * sizeof(struct slab_metadata))) {
|
|
||||||
fatal_error("failed to allocate initial slab info");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deallocate_pages(rng, sizeof(struct random_state), PAGE_SIZE);
|
deallocate_pages(rng, sizeof(struct random_state), PAGE_SIZE);
|
||||||
|
|
12
util.h
12
util.h
|
@ -7,6 +7,18 @@
|
||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
|
||||||
|
#define min(x, y) ({ \
|
||||||
|
__typeof__(x) _x = (x); \
|
||||||
|
__typeof__(y) _y = (y); \
|
||||||
|
(void) (&_x == &_y); \
|
||||||
|
_x < _y ? _x : _y; })
|
||||||
|
|
||||||
|
#define max(x, y) ({ \
|
||||||
|
__typeof__(x) _x = (x); \
|
||||||
|
__typeof__(y) _y = (y); \
|
||||||
|
(void) (&_x == &_y); \
|
||||||
|
_x > _y ? _x : _y; })
|
||||||
|
|
||||||
#define COLD __attribute__((cold))
|
#define COLD __attribute__((cold))
|
||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
#define EXPORT __attribute__((visibility("default")))
|
#define EXPORT __attribute__((visibility("default")))
|
||||||
|
|
Loading…
Reference in New Issue