Commit 7676ebba authored by Ingo Molnar's avatar Ingo Molnar

Merge branch 'perf/core' of...

Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
parents e710574d 981c1252
...@@ -1637,23 +1637,29 @@ static struct perf_event_ops event_ops = { ...@@ -1637,23 +1637,29 @@ static struct perf_event_ops event_ops = {
.ordered_samples = true, .ordered_samples = true,
}; };
static int read_events(void) static void read_events(bool destroy, struct perf_session **psession)
{ {
int err = -EINVAL; int err = -EINVAL;
struct perf_session *session = perf_session__new(input_name, O_RDONLY, struct perf_session *session = perf_session__new(input_name, O_RDONLY,
0, false, &event_ops); 0, false, &event_ops);
if (session == NULL) if (session == NULL)
return -ENOMEM; die("No Memory");
if (perf_session__has_traces(session, "record -R")) { if (perf_session__has_traces(session, "record -R")) {
err = perf_session__process_events(session, &event_ops); err = perf_session__process_events(session, &event_ops);
if (err)
die("Failed to process events, error %d", err);
nr_events = session->hists.stats.nr_events[0]; nr_events = session->hists.stats.nr_events[0];
nr_lost_events = session->hists.stats.total_lost; nr_lost_events = session->hists.stats.total_lost;
nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST]; nr_lost_chunks = session->hists.stats.nr_events[PERF_RECORD_LOST];
} }
perf_session__delete(session); if (destroy)
return err; perf_session__delete(session);
if (psession)
*psession = session;
} }
static void print_bad_events(void) static void print_bad_events(void)
...@@ -1689,9 +1695,10 @@ static void print_bad_events(void) ...@@ -1689,9 +1695,10 @@ static void print_bad_events(void)
static void __cmd_lat(void) static void __cmd_lat(void)
{ {
struct rb_node *next; struct rb_node *next;
struct perf_session *session;
setup_pager(); setup_pager();
read_events(); read_events(false, &session);
sort_lat(); sort_lat();
printf("\n ---------------------------------------------------------------------------------------------------------------\n"); printf("\n ---------------------------------------------------------------------------------------------------------------\n");
...@@ -1717,6 +1724,7 @@ static void __cmd_lat(void) ...@@ -1717,6 +1724,7 @@ static void __cmd_lat(void)
print_bad_events(); print_bad_events();
printf("\n"); printf("\n");
perf_session__delete(session);
} }
static struct trace_sched_handler map_ops = { static struct trace_sched_handler map_ops = {
...@@ -1731,7 +1739,7 @@ static void __cmd_map(void) ...@@ -1731,7 +1739,7 @@ static void __cmd_map(void)
max_cpu = sysconf(_SC_NPROCESSORS_CONF); max_cpu = sysconf(_SC_NPROCESSORS_CONF);
setup_pager(); setup_pager();
read_events(); read_events(true, NULL);
print_bad_events(); print_bad_events();
} }
...@@ -1744,7 +1752,7 @@ static void __cmd_replay(void) ...@@ -1744,7 +1752,7 @@ static void __cmd_replay(void)
test_calibrations(); test_calibrations();
read_events(); read_events(true, NULL);
printf("nr_run_events: %ld\n", nr_run_events); printf("nr_run_events: %ld\n", nr_run_events);
printf("nr_sleep_events: %ld\n", nr_sleep_events); printf("nr_sleep_events: %ld\n", nr_sleep_events);
...@@ -1769,7 +1777,7 @@ static void __cmd_replay(void) ...@@ -1769,7 +1777,7 @@ static void __cmd_replay(void)
static const char * const sched_usage[] = { static const char * const sched_usage[] = {
"perf sched [<options>] {record|latency|map|replay|trace}", "perf sched [<options>] {record|latency|map|replay|script}",
NULL NULL
}; };
......
...@@ -413,13 +413,32 @@ int perf_config(config_fn_t fn, void *data) ...@@ -413,13 +413,32 @@ int perf_config(config_fn_t fn, void *data)
home = getenv("HOME"); home = getenv("HOME");
if (perf_config_global() && home) { if (perf_config_global() && home) {
char *user_config = strdup(mkpath("%s/.perfconfig", home)); char *user_config = strdup(mkpath("%s/.perfconfig", home));
if (!access(user_config, R_OK)) { struct stat st;
ret += perf_config_from_file(fn, user_config, data);
found += 1; if (user_config == NULL) {
warning("Not enough memory to process %s/.perfconfig, "
"ignoring it.", home);
goto out;
}
if (stat(user_config, &st) < 0)
goto out_free;
if (st.st_uid && (st.st_uid != geteuid())) {
warning("File %s not owned by current user or root, "
"ignoring it.", user_config);
goto out_free;
} }
if (!st.st_size)
goto out_free;
ret += perf_config_from_file(fn, user_config, data);
found += 1;
out_free:
free(user_config); free(user_config);
} }
out:
if (found == 0) if (found == 0)
return -1; return -1;
return ret; return ret;
......
...@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) ...@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
dso->adjust_symbols = 0; dso->adjust_symbols = 0;
if (strncmp(dso->name, "/tmp/perf-", 10) == 0) { if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
struct stat st;
if (stat(dso->name, &st) < 0)
return -1;
if (st.st_uid && (st.st_uid != geteuid())) {
pr_warning("File %s not owned by current user or root, "
"ignoring it.\n", dso->name);
return -1;
}
ret = dso__load_perf_map(dso, map, filter); ret = dso__load_perf_map(dso, map, filter);
dso->symtab_type = ret > 0 ? SYMTAB__JAVA_JIT : dso->symtab_type = ret > 0 ? SYMTAB__JAVA_JIT :
SYMTAB__NOT_FOUND; SYMTAB__NOT_FOUND;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment