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:

 - UAPI fixes, from David Howels

 - Separate perf tests into multiple objects, one per test, from Jiri Olsa.

 - Fixes to /proc/pid/maps parsing, preparatory to supporting data maps,
   from Namhyung Kim

 - Fix compile error for non-NEWT builds, from Namhyung Kim

 - Implement ui_progress for GTK, from Namhyung Kim

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Dec 8, 2012
2 parents 84e53ff + 07ac002 commit adc1ef1
Show file tree
Hide file tree
Showing 52 changed files with 2,050 additions and 1,785 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1321,10 +1321,12 @@ kernelversion:

# Clear a bunch of variables before executing the submake
tools/: FORCE
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/
$(Q)mkdir -p $(objtree)/tools
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/

tools/%: FORCE
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= -C $(src)/tools/ $*
$(Q)mkdir -p $(objtree)/tools
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*

# Single targets
# ---------------------------------------------------------------------------
Expand Down
24 changes: 12 additions & 12 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@ help:
@echo ' clean: a summary clean target to clean _all_ folders'

cpupower: FORCE
$(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1)
$(call descend,power/$@)

firewire lguest perf usb virtio vm: FORCE
$(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)
$(call descend,$@)

selftests: FORCE
$(QUIET_SUBDIR0)testing/$@/ $(QUIET_SUBDIR1)
$(call descend,testing/$@)

turbostat x86_energy_perf_policy: FORCE
$(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1)
$(call descend,power/x86/$@)

cpupower_install:
$(QUIET_SUBDIR0)power/$(@:_install=)/ $(QUIET_SUBDIR1) install
$(call descend,power/$(@:_install=),install)

firewire_install lguest_install perf_install usb_install virtio_install vm_install:
$(QUIET_SUBDIR0)$(@:_install=)/ $(QUIET_SUBDIR1) install
$(call descend,$(@:_install=),install)

selftests_install:
$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) install
$(call descend,testing/$(@:_clean=),install)

turbostat_install x86_energy_perf_policy_install:
$(QUIET_SUBDIR0)power/x86/$(@:_install=)/ $(QUIET_SUBDIR1) install
$(call descend,power/x86/$(@:_install=),install)

install: cpupower_install firewire_install lguest_install perf_install \
selftests_install turbostat_install usb_install virtio_install \
vm_install x86_energy_perf_policy_install

cpupower_clean:
$(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean
$(call descend,power/cpupower,clean)

firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
$(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean
$(call descend,$(@:_clean=),clean)

selftests_clean:
$(QUIET_SUBDIR0)testing/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
$(call descend,testing/$(@:_clean=),clean)

turbostat_clean x86_energy_perf_policy_clean:
$(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean
$(call descend,power/x86/$(@:_clean=),clean)

clean: cpupower_clean firewire_clean lguest_clean perf_clean selftests_clean \
turbostat_clean usb_clean virtio_clean vm_clean \
Expand Down
18 changes: 15 additions & 3 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ LIB_OBJS += $(OUTPUT)util/intlist.o
LIB_OBJS += $(OUTPUT)util/vdso.o
LIB_OBJS += $(OUTPUT)util/stat.o

LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/helpline.o
LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/hist.o
LIB_OBJS += $(OUTPUT)ui/stdio/hist.o

Expand All @@ -431,6 +433,17 @@ LIB_OBJS += $(OUTPUT)arch/common.o
LIB_OBJS += $(OUTPUT)tests/parse-events.o
LIB_OBJS += $(OUTPUT)tests/dso-data.o
LIB_OBJS += $(OUTPUT)tests/attr.o
LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o
LIB_OBJS += $(OUTPUT)tests/open-syscall.o
LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o
LIB_OBJS += $(OUTPUT)tests/open-syscall-tp-fields.o
LIB_OBJS += $(OUTPUT)tests/mmap-basic.o
LIB_OBJS += $(OUTPUT)tests/perf-record.o
LIB_OBJS += $(OUTPUT)tests/rdpmc.o
LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o
LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o
LIB_OBJS += $(OUTPUT)tests/pmu.o
LIB_OBJS += $(OUTPUT)tests/util.o

BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
Expand Down Expand Up @@ -600,17 +613,16 @@ ifndef NO_NEWT
BASIC_CFLAGS += -I/usr/include/slang
BASIC_CFLAGS += -DNEWT_SUPPORT
EXTLIBS += -lnewt -lslang
LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/browser.o
LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o
LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
LIB_OBJS += $(OUTPUT)ui/browsers/map.o
LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
LIB_OBJS += $(OUTPUT)ui/progress.o
LIB_OBJS += $(OUTPUT)ui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/setup.o
LIB_OBJS += $(OUTPUT)ui/tui/util.o
LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
LIB_OBJS += $(OUTPUT)ui/tui/progress.o
LIB_H += ui/browser.h
LIB_H += ui/browsers/map.h
LIB_H += ui/keysyms.h
Expand All @@ -636,9 +648,9 @@ ifndef NO_GTK2
LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
LIB_OBJS += $(OUTPUT)ui/gtk/util.o
LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
# Make sure that it'd be included only once.
ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
LIB_OBJS += $(OUTPUT)ui/setup.o
LIB_OBJS += $(OUTPUT)ui/util.o
endif
endif
Expand Down
26 changes: 22 additions & 4 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,15 @@ static int perf_record__open(struct perf_record *rec)
struct perf_record_opts *opts = &rec->opts;
int rc = 0;

perf_evlist__config_attrs(evlist, opts);

/*
* Set the evsel leader links before we configure attributes,
* since some might depend on this info.
*/
if (opts->group)
perf_evlist__set_leader(evlist);

perf_evlist__config_attrs(evlist, opts);

list_for_each_entry(pos, &evlist->entries, node) {
struct perf_event_attr *attr = &pos->attr;
/*
Expand Down Expand Up @@ -498,6 +502,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
struct perf_evlist *evsel_list = rec->evlist;
const char *output_name = rec->output_name;
struct perf_session *session;
bool disabled = false;

rec->progname = argv[0];

Expand Down Expand Up @@ -697,7 +702,13 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
}
}

perf_evlist__enable(evsel_list);
/*
* When perf is starting the traced process, all the events
* (apart from group members) have enable_on_exec=1 set,
* so don't spoil it by prematurely enabling them.
*/
if (!perf_target__none(&opts->target))
perf_evlist__enable(evsel_list);

/*
* Let the child rip
Expand All @@ -720,8 +731,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
waking++;
}

if (done)
/*
* When perf is starting the traced process, at the end events
* die with the process and we wait for that. Thus no need to
* disable events in this case.
*/
if (done && !disabled && !perf_target__none(&opts->target)) {
perf_evlist__disable(evsel_list);
disabled = true;
}
}

if (quiet || signr == SIGUSR1)
Expand Down
12 changes: 5 additions & 7 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS];
static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS];
static struct stats walltime_nsecs_stats;

static int create_perf_stat_counter(struct perf_evsel *evsel,
struct perf_evsel *first)
static int create_perf_stat_counter(struct perf_evsel *evsel)
{
struct perf_event_attr *attr = &evsel->attr;
bool exclude_guest_missing = false;
Expand All @@ -153,7 +152,8 @@ static int create_perf_stat_counter(struct perf_evsel *evsel,
return 0;
}

if (!perf_target__has_task(&target) && (!group || evsel == first)) {
if (!perf_target__has_task(&target) &&
!perf_evsel__is_group_member(evsel)) {
attr->disabled = 1;
attr->enable_on_exec = 1;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ static int read_counter(struct perf_evsel *counter)
static int __run_perf_stat(int argc __maybe_unused, const char **argv)
{
unsigned long long t0, t1;
struct perf_evsel *counter, *first;
struct perf_evsel *counter;
int status = 0;
int child_ready_pipe[2], go_pipe[2];
const bool forks = (argc > 0);
Expand Down Expand Up @@ -332,10 +332,8 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv)
if (group)
perf_evlist__set_leader(evsel_list);

first = perf_evlist__first(evsel_list);

list_for_each_entry(counter, &evsel_list->entries, node) {
if (create_perf_stat_counter(counter, first) < 0) {
if (create_perf_stat_counter(counter) < 0) {
/*
* PPC returns ENXIO for HW counters until 2.6.37
* (behavior changed with commit b0a873e).
Expand Down
15 changes: 10 additions & 5 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,26 @@ int check_pager_config(const char *cmd)
return c.val;
}

static int tui_command_config(const char *var, const char *value, void *data)
static int browser_command_config(const char *var, const char *value, void *data)
{
struct pager_config *c = data;
if (!prefixcmp(var, "tui.") && !strcmp(var + 4, c->cmd))
c->val = perf_config_bool(var, value);
if (!prefixcmp(var, "gtk.") && !strcmp(var + 4, c->cmd))
c->val = perf_config_bool(var, value) ? 2 : 0;
return 0;
}

/* returns 0 for "no tui", 1 for "use tui", and -1 for "not specified" */
static int check_tui_config(const char *cmd)
/*
* returns 0 for "no tui", 1 for "use tui", 2 for "use gtk",
* and -1 for "not specified"
*/
static int check_browser_config(const char *cmd)
{
struct pager_config c;
c.cmd = cmd;
c.val = -1;
perf_config(tui_command_config, &c);
perf_config(browser_command_config, &c);
return c.val;
}

Expand Down Expand Up @@ -302,7 +307,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
prefix = NULL; /* setup_perf_directory(); */

if (use_browser == -1)
use_browser = check_tui_config(p->cmd);
use_browser = check_browser_config(p->cmd);

if (use_pager == -1 && p->option & RUN_SETUP)
use_pager = check_pager_config(p->cmd);
Expand Down
3 changes: 1 addition & 2 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void get_term_dimensions(struct winsize *ws);
#endif

#ifdef __powerpc__
#include "../../arch/powerpc/include/asm/unistd.h"
#include "../../arch/powerpc/include/uapi/asm/unistd.h"
#define rmb() asm volatile ("sync" ::: "memory")
#define cpu_relax() asm volatile ("" ::: "memory");
#define CPUINFO_PROC "cpu"
Expand Down Expand Up @@ -178,7 +178,6 @@ extern bool test_attr__enabled;
void test_attr__init(void);
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
int fd, int group_fd, unsigned long flags);
int test_attr__run(void);

static inline int
sys_perf_event_open(struct perf_event_attr *attr,
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/tests/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "../perf.h"
#include "util.h"
#include "exec_cmd.h"
#include "tests.h"

#define ENV "PERF_TEST_ATTR"

Expand Down Expand Up @@ -151,7 +152,7 @@ static int run_dir(const char *d, const char *perf)
return system(cmd);
}

int test_attr__run(void)
int test__attr(void)
{
struct stat st;
char path_perf[PATH_MAX];
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/attr/test-record-group
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ sample_type=327
mmap=0
comm=0
enable_on_exec=0
disabled=0
5 changes: 2 additions & 3 deletions tools/perf/tests/attr/test-record-group1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ config=1
sample_type=327
mmap=0
comm=0
# TODO this is disabled for --group option, enabled otherwise
# check why..
enable_on_exec=1
enable_on_exec=0
disabled=0
6 changes: 2 additions & 4 deletions tools/perf/tests/attr/test-stat-group1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ group_fd=-1
fd=2
group_fd=1
config=1
# TODO both disabled and enable_on_exec are disabled for --group option,
# enabled otherwise, check why..
disabled=1
enable_on_exec=1
disabled=0
enable_on_exec=0
Loading

0 comments on commit adc1ef1

Please sign in to comment.