mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	Revert "fs/pipe: use kvcalloc to allocate a pipe_buffer array"
This reverts commit 5a519c8fe4.
It turns out that making the pipe almost arbitrarily large has some
rather unexpected downsides.  The kernel test robot reports a kernel
warning that is due to pipe->max_usage now growing to the point where
the iter_file_splice_write() buffer allocation can no longer be
satisfied as a slab allocation, and the
        int nbufs = pipe->max_usage;
        struct bio_vec *array = kcalloc(nbufs, sizeof(struct bio_vec),
                                        GFP_KERNEL);
code sequence there will now always fail as a result.
That code could be modified to use kvcalloc() too, but I feel very
uncomfortable making those kinds of changes for a very niche use case
that really should have other options than make these kinds of
fundamental changes to pipe behavior.
Maybe the CRIU process dumping should be multi-threaded, and use
multiple pipes and multiple cores, rather than try to use one larger
pipe to minimize splice() calls.
Reported-by: kernel test robot <oliver.sang@intel.com>
Link: https://lore.kernel.org/all/20220420073717.GD16310@xsang-OptiPlex-9020/
Cc: Andrei Vagin <avagin@gmail.com>
Cc: Dmitry Safonov <0x7f454c46@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
			
			
This commit is contained in:
		
							parent
							
								
									a6823e4e36
								
							
						
					
					
						commit
						906f904097
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -804,7 +804,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
 | 
				
			||||||
	if (too_many_pipe_buffers_hard(user_bufs) && pipe_is_unprivileged_user())
 | 
						if (too_many_pipe_buffers_hard(user_bufs) && pipe_is_unprivileged_user())
 | 
				
			||||||
		goto out_revert_acct;
 | 
							goto out_revert_acct;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pipe->bufs = kvcalloc(pipe_bufs, sizeof(struct pipe_buffer),
 | 
						pipe->bufs = kcalloc(pipe_bufs, sizeof(struct pipe_buffer),
 | 
				
			||||||
			     GFP_KERNEL_ACCOUNT);
 | 
								     GFP_KERNEL_ACCOUNT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pipe->bufs) {
 | 
						if (pipe->bufs) {
 | 
				
			||||||
| 
						 | 
					@ -849,7 +849,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	if (pipe->tmp_page)
 | 
						if (pipe->tmp_page)
 | 
				
			||||||
		__free_page(pipe->tmp_page);
 | 
							__free_page(pipe->tmp_page);
 | 
				
			||||||
	kvfree(pipe->bufs);
 | 
						kfree(pipe->bufs);
 | 
				
			||||||
	kfree(pipe);
 | 
						kfree(pipe);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1264,7 +1264,8 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
 | 
				
			||||||
	if (nr_slots < n)
 | 
						if (nr_slots < n)
 | 
				
			||||||
		return -EBUSY;
 | 
							return -EBUSY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bufs = kvcalloc(nr_slots, sizeof(*bufs), GFP_KERNEL_ACCOUNT);
 | 
						bufs = kcalloc(nr_slots, sizeof(*bufs),
 | 
				
			||||||
 | 
							       GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
 | 
				
			||||||
	if (unlikely(!bufs))
 | 
						if (unlikely(!bufs))
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1291,7 +1292,7 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
 | 
				
			||||||
	head = n;
 | 
						head = n;
 | 
				
			||||||
	tail = 0;
 | 
						tail = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvfree(pipe->bufs);
 | 
						kfree(pipe->bufs);
 | 
				
			||||||
	pipe->bufs = bufs;
 | 
						pipe->bufs = bufs;
 | 
				
			||||||
	pipe->ring_size = nr_slots;
 | 
						pipe->ring_size = nr_slots;
 | 
				
			||||||
	if (pipe->max_usage > nr_slots)
 | 
						if (pipe->max_usage > nr_slots)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue