mm: Add mm_lock_irq, mm_unlock_iq

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
wangmingrong1
2025-01-10 18:34:06 +08:00
committed by Xiang Xiao
parent 1d8ce18d7f
commit 91c71ed00a
5 changed files with 68 additions and 10 deletions
+33 -5
View File
@@ -181,6 +181,34 @@ static void mm_delayfree(struct mm_heap_s *heap, void *mem, bool delay);
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: mm_lock_irq
*
* Description:
* Locking by pausing interruption
*
****************************************************************************/
static irqstate_t mm_lock_irq(FAR struct mm_heap_s *heap)
{
UNUSED(heap);
return up_irq_save();
}
/****************************************************************************
* Name: mm_unlock_irq
*
* Description:
* Release the lock by resuming the interrupt
*
****************************************************************************/
static void mm_unlock_irq(FAR struct mm_heap_s *heap, irqstate_t state)
{
UNUSED(heap);
up_irq_restore(state);
}
static void memdump_allocnode(FAR void *ptr, size_t size)
{
#if CONFIG_MM_BACKTRACE < 0
@@ -301,7 +329,7 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem)
/* Delay the deallocation until a more appropriate time. */
flags = up_irq_save();
flags = mm_lock_irq(heap);
tmp->flink = heap->mm_delaylist[this_cpu()];
heap->mm_delaylist[this_cpu()] = tmp;
@@ -310,7 +338,7 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem)
heap->mm_delaycount[this_cpu()]++;
#endif
up_irq_restore(flags);
mm_unlock_irq(heap, flags);
#endif
}
@@ -327,7 +355,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force)
/* Move the delay list to local */
flags = up_irq_save();
flags = mm_lock_irq(heap);
tmp = heap->mm_delaylist[this_cpu()];
@@ -336,7 +364,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force)
(!force &&
heap->mm_delaycount[this_cpu()] < CONFIG_MM_FREE_DELAYCOUNT_MAX))
{
up_irq_restore(flags);
mm_unlock_irq(heap, flags);
return false;
}
@@ -345,7 +373,7 @@ static bool free_delaylist(FAR struct mm_heap_s *heap, bool force)
heap->mm_delaylist[this_cpu()] = NULL;
up_irq_restore(flags);
mm_unlock_irq(heap, flags);
/* Test if the delayed is empty */