mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	proc: add a reschedule point in proc_readfd_common()
User can pass an arbitrary large buffer to getdents().
It is typically a 32KB buffer used by libc scandir() implementation.
When scanning /proc/{pid}/fd, we can hold cpu way too long,
so add a cond_resched() to be kind with other tasks.
We've seen latencies of more than 50ms on real workloads.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
			
			
This commit is contained in:
		
							parent
							
								
									bc51b2a919
								
							
						
					
					
						commit
						3cc4a84e02
					
				
					 1 changed files with 1 additions and 0 deletions
				
			
		| 
						 | 
					@ -258,6 +258,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx,
 | 
				
			||||||
				     name, len, instantiate, p,
 | 
									     name, len, instantiate, p,
 | 
				
			||||||
				     (void *)(unsigned long)fd))
 | 
									     (void *)(unsigned long)fd))
 | 
				
			||||||
			goto out_fd_loop;
 | 
								goto out_fd_loop;
 | 
				
			||||||
 | 
							cond_resched();
 | 
				
			||||||
		rcu_read_lock();
 | 
							rcu_read_lock();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	rcu_read_unlock();
 | 
						rcu_read_unlock();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue