static void kdbg_heapinfo_task(FAR struct tcb_s *tcb, FAR void *arg)
{
- if (tcb->pid == 0) {
- tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE;
- }
- printf("%3d | ", tcb->pid);
+ struct mm_allocnode_s *node;
+ node = (struct mm_allocnode_s *)(tcb->stack_alloc_ptr - SIZEOF_MM_ALLOCNODE);
+
+ printf("%3d", tcb->pid);
#if defined(CONFIG_SCHED_HAVE_PARENT) && !defined(HAVE_GROUP_MEMBERS)
- printf("%5d | ", tcb->ppid);
+ printf(" | %5d", tcb->ppid);
#endif
- printf("%5d | %9d | %9d | ", tcb->adj_stack_size, tcb->curr_alloc_size, tcb->peak_alloc_size);
+ if (tcb->pid == 0) {
+ printf(" | %5d", CONFIG_IDLETHREAD_STACKSIZE);
+ } else {
+ printf(" | %5d", node->size);
+ }
+ printf(" | %9d | %9d", tcb->curr_alloc_size, tcb->peak_alloc_size);
/* Show task name and arguments */
#if CONFIG_TASK_NAME_SIZE > 0
- printf("%s(", tcb->name);
+ printf(" | %s(", tcb->name);
#else
printf("<noname>(");
#endif
printf("-------|-----------|-----------|----------\n");
sched_foreach(kdbg_heapinfo_task, NULL);
+ printf("\n** NOTED **\n");
+ printf("* Idle Task's stack is not allocated in heap region\n");
+ printf("* And another stack size is allocated stack size + alloc node size(task:32/pthread:20)\n\n");
return OK;
usage:
#ifdef CONFIG_STACK_COLORATION
up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size);
#endif
-
+#ifdef CONFIG_DEBUG_MM_HEAPINFO
+ heapinfo_exclude_stacksize(tcb->stack_alloc_ptr);
+#endif
board_led_on(LED_STACKCREATED);
return OK;
}
void heapinfo_add_size(pid_t pid, mmsize_t size);
void heapinfo_subtract_size(pid_t pid, mmsize_t size);
void heapinfo_update_total_size(struct mm_heap_s *heap, mmsize_t size);
+void heapinfo_exclude_stacksize(void *stack_ptr);
#endif
#ifdef CONFIG_DEBUG_MM_HEAPINFO
size_t mxordblk = 0;
int ordblks = 0; /* Number of non-inuse chunks */
size_t fordblks = 0; /* Total non-inuse space */
+ int stack_resource;
int nonsched_resource;
int nonsched_idx;
#else
#define region 0
#endif
- /* initialize the nonsched */
+ /* initialize the nonsched and stack resource */
nonsched_resource = 0;
+ stack_resource = 0;
for (nonsched_idx = 0; nonsched_idx < CONFIG_MAX_TASKS; nonsched_idx++) {
nonsched_list[nonsched_idx] = -1;
nonsched_size[nonsched_idx] = 0;
#if CONFIG_TASK_NAME_SIZE > 0
if (node->pid == -1 && mode != HEAPINFO_SIMPLE) {
printf("INT Context\n");
+ } else if (node->pid == -2) {
+ stack_resource += node->size;
} else if (sched_gettcb(node->pid) == NULL) {
nonsched_list[MM_PIDHASH(node->pid)] = node->pid;
nonsched_size[MM_PIDHASH(node->pid)] += node->size;
printf("Free Size : %d\n", fordblks);
printf("Largest Free Node Size : %d\n", mxordblk);
printf("Number of Free Node : %d\n", ordblks);
+ printf("\nStack Resources : %d", stack_resource);
printf("\nNon Scheduled Task Resources : %d\n", nonsched_resource);
if (mode != HEAPINFO_SIMPLE) {
}
return;
}
+
+/****************************************************************************
+ * Name: heapinfo_exclude_stacksize
+ *
+ * Description:
+ * when create a stack, subtract the stacksize from parent
+ ****************************************************************************/
+void heapinfo_exclude_stacksize(void *stack_ptr)
+{
+ struct mm_allocnode_s *node;
+ struct tcb_s *rtcb;
+
+ node = (struct mm_allocnode_s *)(stack_ptr - SIZEOF_MM_ALLOCNODE);
+ rtcb = sched_gettcb(node->pid);
+
+ rtcb->curr_alloc_size -= node->size;
+ node->pid = -2;
+}
#endif