perf events: Change perf parameter --pid to process-wide collection instead of thread-wide
Parameter --pid (or -p) of perf currently means a thread-wide collection. For exmaple, if a process whose id is 8888 has 10 threads, 'perf top -p 8888' just collects the main thread statistics. That's misleading. Users are used to attach a whole process when debugging a process by gdb. To follow normal usage style, the patch change --pid to process-wide collection and add --tid (-t) to mean a thread-wide collection. Usage example is: # perf top -p 8888 # perf record -p 8888 -f sleep 10 # perf stat -p 8888 -f sleep 10 Above commands collect the statistics of all threads of process 8888. Signed-off-by: Zhang Yanmin <yanmin_zhang@linux.intel.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Avi Kivity <avi@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Sheng Yang <sheng@linux.intel.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Jes Sorensen <Jes.Sorensen@redhat.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Cc: zhiteng.huang@intel.com Cc: Zachary Amsden <zamsden@redhat.com> LKML-Reference: <1268922965-14774-3-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
		
					parent
					
						
							
								46be604b5b
							
						
					
				
			
			
				commit
				
					
						d6d901c23a
					
				
			
		
					 5 changed files with 366 additions and 187 deletions
				
			
		|  | @ -7,6 +7,37 @@ | |||
| #include "util.h" | ||||
| #include "debug.h" | ||||
| 
 | ||||
| int find_all_tid(int pid, pid_t ** all_tid) | ||||
| { | ||||
| 	char name[256]; | ||||
| 	int items; | ||||
| 	struct dirent **namelist = NULL; | ||||
| 	int ret = 0; | ||||
| 	int i; | ||||
| 
 | ||||
| 	sprintf(name, "/proc/%d/task", pid); | ||||
| 	items = scandir(name, &namelist, NULL, NULL); | ||||
| 	if (items <= 0) | ||||
|                 return -ENOENT; | ||||
| 	*all_tid = malloc(sizeof(pid_t) * items); | ||||
| 	if (!*all_tid) { | ||||
| 		ret = -ENOMEM; | ||||
| 		goto failure; | ||||
| 	} | ||||
| 
 | ||||
| 	for (i = 0; i < items; i++) | ||||
| 		(*all_tid)[i] = atoi(namelist[i]->d_name); | ||||
| 
 | ||||
| 	ret = items; | ||||
| 
 | ||||
| failure: | ||||
| 	for (i=0; i<items; i++) | ||||
| 		free(namelist[i]); | ||||
| 	free(namelist); | ||||
| 
 | ||||
| 	return ret; | ||||
| } | ||||
| 
 | ||||
| void map_groups__init(struct map_groups *self) | ||||
| { | ||||
| 	int i; | ||||
|  | @ -348,3 +379,4 @@ struct symbol *map_groups__find_symbol(struct map_groups *self, | |||
| 
 | ||||
| 	return NULL; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ struct thread { | |||
| 	int			comm_len; | ||||
| }; | ||||
| 
 | ||||
| int find_all_tid(int pid, pid_t ** all_tid); | ||||
| void map_groups__init(struct map_groups *self); | ||||
| int thread__set_comm(struct thread *self, const char *comm); | ||||
| int thread__comm_len(struct thread *self); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Zhang, Yanmin
				Zhang, Yanmin