From 48a19e58d1775ac53680da5446b88d3f8e381d95 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 28 Jun 2022 21:25:28 +0200 Subject: [PATCH] brick_mem: make CONFIG_MARS_MEM_RETRY mandatory by removing the symbol --- kernel/Kconfig | 7 ------- kernel/brick_mem.c | 16 ---------------- kernel/brick_mem.h | 14 +++++--------- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/kernel/Kconfig b/kernel/Kconfig index 3bc01730..fc371f7f 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -134,13 +134,6 @@ config MARS_IPv4_TOS In certain private networks, this can improve certain network bottlenecks. -config MARS_MEM_RETRY - bool "make MARS memory allocation more robust" - depends on MARS - default y - ---help--- - Normally ON. Switch only off for systems having very low memory. - config MARS_LOGDIR string "absolute path to the logging directory" depends on MARS diff --git a/kernel/brick_mem.c b/kernel/brick_mem.c index 9f093c5f..cc64d7b4 100644 --- a/kernel/brick_mem.c +++ b/kernel/brick_mem.c @@ -125,7 +125,6 @@ void *__brick_mem_alloc(int len) #endif res = _brick_block_alloc(0, len, 0); } else { -#ifdef CONFIG_MARS_MEM_RETRY for (;;) { res = kmalloc(len, GFP_BRICK); if (likely(res)) @@ -134,13 +133,6 @@ void *__brick_mem_alloc(int len) } #ifdef BRICK_DEBUG_MEM atomic_inc(&phys_mem_alloc); -#endif -#else - res = kmalloc(len, GFP_BRICK); -#ifdef BRICK_DEBUG_MEM - if (res) - atomic_inc(&phys_mem_alloc); -#endif #endif } return res; @@ -286,16 +278,12 @@ char *_brick_string_alloc(int len, int line) len = BRICK_STRING_LEN; } -#ifdef CONFIG_MARS_MEM_RETRY for (;;) { -#endif res = kzalloc(len + STRING_PLUS, GFP_BRICK); -#ifdef CONFIG_MARS_MEM_RETRY if (likely(res)) break; msleep(1000); } -#endif #ifdef BRICK_DEBUG_MEM if (likely(res)) { @@ -498,20 +486,16 @@ static inline void *__brick_block_alloc(gfp_t gfp, int order, int cline) { void *res; -#ifdef CONFIG_MARS_MEM_RETRY for (;;) { -#endif #ifdef USE_KERNEL_PAGES res = (void*)__get_free_pages(gfp, order); #else res = __vmalloc(PAGE_SIZE << order, gfp, PAGE_KERNEL_IO); #endif -#ifdef CONFIG_MARS_MEM_RETRY if (likely(res)) break; msleep(1000); } -#endif if (likely(res)) { #ifdef CONFIG_MARS_DEBUG_MEM_STRONG diff --git a/kernel/brick_mem.h b/kernel/brick_mem.h index 7347e851..c964d5a3 100644 --- a/kernel/brick_mem.h +++ b/kernel/brick_mem.h @@ -96,18 +96,14 @@ void *__mark_ptr_nonnull(void *_ptr) return ptr; } -/* All the brick memory allocations are guaranteed to succeed when - * CONFIG_MARS_MEM_RETRY is set. In case of low memory, they will just - * retry (forever). +/* All the brick memory allocations need to succeed. + * In case of low memory, they will retry (forever), + * but only after some pause. * - * Allow checking code to be written which works for both cases: - * CONFIG_MARS_MEM_RETRY is selected, or not. + * This allows OOM to catch in, and to (hopefully) + * improve the situation. */ -#ifdef CONFIG_MARS_MEM_RETRY #define brick_mark_nonnull __mark_ptr_nonnull -#else -#define brick_mark_nonnull(p) (p) -#endif /////////////////////////////////////////////////////////////////////////