forked from mirrors/linux
		
	page-allocator: warn if __GFP_NOFAIL is used for a large allocation
__GFP_NOFAIL is a bad fiction. Allocations _can_ fail, and callers should detect and suitably handle this (and not by lamely moving the infinite loop up to the caller level either). Attempting to use __GFP_NOFAIL for a higher-order allocation is even worse, so add a once-off runtime check for this to slap people around for even thinking about trying it. Cc: David Rientjes <rientjes@google.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.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
							
								
									720b17e759
								
							
						
					
					
						commit
						dab48dab37
					
				
					 1 changed files with 13 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -1128,6 +1128,19 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
 | 
			
		|||
		list_del(&page->lru);
 | 
			
		||||
		pcp->count--;
 | 
			
		||||
	} else {
 | 
			
		||||
		if (unlikely(gfp_flags & __GFP_NOFAIL)) {
 | 
			
		||||
			/*
 | 
			
		||||
			 * __GFP_NOFAIL is not to be used in new code.
 | 
			
		||||
			 *
 | 
			
		||||
			 * All __GFP_NOFAIL callers should be fixed so that they
 | 
			
		||||
			 * properly detect and handle allocation failures.
 | 
			
		||||
			 *
 | 
			
		||||
			 * We most definitely don't want callers attempting to
 | 
			
		||||
			 * allocate greater than single-page units with
 | 
			
		||||
			 * __GFP_NOFAIL.
 | 
			
		||||
			 */
 | 
			
		||||
			WARN_ON_ONCE(order > 0);
 | 
			
		||||
		}
 | 
			
		||||
		spin_lock_irqsave(&zone->lock, flags);
 | 
			
		||||
		page = __rmqueue(zone, order, migratetype);
 | 
			
		||||
		__mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue