mm: Change global spinlock to per heap

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-10-30 01:01:37 +08:00 committed by Petro Karashchenko
parent 9e4a1be8d4
commit 0c805ca0a9
4 changed files with 10 additions and 12 deletions

View File

@ -250,6 +250,7 @@ struct mm_heap_s
* immdiately. * immdiately.
*/ */
spinlock_t mm_spinlock;
FAR struct mm_delaynode_s *mm_delaylist[CONFIG_SMP_NCPUS]; FAR struct mm_delaynode_s *mm_delaylist[CONFIG_SMP_NCPUS];
/* The is a multiple mempool of the heap */ /* The is a multiple mempool of the heap */

View File

@ -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. */ /* 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()]; tmp->flink = heap->mm_delaylist[up_cpu_index()];
heap->mm_delaylist[up_cpu_index()] = tmp; heap->mm_delaylist[up_cpu_index()] = tmp;
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&heap->mm_spinlock, flags);
#endif #endif
} }

View File

@ -47,12 +47,12 @@ static void free_delaylist(FAR struct mm_heap_s *heap)
/* Move the delay list to local */ /* 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()]; tmp = heap->mm_delaylist[up_cpu_index()];
heap->mm_delaylist[up_cpu_index()] = NULL; 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 */ /* Test if the delayed is empty */

View File

@ -97,11 +97,8 @@ struct mm_heap_s
/* Free delay list, for some situation can't do free immdiately */ /* 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]; 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) #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMINFO)
struct procfs_meminfo_entry_s mm_procfs; 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. */ /* 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()]; tmp->flink = heap->mm_delaylist[up_cpu_index()];
heap->mm_delaylist[up_cpu_index()] = tmp; heap->mm_delaylist[up_cpu_index()] = tmp;
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&heap->mm_spinlock, flags);
#endif #endif
} }
@ -194,12 +191,12 @@ static void free_delaylist(FAR struct mm_heap_s *heap)
/* Move the delay list to local */ /* 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()]; tmp = heap->mm_delaylist[up_cpu_index()];
heap->mm_delaylist[up_cpu_index()] = NULL; 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 */ /* Test if the delayed is empty */