brick_mem: make CONFIG_MARS_MEM_RETRY mandatory by removing the symbol

This commit is contained in:
Thomas Schoebel-Theuer 2022-06-28 21:25:28 +02:00
parent b4e0927d20
commit 48a19e58d1
3 changed files with 5 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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
/////////////////////////////////////////////////////////////////////////