sched/note: add note when mm add new region
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com> Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
parent
c2bcc56546
commit
7e89ff5d11
@ -230,6 +230,7 @@ struct mm_heap_s *mm_initialize(const char *name,
|
|||||||
procfs_register_meminfo(&heap->mm_procfs);
|
procfs_register_meminfo(&heap->mm_procfs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
sched_note_heap(NOTE_HEAP_ADD, heap, heap_start, heap_size);
|
||||||
return heap;
|
return heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +252,10 @@ struct mm_heap_s *mm_initialize(const char *name,
|
|||||||
|
|
||||||
void mm_uninitialize(struct mm_heap_s *heap)
|
void mm_uninitialize(struct mm_heap_s *heap)
|
||||||
{
|
{
|
||||||
|
sched_note_heap(NOTE_HEAP_REMOVE, heap, heap_start,
|
||||||
|
(uintptr_t)heap->mm_heapend[0] -
|
||||||
|
(uintptr_t)heap->mm_heapstart[0]);
|
||||||
|
|
||||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||||
procfs_unregister_meminfo(&heap->mm_procfs);
|
procfs_unregister_meminfo(&heap->mm_procfs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1086,6 +1086,8 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
|
#ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP
|
||||||
|
case NOTE_HEAP_ADD:
|
||||||
|
case NOTE_HEAP_REMOVE:
|
||||||
case NOTE_HEAP_ALLOC:
|
case NOTE_HEAP_ALLOC:
|
||||||
case NOTE_HEAP_FREE:
|
case NOTE_HEAP_FREE:
|
||||||
{
|
{
|
||||||
@ -1094,21 +1096,22 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s,
|
|||||||
int used = 0;
|
int used = 0;
|
||||||
FAR const char *name[] =
|
FAR const char *name[] =
|
||||||
{
|
{
|
||||||
"malloc", "free"
|
"add", "remove", "malloc", "free"
|
||||||
};
|
};
|
||||||
|
|
||||||
tctx = noteram_dump_find_task_context(ctx, pid);
|
tctx = noteram_dump_find_task_context(ctx, pid);
|
||||||
if (tctx != NULL)
|
if (tctx != NULL)
|
||||||
{
|
{
|
||||||
tctx->mm_used += note->nc_type == NOTE_HEAP_FREE ?
|
tctx->mm_used += note->nc_type == NOTE_HEAP_FREE ? -nmm->size
|
||||||
-nmm->size : nmm->size;
|
: note->nc_type == NOTE_HEAP_ALLOC ? nmm->size
|
||||||
|
: 0;
|
||||||
used = tctx->mm_used;
|
used = tctx->mm_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += noteram_dump_header(s, &nmm->nmm_cmn, ctx);
|
ret += noteram_dump_header(s, &nmm->nmm_cmn, ctx);
|
||||||
ret += lib_sprintf(s, "tracing_mark_write: C|%d|Heap Usage|%d|%s"
|
ret += lib_sprintf(s, "tracing_mark_write: C|%d|Heap Usage|%d|%s"
|
||||||
": heap: %p size:%" PRIiPTR ", address: %p\n",
|
": heap: %p size:%" PRIiPTR ", address: %p\n",
|
||||||
pid, used, name[note->nc_type - NOTE_HEAP_ALLOC],
|
pid, used, name[note->nc_type - NOTE_HEAP_ADD],
|
||||||
nmm->heap, nmm->size, nmm->mem);
|
nmm->heap, nmm->size, nmm->mem);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -186,6 +186,8 @@ enum note_type_e
|
|||||||
NOTE_SYSCALL_LEAVE,
|
NOTE_SYSCALL_LEAVE,
|
||||||
NOTE_IRQ_ENTER,
|
NOTE_IRQ_ENTER,
|
||||||
NOTE_IRQ_LEAVE,
|
NOTE_IRQ_LEAVE,
|
||||||
|
NOTE_HEAP_ADD,
|
||||||
|
NOTE_HEAP_REMOVE,
|
||||||
NOTE_HEAP_ALLOC,
|
NOTE_HEAP_ALLOC,
|
||||||
NOTE_HEAP_FREE,
|
NOTE_HEAP_FREE,
|
||||||
NOTE_DUMP_STRING,
|
NOTE_DUMP_STRING,
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/sched_note.h>
|
||||||
#include <nuttx/mm/mm.h>
|
#include <nuttx/mm/mm.h>
|
||||||
#include <nuttx/mm/kasan.h>
|
#include <nuttx/mm/kasan.h>
|
||||||
|
|
||||||
@ -201,6 +202,8 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||||||
mm_addfreechunk(heap, node);
|
mm_addfreechunk(heap, node);
|
||||||
heap->mm_curused += 2 * MM_SIZEOF_ALLOCNODE;
|
heap->mm_curused += 2 * MM_SIZEOF_ALLOCNODE;
|
||||||
mm_unlock(heap);
|
mm_unlock(heap);
|
||||||
|
|
||||||
|
sched_note_heap(NOTE_HEAP_ADD, heap, heapstart, heapsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -366,6 +369,9 @@ void mm_uninitialize(FAR struct mm_heap_s *heap)
|
|||||||
for (i = 0; i < CONFIG_MM_REGIONS; i++)
|
for (i = 0; i < CONFIG_MM_REGIONS; i++)
|
||||||
{
|
{
|
||||||
kasan_unregister(heap->mm_heapstart[i]);
|
kasan_unregister(heap->mm_heapstart[i]);
|
||||||
|
sched_note_heap(NOTE_HEAP_REMOVE, heap, heap->mm_heapstart[i],
|
||||||
|
(uintptr_t)heap->mm_heapend[i] -
|
||||||
|
(uintptr_t)heap->mm_heapstart[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||||
|
@ -600,6 +600,8 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||||||
|
|
||||||
tlsf_add_pool(heap->mm_tlsf, heapstart, heapsize);
|
tlsf_add_pool(heap->mm_tlsf, heapstart, heapsize);
|
||||||
mm_unlock(heap);
|
mm_unlock(heap);
|
||||||
|
|
||||||
|
sched_note_heap(NOTE_HEAP_ADD, heap, heapstart, heapsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1439,6 +1441,9 @@ void mm_uninitialize(FAR struct mm_heap_s *heap)
|
|||||||
for (i = 0; i < CONFIG_MM_REGIONS; i++)
|
for (i = 0; i < CONFIG_MM_REGIONS; i++)
|
||||||
{
|
{
|
||||||
kasan_unregister(heap->mm_heapstart[i]);
|
kasan_unregister(heap->mm_heapstart[i]);
|
||||||
|
sched_note_heap(NOTE_HEAP_REMOVE, heap, heap->mm_heapstart[i],
|
||||||
|
(uintptr_t)heap->mm_heapend[i] -
|
||||||
|
(uintptr_t)heap->mm_heapstart[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
|
||||||
|
Loading…
Reference in New Issue
Block a user