xiaoqizhan commented on code in PR #18468:
URL: https://github.com/apache/nuttx/pull/18468#discussion_r2871594351


##########
mm/mm_heap/mm_memdump.c:
##########
@@ -301,6 +324,18 @@ void mm_memdump(FAR struct mm_heap_s *heap,
     {
       syslog(LOG_INFO, "Dump allocated orphan nodes\n");
     }
+#if CONFIG_MM_BACKTRACE >= 0
+  else if (pid == PID_MM_ALL_PID)
+    {
+      syslog(LOG_INFO, "Dump all pid memory allocated\n");
+      struct memdump_tcb_arg_s tcb_arg;
+      tcb_arg.heap = heap;
+      tcb_arg.seqmin = dump->seqmin;
+      tcb_arg.seqmax = dump->seqmax;
+      nxsched_foreach(memdump_tcb_handler, &tcb_arg);

Review Comment:
   @xiaoxiang781216 
   Thank you for your review and feedback. If the memdump_handler method is 
used, it will further call memdump_allocnode, which dumps detailed information 
of each node (including call stacks and other logs), which does not meet the 
current requirements. Additionally, in my patch, it calls mm_foreach(heap, 
mallinfo_task_handler, &handle) to traverse all memory nodes of the heap and 
perform statistics, without recording or outputting any other extra information.
   In terms of the number of loops: a total of 3 loops are required: 
nxsched_foreach traverses the corresponding pid, mm_foreach traverses 
mm_nregions of the corresponding heap, and then traverses memory nodes based on 
each region to execute the callback function for statistics. The 
implementations of memdump_handler and mallinfo_task_handler are basically 
similar.
   In the native implementation, when using the memdump pid command, traversal 
is performed via mm_foreach(heap, memdump_handler, &priv), which also involves 
two loops: traversing mm_nregions of the corresponding heap, and then 
traversing memory nodes based on each region. To obtain the memory information 
for all PIDs, an additional loop level is required, so the total number of 
loops remains three.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to