diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h index f7c5549939..163aa46818 100644 --- a/mm/mm_heap/mm.h +++ b/mm/mm_heap/mm.h @@ -250,6 +250,7 @@ struct mm_heap_s * immdiately. */ + spinlock_t mm_spinlock; FAR struct mm_delaynode_s *mm_delaylist[CONFIG_SMP_NCPUS]; /* The is a multiple mempool of the heap */ diff --git a/mm/mm_heap/mm_free.c b/mm/mm_heap/mm_free.c index 7716c720ce..b41464da9f 100644 --- a/mm/mm_heap/mm_free.c +++ b/mm/mm_heap/mm_free.c @@ -45,12 +45,12 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) /* Delay the deallocation until a more appropriate time. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&heap->mm_spinlock); tmp->flink = heap->mm_delaylist[up_cpu_index()]; heap->mm_delaylist[up_cpu_index()] = tmp; - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&heap->mm_spinlock, flags); #endif } diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index c8c12a974d..df2624aba0 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -47,12 +47,12 @@ static void free_delaylist(FAR struct mm_heap_s *heap) /* Move the delay list to local */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&heap->mm_spinlock); tmp = heap->mm_delaylist[up_cpu_index()]; heap->mm_delaylist[up_cpu_index()] = NULL; - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&heap->mm_spinlock, flags); /* Test if the delayed is empty */ diff --git a/mm/tlsf/mm_tlsf.c b/mm/tlsf/mm_tlsf.c index 5d221a8e3d..0f93c2229f 100644 --- a/mm/tlsf/mm_tlsf.c +++ b/mm/tlsf/mm_tlsf.c @@ -97,11 +97,8 @@ struct mm_heap_s /* Free delay list, for some situation can't do free immdiately */ -#ifdef CONFIG_SMP + spinlock_t mm_spinlock; struct mm_delaynode_s *mm_delaylist[CONFIG_SMP_NCPUS]; -#else - struct mm_delaynode_s *mm_delaylist[1]; -#endif #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO) struct procfs_meminfo_entry_s mm_procfs; @@ -173,12 +170,12 @@ static void add_delaylist(FAR struct mm_heap_s *heap, FAR void *mem) /* Delay the deallocation until a more appropriate time. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&heap->mm_spinlock); tmp->flink = heap->mm_delaylist[up_cpu_index()]; heap->mm_delaylist[up_cpu_index()] = tmp; - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&heap->mm_spinlock, flags); #endif } @@ -194,12 +191,12 @@ static void free_delaylist(FAR struct mm_heap_s *heap) /* Move the delay list to local */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&heap->mm_spinlock); tmp = heap->mm_delaylist[up_cpu_index()]; heap->mm_delaylist[up_cpu_index()] = NULL; - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&heap->mm_spinlock, flags); /* Test if the delayed is empty */