make class_region_size configurable
This commit is contained in:
parent
8b0450555f
commit
830a7d338d
@ -23,8 +23,9 @@ common_cflags = [
|
|||||||
"-DGUARD_SIZE_DIVISOR=2",
|
"-DGUARD_SIZE_DIVISOR=2",
|
||||||
"-DREGION_QUARANTINE_RANDOM_SIZE=128",
|
"-DREGION_QUARANTINE_RANDOM_SIZE=128",
|
||||||
"-DREGION_QUARANTINE_QUEUE_SIZE=1024",
|
"-DREGION_QUARANTINE_QUEUE_SIZE=1024",
|
||||||
"-DREGION_QUARANTINE_SKIP_THRESHOLD=33554432",
|
"-DREGION_QUARANTINE_SKIP_THRESHOLD=33554432", // 32MiB
|
||||||
"-DFREE_SLABS_QUARANTINE_RANDOM_SIZE=32",
|
"-DFREE_SLABS_QUARANTINE_RANDOM_SIZE=32",
|
||||||
|
"-DCONFIG_CLASS_REGION_SIZE=1073741824", // 1GiB
|
||||||
]
|
]
|
||||||
|
|
||||||
cc_defaults {
|
cc_defaults {
|
||||||
|
6
Makefile
6
Makefile
@ -12,8 +12,9 @@ CONFIG_GUARD_SLABS_INTERVAL := 1
|
|||||||
CONFIG_GUARD_SIZE_DIVISOR := 2
|
CONFIG_GUARD_SIZE_DIVISOR := 2
|
||||||
CONFIG_REGION_QUARANTINE_RANDOM_SIZE := 128
|
CONFIG_REGION_QUARANTINE_RANDOM_SIZE := 128
|
||||||
CONFIG_REGION_QUARANTINE_QUEUE_SIZE := 1024
|
CONFIG_REGION_QUARANTINE_QUEUE_SIZE := 1024
|
||||||
CONFIG_REGION_QUARANTINE_SKIP_THRESHOLD := 33554432
|
CONFIG_REGION_QUARANTINE_SKIP_THRESHOLD := 33554432 # 32MiB
|
||||||
CONFIG_FREE_SLABS_QUARANTINE_RANDOM_SIZE := 32
|
CONFIG_FREE_SLABS_QUARANTINE_RANDOM_SIZE := 32
|
||||||
|
CONFIG_CLASS_REGION_SIZE := 137438953472 # 128GiB
|
||||||
|
|
||||||
define safe_flag
|
define safe_flag
|
||||||
$(shell $(CC) -E $1 - </dev/null >/dev/null 2>&1 && echo $1)
|
$(shell $(CC) -E $1 - </dev/null >/dev/null 2>&1 && echo $1)
|
||||||
@ -77,7 +78,8 @@ CPPFLAGS += \
|
|||||||
-DREGION_QUARANTINE_RANDOM_SIZE=$(CONFIG_REGION_QUARANTINE_RANDOM_SIZE) \
|
-DREGION_QUARANTINE_RANDOM_SIZE=$(CONFIG_REGION_QUARANTINE_RANDOM_SIZE) \
|
||||||
-DREGION_QUARANTINE_QUEUE_SIZE=$(CONFIG_REGION_QUARANTINE_QUEUE_SIZE) \
|
-DREGION_QUARANTINE_QUEUE_SIZE=$(CONFIG_REGION_QUARANTINE_QUEUE_SIZE) \
|
||||||
-DREGION_QUARANTINE_SKIP_THRESHOLD=$(CONFIG_REGION_QUARANTINE_SKIP_THRESHOLD) \
|
-DREGION_QUARANTINE_SKIP_THRESHOLD=$(CONFIG_REGION_QUARANTINE_SKIP_THRESHOLD) \
|
||||||
-DFREE_SLABS_QUARANTINE_RANDOM_SIZE=$(CONFIG_FREE_SLABS_QUARANTINE_RANDOM_SIZE)
|
-DFREE_SLABS_QUARANTINE_RANDOM_SIZE=$(CONFIG_FREE_SLABS_QUARANTINE_RANDOM_SIZE) \
|
||||||
|
-DCONFIG_CLASS_REGION_SIZE=$(CONFIG_CLASS_REGION_SIZE)
|
||||||
|
|
||||||
libhardened_malloc.so: $(OBJECTS)
|
libhardened_malloc.so: $(OBJECTS)
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -shared $^ $(LDLIBS) -o $@
|
$(CC) $(CFLAGS) $(LDFLAGS) -shared $^ $(LDLIBS) -o $@
|
||||||
|
@ -159,6 +159,8 @@ for the chosen values are not written yet, so use them at your own peril:
|
|||||||
the size threshold where large allocations will not be quarantined
|
the size threshold where large allocations will not be quarantined
|
||||||
* `CONFIG_FREE_SLABS_QUARANTINE_RANDOM_SIZE`: `32` (default) to control the
|
* `CONFIG_FREE_SLABS_QUARANTINE_RANDOM_SIZE`: `32` (default) to control the
|
||||||
number of slots in the random array used to randomize free slab reuse
|
number of slots in the random array used to randomize free slab reuse
|
||||||
|
* `CONFIG_CLASS_REGION_SIZE`: `34359738368` (default) to control the size of
|
||||||
|
the size class regions
|
||||||
|
|
||||||
There will be more control over enabled features in the future along with
|
There will be more control over enabled features in the future along with
|
||||||
control over fairly arbitrarily chosen values like the size of empty slab
|
control over fairly arbitrarily chosen values like the size of empty slab
|
||||||
|
@ -210,7 +210,7 @@ struct __attribute__((aligned(CACHELINE_SIZE))) size_class {
|
|||||||
size_t metadata_count_unguarded;
|
size_t metadata_count_unguarded;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CLASS_REGION_SIZE (128ULL * 1024 * 1024 * 1024)
|
#define CLASS_REGION_SIZE (size_t)CONFIG_CLASS_REGION_SIZE
|
||||||
#define REAL_CLASS_REGION_SIZE (CLASS_REGION_SIZE * 2)
|
#define REAL_CLASS_REGION_SIZE (CLASS_REGION_SIZE * 2)
|
||||||
static const size_t slab_region_size = REAL_CLASS_REGION_SIZE * N_SIZE_CLASSES;
|
static const size_t slab_region_size = REAL_CLASS_REGION_SIZE * N_SIZE_CLASSES;
|
||||||
static_assert(PAGE_SIZE == 4096, "bitmap handling will need adjustment for other page sizes");
|
static_assert(PAGE_SIZE == 4096, "bitmap handling will need adjustment for other page sizes");
|
||||||
|
Loading…
Reference in New Issue
Block a user