Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuttxgdb memory commands performance optimization #14916

Merged
merged 10 commits into from
Nov 24, 2024
15 changes: 9 additions & 6 deletions mm/mempool/mempool.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ static void mempool_memdump_callback(FAR struct mempool_s *pool,
FAR const void *input, FAR void *output)
{
size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool);
size_t overhead = blocksize - pool->blocksize;
FAR const struct mm_memdump_s *dump = input;

if (buf->magic == MEMPOOL_MAGIC_FREE)
Expand All @@ -206,8 +207,8 @@ static void mempool_memdump_callback(FAR struct mempool_s *pool,
FAR const char *tmp = "";
# endif

syslog(LOG_INFO, "%6d%12zu%12lu%*p%s\n",
buf->pid, blocksize, buf->seqno,
syslog(LOG_INFO, "%6d%12zu%9zu%12lu%*p %s\n",
buf->pid, blocksize, overhead, buf->seqno,
BACKTRACE_PTR_FMT_WIDTH,
((FAR char *)buf - pool->blocksize), tmp);
}
Expand All @@ -219,11 +220,12 @@ mempool_memdump_free_callback(FAR struct mempool_s *pool,
FAR const void *input, FAR void *output)
{
size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool);
size_t overhead = blocksize - pool->blocksize;

if (buf->magic == MEMPOOL_MAGIC_FREE)
{
syslog(LOG_INFO, "%12zu%*p\n",
blocksize, BACKTRACE_PTR_FMT_WIDTH,
syslog(LOG_INFO, "%12zu%9zu%*p\n",
blocksize, overhead, BACKTRACE_PTR_FMT_WIDTH,
((FAR char *)buf - pool->blocksize));
}
}
Expand Down Expand Up @@ -587,11 +589,12 @@ void mempool_memdump(FAR struct mempool_s *pool,
}
#else
size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool);
size_t overhead = blocksize - pool->blocksize;

/* Avoid race condition */

syslog(LOG_INFO, "%12zu%*p skip block dump\n",
blocksize, BACKTRACE_PTR_FMT_WIDTH, pool);
syslog(LOG_INFO, "%12zu%9zu%*p skip block dump\n",
blocksize, overhead, BACKTRACE_PTR_FMT_WIDTH, pool);
#endif
}

Expand Down
26 changes: 15 additions & 11 deletions mm/mm_heap/mm_memdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ struct mm_memdump_priv_s
static void memdump_allocnode(FAR struct mm_allocnode_s *node)
{
size_t nodesize = MM_SIZEOF_NODE(node);
size_t overhead = MM_SIZEOF_ALLOCNODE;
#if CONFIG_MM_BACKTRACE < 0
syslog(LOG_INFO, "%12zu%*p\n",
nodesize, BACKTRACE_PTR_FMT_WIDTH,
syslog(LOG_INFO, "%12zu%9zu%*p\n",
nodesize, overhead, BACKTRACE_PTR_FMT_WIDTH,
(FAR const char *)node + MM_SIZEOF_ALLOCNODE);
#elif CONFIG_MM_BACKTRACE == 0
syslog(LOG_INFO, "%6d%12zu%12lu%*p\n",
node->pid, nodesize, node->seqno,
syslog(LOG_INFO, "%6d%12zu%9zu%12lu%*p\n",
node->pid, nodesize, overhead, node->seqno,
BACKTRACE_PTR_FMT_WIDTH,
(FAR const char *)node + MM_SIZEOF_ALLOCNODE);
#else
Expand All @@ -75,8 +76,8 @@ static void memdump_allocnode(FAR struct mm_allocnode_s *node)
backtrace_format(buf, sizeof(buf), node->backtrace,
CONFIG_MM_BACKTRACE);

syslog(LOG_INFO, "%6d%12zu%12lu%*p %s\n",
node->pid, nodesize, node->seqno,
syslog(LOG_INFO, "%6d%12zu%9zu%12lu%*p %s\n",
node->pid, nodesize, overhead, node->seqno,
BACKTRACE_PTR_FMT_WIDTH,
(FAR const char *)node + MM_SIZEOF_ALLOCNODE, buf);
#endif
Expand Down Expand Up @@ -202,8 +203,8 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg)

priv->info.aordblks++;
priv->info.uordblks += nodesize;
syslog(LOG_INFO, "%12zu%*p\n",
nodesize, BACKTRACE_PTR_FMT_WIDTH,
syslog(LOG_INFO, "%12zu%9zu%*p\n",
nodesize, MM_ALLOCNODE_OVERHEAD, BACKTRACE_PTR_FMT_WIDTH,
((FAR char *)node + MM_SIZEOF_ALLOCNODE));
}
}
Expand Down Expand Up @@ -288,10 +289,13 @@ void mm_memdump(FAR struct mm_heap_s *heap,
}

#if CONFIG_MM_BACKTRACE < 0
syslog(LOG_INFO, "%12s%*s\n", "Size", BACKTRACE_PTR_FMT_WIDTH, "Address");
syslog(LOG_INFO, "%12s%9s%*s\n", "Size", "Overhead",
BACKTRACE_PTR_FMT_WIDTH,
"Address");
#else
syslog(LOG_INFO, "%6s%12s%12s%*s %s\n", "PID", "Size", "Sequence",
BACKTRACE_PTR_FMT_WIDTH, "Address", "Backtrace");
syslog(LOG_INFO, "%6s%12s%9s%12s%*s %s\n", "PID", "Size", "Overhead",
"Sequence", BACKTRACE_PTR_FMT_WIDTH,
"Address", "Backtrace");
#endif

memdump_dump_pool(&priv, heap);
Expand Down
Loading
Loading