kernel: memslab: Add maximum mem_slab utilization trace
Add new function to mem_slab API that enables user to get maximum number of slabs used so far. Signed-off-by: Kamil Lazowski <Kamil.Lazowski@nordicsemi.no>
This commit is contained in:
parent
cc0c58c3af
commit
104f100749
4 changed files with 40 additions and 1 deletions
|
@ -4260,6 +4260,9 @@ struct k_mem_slab {
|
|||
char *buffer;
|
||||
char *free_list;
|
||||
uint32_t num_used;
|
||||
#ifdef CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION
|
||||
uint32_t max_used;
|
||||
#endif
|
||||
|
||||
_OBJECT_TRACING_NEXT_PTR(k_mem_slab)
|
||||
_OBJECT_TRACING_LINKED_FLAG
|
||||
|
@ -4388,6 +4391,26 @@ static inline uint32_t k_mem_slab_num_used_get(struct k_mem_slab *slab)
|
|||
return slab->num_used;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the number of maximum used blocks so far in a memory slab.
|
||||
*
|
||||
* This routine gets the maximum number of memory blocks that were
|
||||
* allocated in @a slab.
|
||||
*
|
||||
* @param slab Address of the memory slab.
|
||||
*
|
||||
* @return Maximum number of allocated memory blocks.
|
||||
*/
|
||||
static inline uint32_t k_mem_slab_max_used_get(struct k_mem_slab *slab)
|
||||
{
|
||||
#ifdef CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION
|
||||
return slab->max_used;
|
||||
#else
|
||||
ARG_UNUSED(slab);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the number of unused blocks in a memory slab.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue