perf tools: Configurable per thread proc map processing time out
The time out to limit the individual proc map processing was hard code to 500ms. This patch introduce a new option --proc-map-timeout to make the time limit configurable. Signed-off-by: Kan Liang <kan.liang@intel.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Ying Huang <ying.huang@intel.com> Link: http://lkml.kernel.org/r/1434549071-25611-2-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
930e6fcd2b
commit
9d9cad763c
@@ -213,19 +213,19 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define PROC_MAP_PARSE_TIMEOUT (500 * 1000000ULL)
|
||||
|
||||
int perf_event__synthesize_mmap_events(struct perf_tool *tool,
|
||||
union perf_event *event,
|
||||
pid_t pid, pid_t tgid,
|
||||
perf_event__handler_t process,
|
||||
struct machine *machine,
|
||||
bool mmap_data)
|
||||
bool mmap_data,
|
||||
unsigned int proc_map_timeout)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
FILE *fp;
|
||||
unsigned long long t;
|
||||
bool truncation = false;
|
||||
unsigned long long timeout = proc_map_timeout * 1000000ULL;
|
||||
int rc = 0;
|
||||
|
||||
if (machine__is_default_guest(machine))
|
||||
@@ -258,8 +258,11 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
|
||||
if (fgets(bf, sizeof(bf), fp) == NULL)
|
||||
break;
|
||||
|
||||
if ((rdclock() - t) > PROC_MAP_PARSE_TIMEOUT) {
|
||||
pr_warning("Reading %s time out.\n", filename);
|
||||
if ((rdclock() - t) > timeout) {
|
||||
pr_warning("Reading %s time out. "
|
||||
"You may want to increase "
|
||||
"the time limit by --proc-map-timeout\n",
|
||||
filename);
|
||||
truncation = true;
|
||||
goto out;
|
||||
}
|
||||
@@ -404,7 +407,9 @@ static int __event__synthesize_thread(union perf_event *comm_event,
|
||||
pid_t pid, int full,
|
||||
perf_event__handler_t process,
|
||||
struct perf_tool *tool,
|
||||
struct machine *machine, bool mmap_data)
|
||||
struct machine *machine,
|
||||
bool mmap_data,
|
||||
unsigned int proc_map_timeout)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
DIR *tasks;
|
||||
@@ -421,7 +426,8 @@ static int __event__synthesize_thread(union perf_event *comm_event,
|
||||
return -1;
|
||||
|
||||
return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
|
||||
process, machine, mmap_data);
|
||||
process, machine, mmap_data,
|
||||
proc_map_timeout);
|
||||
}
|
||||
|
||||
if (machine__is_default_guest(machine))
|
||||
@@ -462,7 +468,7 @@ static int __event__synthesize_thread(union perf_event *comm_event,
|
||||
if (_pid == pid) {
|
||||
/* process the parent's maps too */
|
||||
rc = perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
|
||||
process, machine, mmap_data);
|
||||
process, machine, mmap_data, proc_map_timeout);
|
||||
if (rc)
|
||||
break;
|
||||
}
|
||||
@@ -476,7 +482,8 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
|
||||
struct thread_map *threads,
|
||||
perf_event__handler_t process,
|
||||
struct machine *machine,
|
||||
bool mmap_data)
|
||||
bool mmap_data,
|
||||
unsigned int proc_map_timeout)
|
||||
{
|
||||
union perf_event *comm_event, *mmap_event, *fork_event;
|
||||
int err = -1, thread, j;
|
||||
@@ -499,7 +506,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
|
||||
fork_event,
|
||||
threads->map[thread], 0,
|
||||
process, tool, machine,
|
||||
mmap_data)) {
|
||||
mmap_data, proc_map_timeout)) {
|
||||
err = -1;
|
||||
break;
|
||||
}
|
||||
@@ -525,7 +532,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
|
||||
fork_event,
|
||||
comm_event->comm.pid, 0,
|
||||
process, tool, machine,
|
||||
mmap_data)) {
|
||||
mmap_data, proc_map_timeout)) {
|
||||
err = -1;
|
||||
break;
|
||||
}
|
||||
@@ -542,7 +549,9 @@ out:
|
||||
|
||||
int perf_event__synthesize_threads(struct perf_tool *tool,
|
||||
perf_event__handler_t process,
|
||||
struct machine *machine, bool mmap_data)
|
||||
struct machine *machine,
|
||||
bool mmap_data,
|
||||
unsigned int proc_map_timeout)
|
||||
{
|
||||
DIR *proc;
|
||||
char proc_path[PATH_MAX];
|
||||
@@ -582,7 +591,8 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
|
||||
* one thread couldn't be synthesized.
|
||||
*/
|
||||
__event__synthesize_thread(comm_event, mmap_event, fork_event, pid,
|
||||
1, process, tool, machine, mmap_data);
|
||||
1, process, tool, machine, mmap_data,
|
||||
proc_map_timeout);
|
||||
}
|
||||
|
||||
err = 0;
|
||||
|
Reference in New Issue
Block a user