mm: Add mm_lock_irq, mm_unlock_iq
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
parent
1d8ce18d7f
commit
91c71ed00a
5 changed files with 68 additions and 10 deletions
|
@ -282,6 +282,8 @@ typedef CODE void (*mm_node_handler_t)(FAR struct mm_allocnode_s *node,
|
|||
|
||||
int mm_lock(FAR struct mm_heap_s *heap);
|
||||
void mm_unlock(FAR struct mm_heap_s *heap);
|
||||
irqstate_t mm_lock_irq(FAR struct mm_heap_s *heap);
|
||||
void mm_unlock_irq(FAR struct mm_heap_s *heap, irqstate_t state);
|
||||
|
||||
/* Functions contained in mm_shrinkchunk.c **********************************/
|
||||
|
||||
|
|
|
@ -49,7 +49,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);
|
||||
|
||||
# ifdef CONFIG_DEBUG_ASSERTIONS
|
||||
FAR struct mm_freenode_s *node;
|
||||
|
@ -65,7 +65,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
|
||||
}
|
||||
|
||||
|
|
|
@ -117,3 +117,31 @@ void mm_unlock(FAR struct mm_heap_s *heap)
|
|||
|
||||
DEBUGVERIFY(nxmutex_unlock(&heap->mm_lock));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mm_lock_irq
|
||||
*
|
||||
* Description:
|
||||
* Locking by pausing interruption
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void mm_unlock_irq(FAR struct mm_heap_s *heap, irqstate_t state)
|
||||
{
|
||||
UNUSED(heap);
|
||||
up_irq_restore(state);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,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()];
|
||||
|
||||
|
@ -74,7 +74,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;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue