mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	perf: Disallow mmap() on per-task inherited events
Since we now have working per-task-per-cpu events for a while, disallow mmap() on per-task inherited events. Those things were a performance problem anyway, and doing away with it allows us to optimize the buffer somewhat by assuming there is only a single writer. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
		
							parent
							
								
									a19d35c11f
								
							
						
					
					
						commit
						c7920614ce
					
				
					 1 changed files with 8 additions and 0 deletions
				
			
		| 
						 | 
					@ -2593,6 +2593,14 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 | 
				
			||||||
	long user_extra, extra;
 | 
						long user_extra, extra;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Don't allow mmap() of inherited per-task counters. This would
 | 
				
			||||||
 | 
						 * create a performance issue due to all children writing to the
 | 
				
			||||||
 | 
						 * same buffer.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (event->cpu == -1 && event->attr.inherit)
 | 
				
			||||||
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!(vma->vm_flags & VM_SHARED))
 | 
						if (!(vma->vm_flags & VM_SHARED))
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue