mm/mempool: Count the backtrace overhead in mempool_[dump|info[_task]]

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-05-28 22:01:43 +08:00 committed by Petro Karashchenko
parent e9738cd906
commit 0572bc4d03
2 changed files with 21 additions and 21 deletions

View File

@ -39,11 +39,11 @@
****************************************************************************/
#if CONFIG_MM_BACKTRACE >= 0
# define MEMPOOL_REALBLOCKSIZE(pool) (ALIGN_UP(pool->blocksize + \
sizeof(struct mempool_backtrace_s), \
pool->blockalign))
# define MEMPOOL_REALBLOCKSIZE(pool) (ALIGN_UP((pool)->blocksize + \
sizeof(struct mempool_backtrace_s), \
(pool)->blockalign))
#else
# define MEMPOOL_REALBLOCKSIZE(pool) (pool->blocksize)
# define MEMPOOL_REALBLOCKSIZE(pool) ((pool)->blocksize)
#endif
/****************************************************************************

View File

@ -143,11 +143,10 @@ int mempool_init(FAR struct mempool_s *pool, FAR const char *name)
pool->nalloc = 0;
#endif
if (pool->interruptsize > sizeof(sq_entry_t))
if (pool->interruptsize >= blocksize)
{
size_t ninterrupt = (pool->interruptsize - sizeof(sq_entry_t)) /
blocksize;
size_t size = ninterrupt * blocksize + sizeof(sq_entry_t);
size_t ninterrupt = pool->interruptsize / blocksize;
size_t size = ninterrupt * blocksize;
pool->ibase = pool->alloc(pool, size);
if (pool->ibase == NULL)
@ -356,6 +355,7 @@ void mempool_free(FAR struct mempool_s *pool, FAR void *blk)
int mempool_info(FAR struct mempool_s *pool, FAR struct mempoolinfo_s *info)
{
size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool);
irqstate_t flags;
DEBUGASSERT(pool != NULL && info != NULL);
@ -368,10 +368,10 @@ int mempool_info(FAR struct mempool_s *pool, FAR struct mempoolinfo_s *info)
#else
info->aordblks = pool->nalloc;
#endif
info->arena = (info->aordblks + info->ordblks + info->iordblks) *
pool->blocksize;
info->arena =
(info->aordblks + info->ordblks + info->iordblks) * blocksize;
spin_unlock_irqrestore(&pool->lock, flags);
info->sizeblks = pool->blocksize;
info->sizeblks = blocksize;
if (pool->wait && pool->expandsize == 0)
{
int semcount;
@ -395,6 +395,7 @@ struct mallinfo_task
mempool_info_task(FAR struct mempool_s *pool,
FAR const struct malltask *task)
{
size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool);
irqstate_t flags = spin_lock_irqsave(&pool->lock);
struct mallinfo_task info =
{
@ -407,13 +408,13 @@ mempool_info_task(FAR struct mempool_s *pool,
mempool_queue_lenth(&pool->iqueue);
info.aordblks += count;
info.uordblks += count * pool->blocksize;
info.uordblks += count * blocksize;
}
#if CONFIG_MM_BACKTRACE < 0
else if (task->pid == PID_MM_ALLOC)
{
info.aordblks += pool->nalloc;
info.uordblks += pool->nalloc * pool->blocksize;
info.uordblks += pool->nalloc * blocksize;
}
#else
else
@ -428,7 +429,7 @@ mempool_info_task(FAR struct mempool_s *pool,
buf->seqno >= task->seqmin && buf->seqno <= task->seqmax)
{
info.aordblks++;
info.uordblks += pool->blocksize;
info.uordblks += blocksize;
}
}
}
@ -460,6 +461,8 @@ mempool_info_task(FAR struct mempool_s *pool,
void mempool_memdump(FAR struct mempool_s *pool,
FAR const struct mm_memdump_s *dump)
{
size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool);
if (dump->pid == PID_MM_FREE)
{
FAR sq_entry_t *entry;
@ -467,15 +470,13 @@ void mempool_memdump(FAR struct mempool_s *pool,
sq_for_every(&pool->queue, entry)
{
syslog(LOG_INFO, "%12zu%*p\n",
pool->blocksize, MM_PTR_FMT_WIDTH,
(FAR char *)entry);
blocksize, MM_PTR_FMT_WIDTH, (FAR char *)entry);
}
sq_for_every(&pool->iqueue, entry)
{
syslog(LOG_INFO, "%12zu%*p\n",
pool->blocksize, MM_PTR_FMT_WIDTH,
(FAR char *)entry);
blocksize, MM_PTR_FMT_WIDTH, (FAR char *)entry);
}
}
#if CONFIG_MM_BACKTRACE >= 0
@ -506,9 +507,8 @@ void mempool_memdump(FAR struct mempool_s *pool,
# endif
syslog(LOG_INFO, "%6d%12zu%12lu%*p%s\n",
(int)buf->pid, pool->blocksize, buf->seqno,
MM_PTR_FMT_WIDTH,
((FAR char *)buf - pool->blocksize), bt);
(int)buf->pid, blocksize, buf->seqno,
MM_PTR_FMT_WIDTH, ((FAR char *)buf - blocksize), bt);
}
}
}