From 47f71d83cfc13dff311e9c867ab5612a290e57ca Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Thu, 21 Mar 2024 10:22:39 +0100 Subject: [PATCH] mem: add prefer_freelist knob --- kernel/brick_mem.c | 7 ++++--- kernel/brick_mem.h | 1 + kernel/sy_old/mars_proc.c | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/brick_mem.c b/kernel/brick_mem.c index 6abfefc2..4ecd88fc 100644 --- a/kernel/brick_mem.c +++ b/kernel/brick_mem.c @@ -606,10 +606,9 @@ void __brick_block_free(void *data, int order, int cline) #ifdef CONFIG_MARS_MEM_PREALLOC int brick_allow_freelist = 1; -EXPORT_SYMBOL_GPL(brick_allow_freelist); +int brick_prefer_freelist = 1; int brick_pre_reserve[BRICK_MAX_ORDER+1] = {}; -EXPORT_SYMBOL_GPL(brick_pre_reserve); /* Note: we have no separate lists per CPU. * This should not hurt because the freelists are only used @@ -933,7 +932,9 @@ void _brick_block_free(void *data, int len, int cline) } #endif /* BRICK_DEBUG_MEM */ #ifdef CONFIG_MARS_MEM_PREALLOC - if (order > 0 && brick_allow_freelist && atomic_read(&freelist_count[order]) <= brick_mem_freelist_max[order]) { + if (order > 0 && brick_allow_freelist && + (brick_prefer_freelist || + atomic_read(&freelist_count[order]) <= brick_mem_freelist_max[order])) { _put_free(data, order); } else #endif diff --git a/kernel/brick_mem.h b/kernel/brick_mem.h index 937b57d2..c3e45e68 100644 --- a/kernel/brick_mem.h +++ b/kernel/brick_mem.h @@ -237,6 +237,7 @@ extern void _brick_block_free(void *data, int len, int cline); #ifdef CONFIG_MARS_MEM_PREALLOC extern int brick_allow_freelist; +extern int brick_prefer_freelist; extern int brick_pre_reserve[BRICK_MAX_ORDER+1]; extern int brick_mem_freelist_max[BRICK_MAX_ORDER+1]; diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index d4279888..a2df8076 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -650,6 +650,7 @@ struct ctl_table mars_table[] = { INT_ENTRY("mem_used_raw_kb", brick_global_block_used,0400), #ifdef CONFIG_MARS_MEM_PREALLOC INT_ENTRY("mem_allow_freelist", brick_allow_freelist, 0600), + INT_ENTRY("mem_prefer_freelist", brick_prefer_freelist, 0600), VEC_INT_ENTRY("mem_freelist_max", brick_mem_freelist_max, 0600, BRICK_MAX_ORDER+1), VEC_INT_ENTRY("mem_alloc_count", brick_mem_alloc_count, 0400, BRICK_MAX_ORDER+1), VEC_INT_ENTRY("mem_alloc_max", brick_mem_alloc_count, 0600, BRICK_MAX_ORDER+1),