mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-11-01 09:13:37 +00:00 
			
		
		
		
	radix-tree: fix preload vector size
We are not preallocating a sufficient number of nodes. Signed-off-by: Nick Piggin <npiggin@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									fd0a37355c
								
							
						
					
					
						commit
						5536805292
					
				
					 1 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -72,12 +72,25 @@ static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH + 1] __read_mostly;
 | 
			
		|||
 */
 | 
			
		||||
static struct kmem_cache *radix_tree_node_cachep;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The radix tree is variable-height, so an insert operation not only has
 | 
			
		||||
 * to build the branch to its corresponding item, it also has to build the
 | 
			
		||||
 * branch to existing items if the size has to be increased (by
 | 
			
		||||
 * radix_tree_extend).
 | 
			
		||||
 *
 | 
			
		||||
 * The worst case is a zero height tree with just a single item at index 0,
 | 
			
		||||
 * and then inserting an item at index ULONG_MAX. This requires 2 new branches
 | 
			
		||||
 * of RADIX_TREE_MAX_PATH size to be created, with only the root node shared.
 | 
			
		||||
 * Hence:
 | 
			
		||||
 */
 | 
			
		||||
#define RADIX_TREE_PRELOAD_SIZE (RADIX_TREE_MAX_PATH * 2 - 1)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Per-cpu pool of preloaded nodes
 | 
			
		||||
 */
 | 
			
		||||
struct radix_tree_preload {
 | 
			
		||||
	int nr;
 | 
			
		||||
	struct radix_tree_node *nodes[RADIX_TREE_MAX_PATH];
 | 
			
		||||
	struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
 | 
			
		||||
};
 | 
			
		||||
static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue