Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Move toggling event logic from 'perf top' and into hists browser, allowing
    freeze/unfreeze with event lists with more than one entry (Namhyung Kim)

  - Add missing newlines when dumping PERF_RECORD_FINISHED_ROUND and
    showing the Aggregated stats in 'perf report -D' (Adrian Hunter)

Infrastructure changes:

  - Allow auxtrace data alignment (Adrian Hunter)

  - Allow events with dot (Andi Kleen)

  - Fix failure to 'perf probe' events on arm (He Kuang)

  - Add testing for Makefile.perf (Jiri Olsa)

  - Add test for make install with prefix (Jiri Olsa)

  - Fix single target build dependency check (Jiri Olsa)

  - Access thread_map entries via accessors, prep patch to hold more info per
    entry, for ongoing 'perf stat --per-thread' work (Jiri Olsa)

  - Use __weak definition from compiler.h (Sukadev Bhattiprolu)

  - Split perf_pmu__new_alias() (Sukadev Bhattiprolu)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jun 25, 2015
2 parents 407a2c7 + 83b2ea2 commit 2745170
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 72 deletions.
4 changes: 2 additions & 2 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ build-test:
#
# All other targets get passed through:
#
%:
%: FORCE
$(print_msg)
$(make)

.PHONY: tags TAGS
.PHONY: tags TAGS FORCE Makefile
24 changes: 3 additions & 21 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,27 +586,9 @@ static void *display_thread_tui(void *arg)
hists->uid_filter_str = top->record_opts.target.uid_str;
}

while (true) {
int key = perf_evlist__tui_browse_hists(top->evlist, help, &hbt,
top->min_percent,
&top->session->header.env);

if (key != 'f')
break;

perf_evlist__toggle_enable(top->evlist);
/*
* No need to refresh, resort/decay histogram entries
* if we are not collecting samples:
*/
if (top->evlist->enabled) {
hbt.refresh = top->delay_secs;
help = "Press 'f' to disable the events or 'h' to see other hotkeys";
} else {
help = "Press 'f' again to re-enable the events";
hbt.refresh = 0;
}
}
perf_evlist__tui_browse_hists(top->evlist, help, &hbt,
top->min_percent,
&top->session->header.env);

done = 1;
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
*/
if (trace->filter_pids.nr > 0)
err = perf_evlist__set_filter_pids(evlist, trace->filter_pids.nr, trace->filter_pids.entries);
else if (evlist->threads->map[0] == -1)
else if (thread_map__pid(evlist->threads, 0) == -1)
err = perf_evlist__set_filter_pid(evlist, getpid());

if (err < 0) {
Expand All @@ -2343,7 +2343,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
if (forks)
perf_evlist__start_workload(evlist);

trace->multiple_threads = evlist->threads->map[0] == -1 ||
trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 ||
evlist->threads->nr > 1 ||
perf_evlist__first(evlist)->attr.inherit;
again:
Expand Down
31 changes: 28 additions & 3 deletions tools/perf/tests/make
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
ifndef MK
ifeq ($(MAKECMDGOALS),)
# no target specified, trigger the whole suite
all:
@echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile
@echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf
else
# run only specific test over 'Makefile'
%:
@echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile $@
endif
else
PERF := .
MK := Makefile

include config/Makefile.arch

Expand Down Expand Up @@ -47,6 +58,7 @@ make_install_man := install-man
make_install_html := install-html
make_install_info := install-info
make_install_pdf := install-pdf
make_install_prefix := install prefix=/tmp/krava
make_static := LDFLAGS=-static

# all the NO_* variable combined
Expand All @@ -57,7 +69,12 @@ make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1

# $(run) contains all available tests
run := make_pure
# Targets 'clean all' can be run together only through top level
# Makefile because we detect clean target in Makefile.perf and
# disable features detection
ifeq ($(MK),Makefile)
run += make_clean_all
endif
run += make_python_perf_so
run += make_debug
run += make_no_libperl
Expand All @@ -83,6 +100,7 @@ run += make_util_map_o
run += make_util_pmu_bison_o
run += make_install
run += make_install_bin
run += make_install_prefix
# FIXME 'install-*' commented out till they're fixed
# run += make_install_doc
# run += make_install_man
Expand Down Expand Up @@ -157,6 +175,12 @@ test_make_install_O := $(call test_dest_files,$(installed_files_all))
test_make_install_bin := $(call test_dest_files,$(installed_files_bin))
test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))

# We prefix all installed files for make_install_prefix
# with '/tmp/krava' to match installed/prefix-ed files.
installed_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all))
test_make_install_prefix := $(call test_dest_files,$(installed_files_all_prefix))
test_make_install_prefix_O := $(call test_dest_files,$(installed_files_all_prefix))

# FIXME nothing gets installed
test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
test_make_install_man_O := $(test_make_install_man)
Expand Down Expand Up @@ -226,13 +250,13 @@ tarpkg:
( eval $$cmd ) >> $@ 2>&1

make_kernelsrc:
@echo " - make -C <kernelsrc> tools/perf"
@echo "- make -C <kernelsrc> tools/perf"
$(call clean); \
(make -C ../.. tools/perf) > $@ 2>&1 && \
test -x perf && rm -f $@ || (cat $@ ; false)

make_kernelsrc_tools:
@echo " - make -C <kernelsrc>/tools perf"
@echo "- make -C <kernelsrc>/tools perf"
$(call clean); \
(make -C ../../tools perf) > $@ 2>&1 && \
test -x perf && rm -f $@ || (cat $@ ; false)
Expand All @@ -244,3 +268,4 @@ out: $(run_O)
@echo OK

.PHONY: all $(run) $(run_O) tarpkg clean
endif # ifndef MK
2 changes: 1 addition & 1 deletion tools/perf/tests/openat-syscall-tp-fields.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int test__syscall_openat_tp_fields(void)

perf_evsel__config(evsel, &opts);

evlist->threads->map[0] = getpid();
thread_map__set_pid(evlist->threads, 0, getpid());

err = perf_evlist__open(evlist);
if (err < 0) {
Expand Down
19 changes: 17 additions & 2 deletions tools/perf/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,23 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
case CTRL('c'):
goto out_free_stack;
case 'f':
if (!is_report_browser(hbt))
goto out_free_stack;
if (!is_report_browser(hbt)) {
struct perf_top *top = hbt->arg;

perf_evlist__toggle_enable(top->evlist);
/*
* No need to refresh, resort/decay histogram
* entries if we are not collecting samples:
*/
if (top->evlist->enabled) {
helpline = "Press 'f' to disable the events or 'h' to see other hotkeys";
hbt->refresh = delay_secs;
} else {
helpline = "Press 'f' again to re-enable the events";
hbt->refresh = 0;
}
continue;
}
/* Fall thru */
default:
helpline = "Press '?' for help on key bindings";
Expand Down
11 changes: 9 additions & 2 deletions tools/perf/util/auxtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
if (per_cpu) {
mp->cpu = evlist->cpus->map[idx];
if (evlist->threads)
mp->tid = evlist->threads->map[0];
mp->tid = thread_map__pid(evlist->threads, 0);
else
mp->tid = -1;
} else {
mp->cpu = -1;
mp->tid = evlist->threads->map[idx];
mp->tid = thread_map__pid(evlist->threads, idx);
}
}

Expand Down Expand Up @@ -1182,6 +1182,13 @@ static int __auxtrace_mmap__read(struct auxtrace_mmap *mm,
data2 = NULL;
}

if (itr->alignment) {
unsigned int unwanted = len1 % itr->alignment;

len1 -= unwanted;
size -= unwanted;
}

/* padding must be written by fn() e.g. record__process_auxtrace() */
padding = size & 7;
if (padding)
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/auxtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ struct auxtrace_record {
const char *str);
u64 (*reference)(struct auxtrace_record *itr);
int (*read_finish)(struct auxtrace_record *itr, int idx);
unsigned int alignment;
};

#ifdef HAVE_AUXTRACE_SUPPORT
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
for (thread = 0; thread < threads->nr; ++thread) {
if (__event__synthesize_thread(comm_event, mmap_event,
fork_event,
threads->map[thread], 0,
thread_map__pid(threads, thread), 0,
process, tool, machine,
mmap_data, proc_map_timeout)) {
err = -1;
Expand All @@ -515,12 +515,12 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
* comm.pid is set to thread group id by
* perf_event__synthesize_comm
*/
if ((int) comm_event->comm.pid != threads->map[thread]) {
if ((int) comm_event->comm.pid != thread_map__pid(threads, thread)) {
bool need_leader = true;

/* is thread group leader in thread_map? */
for (j = 0; j < threads->nr; ++j) {
if ((int) comm_event->comm.pid == threads->map[j]) {
if ((int) comm_event->comm.pid == thread_map__pid(threads, j)) {
need_leader = false;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ static void perf_evlist__set_sid_idx(struct perf_evlist *evlist,
else
sid->cpu = -1;
if (!evsel->system_wide && evlist->threads && thread >= 0)
sid->tid = evlist->threads->map[thread];
sid->tid = thread_map__pid(evlist->threads, thread);
else
sid->tid = -1;
}
Expand Down Expand Up @@ -1475,7 +1475,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
__func__, __LINE__);
goto out_close_pipes;
}
evlist->threads->map[0] = evlist->workload.pid;
thread_map__set_pid(evlist->threads, 0, evlist->workload.pid);
}

close(child_ready_pipe[1]);
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
int group_fd;

if (!evsel->cgrp && !evsel->system_wide)
pid = threads->map[thread];
pid = thread_map__pid(threads, thread);

group_fd = get_group_fd(evsel, cpu, thread);
retry_open:
Expand Down
5 changes: 2 additions & 3 deletions tools/perf/util/parse-events.l
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ event [^,{}/]+
num_dec [0-9]+
num_hex 0x[a-fA-F0-9]+
num_raw_hex [a-fA-F0-9]+
name [a-zA-Z_*?][a-zA-Z0-9_*?]*
name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]*
name [a-zA-Z_*?][a-zA-Z0-9_*?.]*
name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]*
/* If you add a modifier you need to update check_modifier() */
modifier_event [ukhpGHSDI]+
modifier_bp [rwx]{1,3}
Expand Down Expand Up @@ -165,7 +165,6 @@ modifier_bp [rwx]{1,3}
return PE_EVENT_NAME;
}

. |
<<EOF>> {
BEGIN(INITIAL);
REWIND(0);
Expand Down
45 changes: 29 additions & 16 deletions tools/perf/util/pmu.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <linux/list.h>
#include <linux/compiler.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
Expand Down Expand Up @@ -205,17 +206,12 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
return 0;
}

static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
char *desc __maybe_unused, char *val)
{
struct perf_pmu_alias *alias;
char buf[256];
int ret;

ret = fread(buf, 1, sizeof(buf), file);
if (ret == 0)
return -EINVAL;
buf[ret] = 0;

alias = malloc(sizeof(*alias));
if (!alias)
return -ENOMEM;
Expand All @@ -225,26 +221,43 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
alias->unit[0] = '\0';
alias->per_pkg = false;

ret = parse_events_terms(&alias->terms, buf);
ret = parse_events_terms(&alias->terms, val);
if (ret) {
pr_err("Cannot parse alias %s: %d\n", val, ret);
free(alias);
return ret;
}

alias->name = strdup(name);
/*
* load unit name and scale if available
*/
perf_pmu__parse_unit(alias, dir, name);
perf_pmu__parse_scale(alias, dir, name);
perf_pmu__parse_per_pkg(alias, dir, name);
perf_pmu__parse_snapshot(alias, dir, name);
if (dir) {
/*
* load unit name and scale if available
*/
perf_pmu__parse_unit(alias, dir, name);
perf_pmu__parse_scale(alias, dir, name);
perf_pmu__parse_per_pkg(alias, dir, name);
perf_pmu__parse_snapshot(alias, dir, name);
}

list_add_tail(&alias->list, list);

return 0;
}

static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FILE *file)
{
char buf[256];
int ret;

ret = fread(buf, 1, sizeof(buf), file);
if (ret == 0)
return -EINVAL;

buf[ret] = 0;

return __perf_pmu__new_alias(list, dir, name, NULL, buf);
}

static inline bool pmu_alias_info_file(char *name)
{
size_t len;
Expand Down Expand Up @@ -436,7 +449,7 @@ static struct cpu_map *pmu_cpumask(const char *name)
return cpus;
}

struct perf_event_attr *__attribute__((weak))
struct perf_event_attr * __weak
perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
{
return NULL;
Expand Down
6 changes: 5 additions & 1 deletion tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,12 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
static bool kprobe_blacklist__listed(unsigned long address);
static bool kprobe_warn_out_range(const char *symbol, unsigned long address)
{
u64 etext_addr;

/* Get the address of _etext for checking non-probable text symbol */
if (kernel_get_symbol_address_by_name("_etext", false) < address)
etext_addr = kernel_get_symbol_address_by_name("_etext", false);

if (etext_addr != 0 && etext_addr < address)
pr_warning("%s is out of .text, skip it.\n", symbol);
else if (kprobe_blacklist__listed(address))
pr_warning("%s is blacklisted function, skip it.\n", symbol);
Expand Down
Loading

0 comments on commit 2745170

Please sign in to comment.