Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorIngo Molnar <mingo@kernel.org>
Thu, 21 Mar 2013 10:06:12 +0000 (11:06 +0100)
committerIngo Molnar <mingo@kernel.org>
Thu, 21 Mar 2013 10:06:12 +0000 (11:06 +0100)
Conflicts:
tools/Makefile

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

. Honor parallel jobs, fix from Borislav Petkov

. Introduce tools/lib/lk library, initially just removing duplication
  among tools/perf and tools/vm. from Borislav Petkov

. Fix build on non-glibc systems due to libio.h absence, from Cody P Schafer.

. Remove some perf_session and tracing dead code, from David Ahern.

. Introduce perf stat --repeat forever, from Frederik Deweerdt.

. Add perf test entries for checking --cpu in record and stat, from Jiri Olsa.

. Add perf test entries for checking breakpoint overflow signal handler issues,
  from Jiri Olsa.

. Add perf test entry for for checking number of EXIT events, from Namhyung Kim.

. Simplify some perf_evlist methods and to allow 'stat' to share code with
  'record' and 'trace'.

. Remove dead code in related to libtraceevent integration, from Namhyung Kim.

. Event group view for 'annotate' in --stdio, --tui and --gtk, from Namhyung Kim.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
[ resolved the trivial merge conflict with upstream ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
1  2 
Makefile
tools/Makefile
tools/perf/util/evlist.c

diff --combined Makefile
index a05ea42c5f185d66692be18747e9e90b9633cd20,bbb15dff13bad1c82a3d211948e8004987832b54..6b39246c2c67dd6c8e56b82d0b32da67e45c3d67
+++ b/Makefile
@@@ -1,7 -1,7 +1,7 @@@
  VERSION = 3
 -PATCHLEVEL = 8
 +PATCHLEVEL = 9
  SUBLEVEL = 0
 -EXTRAVERSION =
 +EXTRAVERSION = -rc2
  NAME = Unicycling Gorilla
  
  # *DOCUMENTATION*
@@@ -192,6 -192,7 +192,6 @@@ SUBARCH := $(shell uname -m | sed -e s/
  # "make" in the configured kernel build directory always uses that.
  # Default value for CROSS_COMPILE is not to prefix executables
  # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 -export KBUILD_BUILDHOST := $(SUBARCH)
  ARCH          ?= $(SUBARCH)
  CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
  
@@@ -619,8 -620,7 +619,8 @@@ KBUILD_AFLAGS      += -gdwarf-
  endif
  
  ifdef CONFIG_DEBUG_INFO_REDUCED
 -KBUILD_CFLAGS         += $(call cc-option, -femit-struct-debug-baseonly)
 +KBUILD_CFLAGS         += $(call cc-option, -femit-struct-debug-baseonly) \
 +                 $(call cc-option,-fno-var-tracking)
  endif
  
  ifdef CONFIG_FUNCTION_TRACER
@@@ -720,11 -720,11 +720,11 @@@ endif # INSTALL_MOD_STRI
  export mod_strip_cmd
  
  
 -ifeq ($(CONFIG_MODULE_SIG),y)
 +ifdef CONFIG_MODULE_SIG_ALL
  MODSECKEY = ./signing_key.priv
  MODPUBKEY = ./signing_key.x509
  export MODPUBKEY
 -mod_sign_cmd = perl $(srctree)/scripts/sign-file $(MODSECKEY) $(MODPUBKEY)
 +mod_sign_cmd = perl $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODSECKEY) $(MODPUBKEY)
  else
  mod_sign_cmd = true
  endif
@@@ -1331,11 -1331,11 +1331,11 @@@ kernelversion
  # Clear a bunch of variables before executing the submake
  tools/: FORCE
        $(Q)mkdir -p $(objtree)/tools
-       $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/
+       $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/
  
  tools/%: FORCE
        $(Q)mkdir -p $(objtree)/tools
-       $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $*
+       $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $*
  
  # Single targets
  # ---------------------------------------------------------------------------
@@@ -1398,7 -1398,7 +1398,7 @@@ quiet_cmd_rmfiles = $(if $(wildcard $(r
  # Run depmod only if we have System.map and depmod is executable
  quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
        cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
 -                   $(KERNELRELEASE)
 +                   $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))"
  
  # Create temporary dir for module support files
  # clean it up only when building all modules
diff --combined tools/Makefile
index fa36565b209d80e8e07c14a6e48dd87a5d5d14de,623b1cd86cb34c032d2d072b3e49cb1b41a934f7..6aaeb6cd867dc97a042628e29b5c7edf5abcffd7
@@@ -3,7 -3,6 +3,7 @@@ include scripts/Makefile.includ
  help:
        @echo 'Possible targets:'
        @echo ''
 +      @echo '  cgroup     - cgroup tools'
        @echo '  cpupower   - a tool for all things x86 CPU power'
        @echo '  firewire   - the userspace part of nosy, an IEEE-1394 traffic sniffer'
        @echo '  lguest     - a minimal 32-bit x86 hypervisor'
  cpupower: FORCE
        $(call descend,power/$@)
  
- cgroup firewire lguest perf usb virtio vm: FORCE
 -firewire guest usb virtio vm: FORCE
++cgroup firewire guest usb virtio vm: FORCE
+       $(call descend,$@)
+ liblk: FORCE
+       $(call descend,lib/lk)
+ perf: liblk FORCE
        $(call descend,$@)
  
  selftests: FORCE
@@@ -46,7 -51,7 +52,7 @@@ turbostat x86_energy_perf_policy: FORC
  cpupower_install:
        $(call descend,power/$(@:_install=),install)
  
 -firewire_install lguest_install perf_install usb_install virtio_install vm_install:
 +cgroup_install firewire_install lguest_install perf_install usb_install virtio_install vm_install:
        $(call descend,$(@:_install=),install)
  
  selftests_install:
  turbostat_install x86_energy_perf_policy_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
 +install: cgroup_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:
        $(call descend,power/cpupower,clean)
  
- cgroup_clean firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
 -firewire_clean lguest_clean usb_clean virtio_clean vm_clean:
++cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean:
+       $(call descend,$(@:_clean=),clean)
+ liblk_clean:
+       $(call descend,lib/lk,clean)
+ perf_clean: liblk_clean
        $(call descend,$(@:_clean=),clean)
  
  selftests_clean:
@@@ -71,8 -82,8 +83,8 @@@
  turbostat_clean x86_energy_perf_policy_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 \
 -              x86_energy_perf_policy_clean
 +clean: cgroup_clean cpupower_clean firewire_clean lguest_clean perf_clean \
 +              selftests_clean turbostat_clean usb_clean virtio_clean \
 +              vm_clean x86_energy_perf_policy_clean
  
  .PHONY: FORCE
diff --combined tools/perf/util/evlist.c
index c8be0fbc51458370e9a0b5c5a7885757db4c6c4e,1344fbd2472ec796f3678dec8e0f9978fc6f4894..f7c727801aaba6f5e3ac31631801ce9c06e8a5c0
@@@ -7,7 -7,7 +7,7 @@@
   * Released under the GPL v2. (and only v2, not any later version)
   */
  #include "util.h"
- #include "debugfs.h"
+ #include <lk/debugfs.h>
  #include <poll.h>
  #include "cpumap.h"
  #include "thread_map.h"
@@@ -38,13 -38,12 +38,12 @@@ void perf_evlist__init(struct perf_evli
        evlist->workload.pid = -1;
  }
  
- struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
-                                    struct thread_map *threads)
+ struct perf_evlist *perf_evlist__new(void)
  {
        struct perf_evlist *evlist = zalloc(sizeof(*evlist));
  
        if (evlist != NULL)
-               perf_evlist__init(evlist, cpus, threads);
+               perf_evlist__init(evlist, NULL, NULL);
  
        return evlist;
  }
@@@ -228,12 -227,14 +227,14 @@@ void perf_evlist__disable(struct perf_e
  {
        int cpu, thread;
        struct perf_evsel *pos;
+       int nr_cpus = cpu_map__nr(evlist->cpus);
+       int nr_threads = thread_map__nr(evlist->threads);
  
-       for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+       for (cpu = 0; cpu < nr_cpus; cpu++) {
                list_for_each_entry(pos, &evlist->entries, node) {
                        if (!perf_evsel__is_group_leader(pos))
                                continue;
-                       for (thread = 0; thread < evlist->threads->nr; thread++)
+                       for (thread = 0; thread < nr_threads; thread++)
                                ioctl(FD(pos, cpu, thread),
                                      PERF_EVENT_IOC_DISABLE, 0);
                }
@@@ -244,12 -245,14 +245,14 @@@ void perf_evlist__enable(struct perf_ev
  {
        int cpu, thread;
        struct perf_evsel *pos;
+       int nr_cpus = cpu_map__nr(evlist->cpus);
+       int nr_threads = thread_map__nr(evlist->threads);
  
-       for (cpu = 0; cpu < cpu_map__nr(evlist->cpus); cpu++) {
+       for (cpu = 0; cpu < nr_cpus; cpu++) {
                list_for_each_entry(pos, &evlist->entries, node) {
                        if (!perf_evsel__is_group_leader(pos))
                                continue;
-                       for (thread = 0; thread < evlist->threads->nr; thread++)
+                       for (thread = 0; thread < nr_threads; thread++)
                                ioctl(FD(pos, cpu, thread),
                                      PERF_EVENT_IOC_ENABLE, 0);
                }
  
  static int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
  {
-       int nfds = cpu_map__nr(evlist->cpus) * evlist->threads->nr * evlist->nr_entries;
+       int nr_cpus = cpu_map__nr(evlist->cpus);
+       int nr_threads = thread_map__nr(evlist->threads);
+       int nfds = nr_cpus * nr_threads * evlist->nr_entries;
        evlist->pollfd = malloc(sizeof(struct pollfd) * nfds);
        return evlist->pollfd != NULL ? 0 : -ENOMEM;
  }
@@@ -314,6 -319,7 +319,6 @@@ static int perf_evlist__id_add_fd(struc
  struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
  {
        struct hlist_head *head;
 -      struct hlist_node *pos;
        struct perf_sample_id *sid;
        int hash;
  
        hash = hash_64(id, PERF_EVLIST__HLIST_BITS);
        head = &evlist->heads[hash];
  
 -      hlist_for_each_entry(sid, pos, head, node)
 +      hlist_for_each_entry(sid, head, node)
                if (sid->id == id)
                        return sid->evsel;
  
@@@ -417,7 -423,7 +422,7 @@@ static int perf_evlist__alloc_mmap(stru
  {
        evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
        if (cpu_map__all(evlist->cpus))
-               evlist->nr_mmaps = evlist->threads->nr;
+               evlist->nr_mmaps = thread_map__nr(evlist->threads);
        evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
        return evlist->mmap != NULL ? 0 : -ENOMEM;
  }
@@@ -442,11 -448,13 +447,13 @@@ static int perf_evlist__mmap_per_cpu(st
  {
        struct perf_evsel *evsel;
        int cpu, thread;
+       int nr_cpus = cpu_map__nr(evlist->cpus);
+       int nr_threads = thread_map__nr(evlist->threads);
  
-       for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+       for (cpu = 0; cpu < nr_cpus; cpu++) {
                int output = -1;
  
-               for (thread = 0; thread < evlist->threads->nr; thread++) {
+               for (thread = 0; thread < nr_threads; thread++) {
                        list_for_each_entry(evsel, &evlist->entries, node) {
                                int fd = FD(evsel, cpu, thread);
  
        return 0;
  
  out_unmap:
-       for (cpu = 0; cpu < evlist->cpus->nr; cpu++) {
+       for (cpu = 0; cpu < nr_cpus; cpu++) {
                if (evlist->mmap[cpu].base != NULL) {
                        munmap(evlist->mmap[cpu].base, evlist->mmap_len);
                        evlist->mmap[cpu].base = NULL;
@@@ -483,8 -491,9 +490,9 @@@ static int perf_evlist__mmap_per_thread
  {
        struct perf_evsel *evsel;
        int thread;
+       int nr_threads = thread_map__nr(evlist->threads);
  
-       for (thread = 0; thread < evlist->threads->nr; thread++) {
+       for (thread = 0; thread < nr_threads; thread++) {
                int output = -1;
  
                list_for_each_entry(evsel, &evlist->entries, node) {
        return 0;
  
  out_unmap:
-       for (thread = 0; thread < evlist->threads->nr; thread++) {
+       for (thread = 0; thread < nr_threads; thread++) {
                if (evlist->mmap[thread].base != NULL) {
                        munmap(evlist->mmap[thread].base, evlist->mmap_len);
                        evlist->mmap[thread].base = NULL;
@@@ -610,7 -619,7 +618,7 @@@ int perf_evlist__apply_filters(struct p
        struct perf_evsel *evsel;
        int err = 0;
        const int ncpus = cpu_map__nr(evlist->cpus),
-                 nthreads = evlist->threads->nr;
+                 nthreads = thread_map__nr(evlist->threads);
  
        list_for_each_entry(evsel, &evlist->entries, node) {
                if (evsel->filter == NULL)
@@@ -629,7 -638,7 +637,7 @@@ int perf_evlist__set_filter(struct perf
        struct perf_evsel *evsel;
        int err = 0;
        const int ncpus = cpu_map__nr(evlist->cpus),
-                 nthreads = evlist->threads->nr;
+                 nthreads = thread_map__nr(evlist->threads);
  
        list_for_each_entry(evsel, &evlist->entries, node) {
                err = perf_evsel__set_filter(evsel, ncpus, nthreads, filter);
@@@ -712,10 -721,20 +720,20 @@@ void perf_evlist__set_selected(struct p
        evlist->selected = evsel;
  }
  
+ void perf_evlist__close(struct perf_evlist *evlist)
+ {
+       struct perf_evsel *evsel;
+       int ncpus = cpu_map__nr(evlist->cpus);
+       int nthreads = thread_map__nr(evlist->threads);
+       list_for_each_entry_reverse(evsel, &evlist->entries, node)
+               perf_evsel__close(evsel, ncpus, nthreads);
+ }
  int perf_evlist__open(struct perf_evlist *evlist)
  {
        struct perf_evsel *evsel;
-       int err, ncpus, nthreads;
+       int err;
  
        list_for_each_entry(evsel, &evlist->entries, node) {
                err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
  
        return 0;
  out_err:
-       ncpus = evlist->cpus ? evlist->cpus->nr : 1;
-       nthreads = evlist->threads ? evlist->threads->nr : 1;
-       list_for_each_entry_reverse(evsel, &evlist->entries, node)
-               perf_evsel__close(evsel, ncpus, nthreads);
+       perf_evlist__close(evlist);
        errno = -err;
        return err;
  }
  
  int perf_evlist__prepare_workload(struct perf_evlist *evlist,
-                                 struct perf_record_opts *opts,
-                                 const char *argv[])
+                                 struct perf_target *target,
+                                 const char *argv[], bool pipe_output,
+                                 bool want_signal)
  {
        int child_ready_pipe[2], go_pipe[2];
        char bf;
        }
  
        if (!evlist->workload.pid) {
-               if (opts->pipe_output)
+               if (pipe_output)
                        dup2(2, 1);
  
                close(child_ready_pipe[0]);
                execvp(argv[0], (char **)argv);
  
                perror(argv[0]);
-               kill(getppid(), SIGUSR1);
+               if (want_signal)
+                       kill(getppid(), SIGUSR1);
                exit(-1);
        }
  
-       if (perf_target__none(&opts->target))
+       if (perf_target__none(target))
                evlist->threads->map[0] = evlist->workload.pid;
  
        close(child_ready_pipe[1]);