qcacmn: Use qdf_flex_mem for scheduler messages
Currently, the scheduler thread keeps a large, pre-allocated array of messages for use in message posting. The vast majority of the time, however, the scheduler thread has zero or one messages pending in the queue. This leads to a huge memory overhead for nominal driver operation. Replace the current pre-allocated scheduler message pool with a hybrid static/dynamic approach. Change-Id: Ie942bacfef43edf142a9f35ad0309069096cda90 CRs-Fixed: 2204172
This commit is contained in:
@@ -63,29 +63,13 @@ struct scheduler_mq_type {
|
||||
QDF_MODULE_ID qid;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct scheduler_msg_wrapper - scheduler message wrapper
|
||||
* @msg_node: message node
|
||||
* @msg_buf: message buffer pointer
|
||||
*/
|
||||
struct scheduler_msg_wrapper {
|
||||
qdf_list_node_t msg_node;
|
||||
struct scheduler_msg *msg_buf;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct scheduler_mq_ctx - scheduler message queue context
|
||||
* @msg_buffers: array of message buffers
|
||||
* @msg_wrappers: array of message wrappers
|
||||
* @free_msg_q: free message queue
|
||||
* @sch_msg_q: scheduler message queue
|
||||
* @scheduler_msg_qid_to_qidx: message qid to qidx mapping
|
||||
* @scheduler_msg_process_fn: array of message queue handler function pointers
|
||||
*/
|
||||
struct scheduler_mq_ctx {
|
||||
struct scheduler_msg msg_buffers[SCHEDULER_CORE_MAX_MESSAGES];
|
||||
struct scheduler_msg_wrapper msg_wrappers[SCHEDULER_CORE_MAX_MESSAGES];
|
||||
struct scheduler_mq_type free_msg_q;
|
||||
struct scheduler_mq_type sch_msg_q[SCHEDULER_NUMBER_OF_MSG_QUEUE];
|
||||
uint8_t scheduler_msg_qid_to_qidx[QDF_MODULE_ID_MAX];
|
||||
QDF_STATUS (*scheduler_msg_process_fn[SCHEDULER_NUMBER_OF_MSG_QUEUE])
|
||||
@@ -128,6 +112,23 @@ struct scheduler_ctx {
|
||||
void *watchdog_callback;
|
||||
};
|
||||
|
||||
/**
|
||||
* scheduler_core_msg_dup() duplicate the given scheduler message
|
||||
* @msg: the message to duplicated
|
||||
*
|
||||
* Note: Duplicated messages must be freed using scheduler_core_msg_free().
|
||||
*
|
||||
* Return: pointer to the duplicated message
|
||||
*/
|
||||
struct scheduler_msg *scheduler_core_msg_dup(struct scheduler_msg *msg);
|
||||
|
||||
/**
|
||||
* scheduler_core_msg_free() - free the given scheduler message
|
||||
* @msg: the duplicated message to free
|
||||
*
|
||||
* Return: None
|
||||
*/
|
||||
void scheduler_core_msg_free(struct scheduler_msg *msg);
|
||||
|
||||
/**
|
||||
* scheduler_get_context() - to get scheduler context
|
||||
@@ -137,6 +138,7 @@ struct scheduler_ctx {
|
||||
* Return: Pointer to scheduler context
|
||||
*/
|
||||
struct scheduler_ctx *scheduler_get_context(void);
|
||||
|
||||
/**
|
||||
* scheduler_thread() - spawned thread will execute this routine
|
||||
* @arg: pointer to scheduler context
|
||||
@@ -147,17 +149,6 @@ struct scheduler_ctx *scheduler_get_context(void);
|
||||
*/
|
||||
int scheduler_thread(void *arg);
|
||||
|
||||
/**
|
||||
* scheduler_cleanup_queues() - to clean up the given module's queue
|
||||
* @sch_ctx: pointer to scheduler context
|
||||
* @idx: index of the queue which needs to be cleanup.
|
||||
*
|
||||
* This routine is used to clean the module's queue provided by
|
||||
* user through idx field
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
void scheduler_cleanup_queues(struct scheduler_ctx *sch_ctx, int idx);
|
||||
/**
|
||||
* scheduler_create_ctx() - to create scheduler context
|
||||
*
|
||||
@@ -174,28 +165,11 @@ QDF_STATUS scheduler_create_ctx(void);
|
||||
* Return: QDF_STATUS based on success or failure
|
||||
*/
|
||||
QDF_STATUS scheduler_destroy_ctx(void);
|
||||
/**
|
||||
* scheduler_mq_init() - initialize scheduler message queue
|
||||
* @msg_q: Pointer to the message queue
|
||||
*
|
||||
* This function initializes the Message queue.
|
||||
*
|
||||
* Return: qdf status
|
||||
*/
|
||||
QDF_STATUS scheduler_mq_init(struct scheduler_mq_type *msg_q);
|
||||
/**
|
||||
* scheduler_mq_deinit() - de-initialize scheduler message queue
|
||||
* @msg_q: Pointer to the message queue
|
||||
*
|
||||
* This function de-initializes scheduler message queue
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
void scheduler_mq_deinit(struct scheduler_mq_type *msg_q);
|
||||
|
||||
/**
|
||||
* scheduler_mq_put() - put message in the back of queue
|
||||
* @msg_q: Pointer to the message queue
|
||||
* @msg_wrapper: pointer to message wrapper
|
||||
* @msg: the message to enqueue
|
||||
*
|
||||
* This function is used to put message in back of provided message
|
||||
* queue
|
||||
@@ -203,11 +177,11 @@ void scheduler_mq_deinit(struct scheduler_mq_type *msg_q);
|
||||
* Return: none
|
||||
*/
|
||||
void scheduler_mq_put(struct scheduler_mq_type *msg_q,
|
||||
struct scheduler_msg_wrapper *msg_wrapper);
|
||||
struct scheduler_msg *msg);
|
||||
/**
|
||||
* scheduler_mq_put_front() - put message in the front of queue
|
||||
* @msg_q: Pointer to the message queue
|
||||
* @msg_wrapper: pointer to message wrapper
|
||||
* @msg: the message to enqueue
|
||||
*
|
||||
* This function is used to put message in front of provided message
|
||||
* queue
|
||||
@@ -215,7 +189,7 @@ void scheduler_mq_put(struct scheduler_mq_type *msg_q,
|
||||
* Return: none
|
||||
*/
|
||||
void scheduler_mq_put_front(struct scheduler_mq_type *msg_q,
|
||||
struct scheduler_msg_wrapper *msg_wrapper);
|
||||
struct scheduler_msg *msg);
|
||||
/**
|
||||
* scheduler_mq_get() - to get message from message queue
|
||||
* @msg_q: Pointer to the message queue
|
||||
@@ -224,16 +198,8 @@ void scheduler_mq_put_front(struct scheduler_mq_type *msg_q,
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
struct scheduler_msg_wrapper *scheduler_mq_get(struct scheduler_mq_type *msg_q);
|
||||
/**
|
||||
* scheduler_is_mq_empty() - to check if message queue is empty
|
||||
* @msg_q: Pointer to the message queue
|
||||
*
|
||||
* This function is used to check if message queue is empty
|
||||
*
|
||||
* Return: true or false
|
||||
*/
|
||||
bool scheduler_is_mq_empty(struct scheduler_mq_type *msg_q);
|
||||
struct scheduler_msg *scheduler_mq_get(struct scheduler_mq_type *msg_q);
|
||||
|
||||
/**
|
||||
* scheduler_queues_init() - to initialize all the modules' queues
|
||||
* @sched_ctx: pointer to scheduler context
|
||||
@@ -243,6 +209,7 @@ bool scheduler_is_mq_empty(struct scheduler_mq_type *msg_q);
|
||||
* Return: QDF_STATUS based on success of failure
|
||||
*/
|
||||
QDF_STATUS scheduler_queues_init(struct scheduler_ctx *sched_ctx);
|
||||
|
||||
/**
|
||||
* scheduler_queues_deinit() - to de-initialize all the modules' queues
|
||||
* @sched_ctx: pointer to scheduler context
|
||||
@@ -252,4 +219,14 @@ QDF_STATUS scheduler_queues_init(struct scheduler_ctx *sched_ctx);
|
||||
* Return: QDF_STATUS based on success of failure
|
||||
*/
|
||||
QDF_STATUS scheduler_queues_deinit(struct scheduler_ctx *gp_sch_ctx);
|
||||
|
||||
/**
|
||||
* scheduler_queues_flush() - flush all of the scheduler queues
|
||||
* @sch_ctx: pointer to scheduler context
|
||||
*
|
||||
* This routine is used to clean the module's queues
|
||||
*
|
||||
* Return: none
|
||||
*/
|
||||
void scheduler_queues_flush(struct scheduler_ctx *sched_ctx);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user