mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	mm/cma.c: remove redundant cma_mutex lock
The cma_mutex which protects alloc_contig_range() was first appeared in commit7ee793a62f("cma: Remove potential deadlock situation"), at that time, there is no guarantee the behavior of concurrency inside alloc_contig_range(). After commit2c7452a075("mm/page_isolation.c: make start_isolate_page_range() fail if already isolated") > However, two subsystems (CMA and gigantic > huge pages for example) could attempt operations on the same range. If > this happens, one thread may 'undo' the work another thread is doing. > This can result in pageblocks being incorrectly left marked as > MIGRATE_ISOLATE and therefore not available for page allocation. The concurrency inside alloc_contig_range() was clarified. Now we can find that hugepage and virtio call alloc_contig_range() without any lock, thus cma_mutex is "redundant" in cma_alloc() now. Link: https://lkml.kernel.org/r/20201020102241.3729-1-lecopzer.chen@mediatek.com Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com> Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: YJ Chiang <yj.chiang@mediatek.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									d85c6db4cc
								
							
						
					
					
						commit
						a4efc174b3
					
				
					 1 changed files with 1 additions and 3 deletions
				
			
		
							
								
								
									
										4
									
								
								mm/cma.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								mm/cma.c
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -38,7 +38,6 @@
 | 
			
		|||
 | 
			
		||||
struct cma cma_areas[MAX_CMA_AREAS];
 | 
			
		||||
unsigned cma_area_count;
 | 
			
		||||
static DEFINE_MUTEX(cma_mutex);
 | 
			
		||||
 | 
			
		||||
phys_addr_t cma_get_base(const struct cma *cma)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -454,10 +453,9 @@ struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align,
 | 
			
		|||
		mutex_unlock(&cma->lock);
 | 
			
		||||
 | 
			
		||||
		pfn = cma->base_pfn + (bitmap_no << cma->order_per_bit);
 | 
			
		||||
		mutex_lock(&cma_mutex);
 | 
			
		||||
		ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA,
 | 
			
		||||
				     GFP_KERNEL | (no_warn ? __GFP_NOWARN : 0));
 | 
			
		||||
		mutex_unlock(&cma_mutex);
 | 
			
		||||
 | 
			
		||||
		if (ret == 0) {
 | 
			
		||||
			page = pfn_to_page(pfn);
 | 
			
		||||
			break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue