提交 b13fa914 编写于 作者: I Ingo Molnar

Merge tag 'perf-core-for-mingo' of...

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/core

Pull perf/core improvements and fixes from Jiri Olsa:

  * Warn the user when trace command is not available (Arnaldo Carvalho de Melo)

  * Add warning when disabling perl scripting support due to missing devel files (Arnaldo Carvalho de Melo)

  * Consider header files outside perf directory in tags target (Sebastian Andrzej Siewior)

  * Allow overriding sysfs and proc finding with env var (Cody P Schafer)

  * Fix "==" into "=" in ui_browser__warning assignment (zhangdianfang)

  * Factor elide bool handling in sort code (Jiri Olsa)

  * Fix poll return value propagation (Jiri Olsa)

  * Fix 'make help' message error (Jianyu Zhan)
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Signed-off-by: NIngo Molnar <mingo@kernel.org>
/* TODO merge/factor in debugfs.c here */
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/vfs.h>
......@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
return false;
}
static void mem_toupper(char *f, size_t len)
{
while (len) {
*f = toupper(*f);
f++;
len--;
}
}
/*
* Check for "NAME_PATH" environment variable to override fs location (for
* testing). This matches the recommendation in Documentation/sysfs-rules.txt
* for SYSFS_PATH.
*/
static bool fs__env_override(struct fs *fs)
{
char *override_path;
size_t name_len = strlen(fs->name);
/* name + "_PATH" + '\0' */
char upper_name[name_len + 5 + 1];
memcpy(upper_name, fs->name, name_len);
mem_toupper(upper_name, name_len);
strcpy(&upper_name[name_len], "_PATH");
override_path = getenv(upper_name);
if (!override_path)
return false;
fs->found = true;
strncpy(fs->path, override_path, sizeof(fs->path));
return true;
}
static const char *fs__get_mountpoint(struct fs *fs)
{
if (fs__env_override(fs))
return fs->path;
if (fs__check_mounts(fs))
return fs->path;
return fs__read_mounts(fs) ? fs->path : NULL;
if (fs__read_mounts(fs))
return fs->path;
return NULL;
}
static const char *fs__mountpoint(int idx)
......
......@@ -789,8 +789,8 @@ help:
@echo ''
@echo 'Perf install targets:'
@echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
@echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
@echo ' path like make prefix=/usr/local install install-doc'
@echo ' HINT: use "prefix" or "DESTDIR" to install to a particular'
@echo ' path like "make prefix=/usr/local install install-doc"'
@echo ' install - install compiled binaries'
@echo ' install-doc - install *all* documentation'
@echo ' install-man - install manpage documentation'
......@@ -815,17 +815,20 @@ INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
$(DOC_TARGETS):
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all)
TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol
TAG_FILES= ../../include/uapi/linux/perf_event.h
TAGS:
$(RM) TAGS
$(FIND) . -name '*.[hcS]' -print | xargs etags -a
$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs etags -a $(TAG_FILES)
tags:
$(RM) tags
$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs ctags -a $(TAG_FILES)
cscope:
$(RM) cscope*
$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
$(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs cscope -b $(TAG_FILES)
### Detect prefix changes
TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\
......
......@@ -454,7 +454,11 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
if (done)
break;
err = poll(rec->evlist->pollfd, rec->evlist->nr_fds, -1);
if (err < 0 && errno == EINTR)
/*
* Propagate error, only if there's any. Ignore positive
* number of returned events and interrupt error.
*/
if (err > 0 || (err < 0 && errno == EINTR))
err = 0;
waking++;
}
......
......@@ -447,6 +447,7 @@ else
ifneq ($(feature-libperl), 1)
CFLAGS += -DNO_LIBPERL
NO_LIBPERL := 1
msg := $(warning Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed);
else
LDFLAGS += $(PERL_EMBED_LDFLAGS)
EXTLIBS += $(PERL_EMBED_LIBADD)
......@@ -599,7 +600,7 @@ endif
# Make the path relative to DESTDIR, not to prefix
ifndef DESTDIR
prefix = $(HOME)
prefix ?= $(HOME)
endif
bindir_relative = bin
bindir = $(prefix)/$(bindir_relative)
......
......@@ -481,14 +481,18 @@ int main(int argc, const char **argv)
fprintf(stderr, "cannot handle %s internally", cmd);
goto out;
}
#ifdef HAVE_LIBAUDIT_SUPPORT
if (!prefixcmp(cmd, "trace")) {
#ifdef HAVE_LIBAUDIT_SUPPORT
set_buildid_dir();
setup_path();
argv[0] = "trace";
return cmd_trace(argc, argv, NULL);
}
#else
fprintf(stderr,
"trace command not available: missing audit-libs devel package at build time.\n");
goto out;
#endif
}
/* Look for flags.. */
argv++;
argc--;
......
......@@ -194,7 +194,7 @@ int ui_browser__warning(struct ui_browser *browser, int timeout,
ui_helpline__vpush(format, args);
va_end(args);
} else {
while ((key == ui__question_window("Warning!", text,
while ((key = ui__question_window("Warning!", text,
"Press any key...",
timeout)) == K_RESIZE)
ui_browser__handle_resize(browser);
......
......@@ -1706,14 +1706,14 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
zoom_out_dso:
ui_helpline__pop();
browser->hists->dso_filter = NULL;
sort_dso.elide = false;
perf_hpp__set_elide(HISTC_DSO, false);
} else {
if (dso == NULL)
continue;
ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"",
dso->kernel ? "the Kernel" : dso->short_name);
browser->hists->dso_filter = dso;
sort_dso.elide = true;
perf_hpp__set_elide(HISTC_DSO, true);
pstack__push(fstack, &browser->hists->dso_filter);
}
hists__filter_by_dso(hists);
......@@ -1725,13 +1725,13 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
zoom_out_thread:
ui_helpline__pop();
browser->hists->thread_filter = NULL;
sort_thread.elide = false;
perf_hpp__set_elide(HISTC_THREAD, false);
} else {
ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
thread->comm_set ? thread__comm_str(thread) : "",
thread->tid);
browser->hists->thread_filter = thread;
sort_thread.elide = true;
perf_hpp__set_elide(HISTC_THREAD, false);
pstack__push(fstack, &browser->hists->thread_filter);
}
hists__filter_by_thread(hists);
......
......@@ -205,6 +205,7 @@ struct perf_hpp_fmt {
struct list_head list;
struct list_head sort_list;
bool elide;
};
extern struct list_head perf_hpp__list;
......@@ -252,7 +253,12 @@ void perf_hpp__append_sort_keys(void);
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
bool perf_hpp__should_skip(struct perf_hpp_fmt *format);
static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format)
{
return format->elide;
}
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
typedef u64 (*hpp_field_fn)(struct hist_entry *he);
......
......@@ -1157,6 +1157,7 @@ __sort_dimension__alloc_hpp(struct sort_dimension *sd)
INIT_LIST_HEAD(&hse->hpp.list);
INIT_LIST_HEAD(&hse->hpp.sort_list);
hse->hpp.elide = false;
return hse;
}
......@@ -1364,27 +1365,64 @@ static int __setup_sorting(void)
return ret;
}
bool perf_hpp__should_skip(struct perf_hpp_fmt *format)
void perf_hpp__set_elide(int idx, bool elide)
{
if (perf_hpp__is_sort_entry(format)) {
struct hpp_sort_entry *hse;
struct perf_hpp_fmt *fmt;
struct hpp_sort_entry *hse;
hse = container_of(format, struct hpp_sort_entry, hpp);
return hse->se->elide;
perf_hpp__for_each_format(fmt) {
if (!perf_hpp__is_sort_entry(fmt))
continue;
hse = container_of(fmt, struct hpp_sort_entry, hpp);
if (hse->se->se_width_idx == idx) {
fmt->elide = elide;
break;
}
}
return false;
}
static void sort_entry__setup_elide(struct sort_entry *se,
struct strlist *list,
const char *list_name, FILE *fp)
static bool __get_elide(struct strlist *list, const char *list_name, FILE *fp)
{
if (list && strlist__nr_entries(list) == 1) {
if (fp != NULL)
fprintf(fp, "# %s: %s\n", list_name,
strlist__entry(list, 0)->s);
se->elide = true;
return true;
}
return false;
}
static bool get_elide(int idx, FILE *output)
{
switch (idx) {
case HISTC_SYMBOL:
return __get_elide(symbol_conf.sym_list, "symbol", output);
case HISTC_DSO:
return __get_elide(symbol_conf.dso_list, "dso", output);
case HISTC_COMM:
return __get_elide(symbol_conf.comm_list, "comm", output);
default:
break;
}
if (sort__mode != SORT_MODE__BRANCH)
return false;
switch (idx) {
case HISTC_SYMBOL_FROM:
return __get_elide(symbol_conf.sym_from_list, "sym_from", output);
case HISTC_SYMBOL_TO:
return __get_elide(symbol_conf.sym_to_list, "sym_to", output);
case HISTC_DSO_FROM:
return __get_elide(symbol_conf.dso_from_list, "dso_from", output);
case HISTC_DSO_TO:
return __get_elide(symbol_conf.dso_to_list, "dso_to", output);
default:
break;
}
return false;
}
void sort__setup_elide(FILE *output)
......@@ -1392,39 +1430,12 @@ void sort__setup_elide(FILE *output)
struct perf_hpp_fmt *fmt;
struct hpp_sort_entry *hse;
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"dso", output);
sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list,
"comm", output);
sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list,
"symbol", output);
if (sort__mode == SORT_MODE__BRANCH) {
sort_entry__setup_elide(&sort_dso_from,
symbol_conf.dso_from_list,
"dso_from", output);
sort_entry__setup_elide(&sort_dso_to,
symbol_conf.dso_to_list,
"dso_to", output);
sort_entry__setup_elide(&sort_sym_from,
symbol_conf.sym_from_list,
"sym_from", output);
sort_entry__setup_elide(&sort_sym_to,
symbol_conf.sym_to_list,
"sym_to", output);
} else if (sort__mode == SORT_MODE__MEMORY) {
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"symbol_daddr", output);
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"dso_daddr", output);
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"mem", output);
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"local_weight", output);
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"tlb", output);
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"snoop", output);
perf_hpp__for_each_format(fmt) {
if (!perf_hpp__is_sort_entry(fmt))
continue;
hse = container_of(fmt, struct hpp_sort_entry, hpp);
fmt->elide = get_elide(hse->se->se_width_idx, output);
}
/*
......@@ -1435,8 +1446,7 @@ void sort__setup_elide(FILE *output)
if (!perf_hpp__is_sort_entry(fmt))
continue;
hse = container_of(fmt, struct hpp_sort_entry, hpp);
if (!hse->se->elide)
if (!fmt->elide)
return;
}
......@@ -1444,8 +1454,7 @@ void sort__setup_elide(FILE *output)
if (!perf_hpp__is_sort_entry(fmt))
continue;
hse = container_of(fmt, struct hpp_sort_entry, hpp);
hse->se->elide = false;
fmt->elide = false;
}
}
......
......@@ -202,7 +202,6 @@ struct sort_entry {
int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size,
unsigned int width);
u8 se_width_idx;
bool elide;
};
extern struct sort_entry sort_thread;
......@@ -213,6 +212,7 @@ int setup_output_field(void);
void reset_output_field(void);
extern int sort_dimension__add(const char *);
void sort__setup_elide(FILE *fp);
void perf_hpp__set_elide(int idx, bool elide);
int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, int unset);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册