mm: Change global spinlock to per heap
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
9e4a1be8d4
commit
0c805ca0a9
@ -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 */
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 */
|
||||||
|
|
||||||
|
@ -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 */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user