mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
qcacmn: Use atomic allocation for all scheduler context scan allocations
In low memory environments using GFP_KERNEL flag may cause scheduler thread to sleep. Scheduler thread callback handlers are expected to be atomic in nature to ensure timely execution of different commands. Move all allocations done by scan module in scheduler thread context to atomic allocation. Change-Id: Iee3eafbc00a3afea0687ba67b3041ec0816094cc CRs-Fixed: 2232553
This commit is contained in:
parent
028f560991
commit
9b56f5dc1c
11 changed files with 69 additions and 29 deletions
|
|
@ -93,6 +93,7 @@ void qdf_mem_exit(void);
|
|||
* @file: File name of the call site
|
||||
* @line: Line number of the call site
|
||||
* @caller: Address of the caller function
|
||||
* @flag: GFP flag
|
||||
*
|
||||
* This function will dynamicallly allocate the specified number of bytes of
|
||||
* memory and add it to the qdf tracking list to check for memory leaks and
|
||||
|
|
@ -101,11 +102,13 @@ void qdf_mem_exit(void);
|
|||
* Return: A valid memory location on success, or NULL on failure
|
||||
*/
|
||||
void *qdf_mem_malloc_debug(size_t size, const char *file, uint32_t line,
|
||||
void *caller);
|
||||
void *caller, uint32_t flag);
|
||||
|
||||
#define qdf_mem_malloc(size) \
|
||||
qdf_mem_malloc_debug(size, __FILE__, __LINE__, QDF_RET_IP)
|
||||
qdf_mem_malloc_debug(size, __FILE__, __LINE__, QDF_RET_IP, 0)
|
||||
|
||||
#define qdf_mem_malloc_atomic(size) \
|
||||
qdf_mem_malloc_debug(size, __FILE__, __LINE__, QDF_RET_IP, GFP_ATOMIC)
|
||||
/**
|
||||
* qdf_mem_free_debug() - debug version of qdf_mem_free
|
||||
* @ptr: Pointer to the starting address of the memory to be freed.
|
||||
|
|
@ -196,6 +199,7 @@ void qdf_mem_free_consistent_debug(qdf_device_t osdev, void *dev,
|
|||
__FILE__, __LINE__)
|
||||
#else
|
||||
void *qdf_mem_malloc(qdf_size_t size);
|
||||
void *qdf_mem_malloc_atomic(qdf_size_t size);
|
||||
|
||||
/**
|
||||
* qdf_mem_free() - free QDF memory
|
||||
|
|
|
|||
|
|
@ -1061,7 +1061,7 @@ static void qdf_mem_debug_exit(void)
|
|||
}
|
||||
|
||||
void *qdf_mem_malloc_debug(size_t size, const char *file, uint32_t line,
|
||||
void *caller)
|
||||
void *caller, uint32_t flag)
|
||||
{
|
||||
QDF_STATUS status;
|
||||
enum qdf_debug_domain current_domain = qdf_debug_domain_get();
|
||||
|
|
@ -1079,8 +1079,11 @@ void *qdf_mem_malloc_debug(size_t size, const char *file, uint32_t line,
|
|||
if (ptr)
|
||||
return ptr;
|
||||
|
||||
if (!flag)
|
||||
flag = qdf_mem_malloc_flags();
|
||||
|
||||
start = qdf_mc_timer_get_system_time();
|
||||
header = kzalloc(size + QDF_MEM_DEBUG_SIZE, qdf_mem_malloc_flags());
|
||||
header = kzalloc(size + QDF_MEM_DEBUG_SIZE, flag);
|
||||
duration = qdf_mc_timer_get_system_time() - start;
|
||||
|
||||
if (duration > QDF_MEM_WARN_THRESHOLD)
|
||||
|
|
@ -1193,6 +1196,37 @@ void *qdf_mem_malloc(size_t size)
|
|||
}
|
||||
qdf_export_symbol(qdf_mem_malloc);
|
||||
|
||||
/**
|
||||
* qdf_mem_malloc_atomic() - allocation QDF memory atomically
|
||||
* @size: Number of bytes of memory to allocate.
|
||||
*
|
||||
* This function will dynamicallly allocate the specified number of bytes of
|
||||
* memory.
|
||||
*
|
||||
* Return:
|
||||
* Upon successful allocate, returns a non-NULL pointer to the allocated
|
||||
* memory. If this function is unable to allocate the amount of memory
|
||||
* specified (for any reason) it returns NULL.
|
||||
*/
|
||||
void *qdf_mem_malloc_atomic(size_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
ptr = qdf_mem_prealloc_get(size);
|
||||
if (ptr)
|
||||
return ptr;
|
||||
|
||||
ptr = kzalloc(size, GFP_ATOMIC);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
qdf_mem_kmalloc_inc(ksize(ptr));
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
qdf_export_symbol(qdf_mem_malloc_atomic);
|
||||
|
||||
/**
|
||||
* qdf_mem_free() - free QDF memory
|
||||
* @ptr: Pointer to the starting address of the memory to be free'd.
|
||||
|
|
|
|||
Loading…
Reference in a new issue