1. 03 Jun, 2016 1 commit
    • Kan Liang's avatar
      perf/core: Optimize side-band event delivery · f2fb6bef
      Kan Liang authored
      The perf_event_aux() function iterates all PMUs and all events in
      their respective per-CPU contexts to find the events to deliver
      side-band records to.
      
      For example, the brk test case in lkp triggers many mmap() operations,
      which, if we're also running perf, results in many perf_event_aux()
      invocations.
      
      If we enable uncore PMU support (even when uncore events are not used),
      dozens of uncore PMUs will be iterated, which can significantly
      decrease brk_test's throughput.
      
      For example, the brk throughput:
      
        without uncore PMUs: 2647573 ops_per_sec
        with    uncore PMUs: 1768444 ops_per_sec
      
      ... a 33% reduction.
      
      To get at the per-CPU events that need side-band records, this patch
      puts these events on a per-CPU list, this avoids iterating the PMUs
      and any events that do not need side-band records.
      
      Per task events are unchanged to avoid extra overhead on the context
      switch paths.
      Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reported-by: default avatarHuang, Ying <ying.huang@linux.intel.com>
      Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/1458757477-3781-1-git-send-email-kan.liang@intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f2fb6bef
  2. 31 May, 2016 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160530' of... · 42c4fb77
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-20160530' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible/kernel ABI changes:
      
      - Per event callchain limit: Recently we introduced a sysctl to tune the
        max-stack for all events for which callchains were requested:
      
        $ sysctl kernel.perf_event_max_stack
        kernel.perf_event_max_stack = 127
      
        Now this patch introduces a way to configure this per event, i.e. this
        becomes possible:
      
        $ perf record -e sched:*/max-stack=2/ -e block:*/max-stack=10/ -a
      
        allowing finer tuning of how much buffer space callchains use.
      
        This uses an u16 from the reserved space at the end, leaving another
        u16 for future use.
      
        There has been interest in even finer tuning, namely to control the
        max stack for kernel and userspace callchains separately. Further
        discussion is needed, we may for instance use the remaining u16 for
        that and when it is present, assume that the sample_max_stack introduced
        in this patch applies for the kernel, and the u16 left is used for
        limiting the userspace callchain. (Arnaldo Carvalho de Melo)
      
      Infrastructure changes:
      
      - Adopt get_main_thread from db-export.c (Andi Kleen)
      
      - More prep work for backward ring buffer support (Wang Nan)
      
      - Prep work for supporting SDT (Statically Defined Tracing)
        tracepoints (Masami Hiramatsu)
      
      - Add arch/*/include/generated/ to .gitignore (Taeung Song)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      42c4fb77
  3. 30 May, 2016 12 commits
  4. 29 May, 2016 1 commit
  5. 27 May, 2016 3 commits
    • Wang Nan's avatar
      perf ctf: Convert invalid chars in a string before set value · 5ea5888b
      Wang Nan authored
      We observed some crazy apps on Android set their comm to unprintable
      string. For example:
      
        # cat /proc/10607/task/*/comm
        tencent.qqmusic
        ...
        Binder_2
        日志输出线  <-- Chinese word 'log output thread'
        WifiManager
        ...
      
      'perf data convert' fails to convert perf.data with such string to CTF format.
      
      For example:
      
        # cat << EOF > ./badguy.c
        #include <sys/prctl.h>
        int main(int argc, char *argv[])
        {
               prctl(PR_SET_NAME, "\xe6\x97\xa5\xe5\xbf\x97\xe8\xbe\x93\xe5\x87\xba\xe7\xba\xbf");
               while(1)
                       sleep(1);
               return 0;
        }
        EOF
        # gcc ./badguy.c
        # perf record -e sched:* ./a.out
        # perf data convert --to-ctf ./bad.ctf
        CTF stream 4 flush failed
        [ perf data convert: Converted 'perf.data' into CTF data './bad.ctf' ]
        [ perf data convert: Converted and wrote 0.008 MB (78 samples)  ]
        # babeltrace ./bad.ctf/
        [error] Packet size (18446744073709551615 bits) is larger than remaining file size (262144 bits).
        [error] Stream index creation error.
        [error] Open file stream error.
        [warning] [Context] Cannot open_trace of format ctf at path ./bad.ctf.
        [warning] [Context] cannot open trace "./bad.ctf" from ./bad.ctf/ for reading.
        [error] Cannot open any trace for reading.
      
        [error] opening trace "./bad.ctf/" for reading.
      
        [error] none of the specified trace paths could be opened.
      
      This patch converts unprintable characters to hexadecimal word.
      
      After applying this patch the above test works correctly:
      
        # ~/perf data convert --to-ctf ./good.ctf
        [ perf data convert: Converted 'perf.data' into CTF data './good.ctf' ]
        [ perf data convert: Converted and wrote 0.008 MB (78 samples) ]
        # babeltrace ./good.ctf
        ..
        [23:14:35.491665268] (+0.000001100) sched:sched_wakeup: { cpu_id = 4 }, { perf_ip = 0xFFFFFFFF810AEF33, perf_tid = 0, perf_pid = 0, perf_id = 5123, perf_period = 1, common_type = 270, common_flags = 45, common_preempt_count = 4, common_pid = 0, comm = "\xe6\x97\xa5\xe5\xbf\x97\xe8\xbe\x93\xe5\x87\xba\xe7\xba\xbf", pid = 1057, prio = 120, success = 1, target_cpu = 4 }
        [23:14:35.491666230] (+0.000000962) sched:sched_wakeup: { cpu_id = 4 }, { perf_ip = 0xFFFFFFFF810AEF33, perf_tid = 0, perf_pid = 0, perf_id = 5122, perf_period = 1, common_type = 270, common_flags = 45, common_preempt_count = 4, common_pid = 0, comm = "\xe6\x97\xa5\xe5\xbf\x97\xe8\xbe\x93\xe5\x87\xba\xe7\xba\xbf", pid = 1057, prio = 120, success = 1, target_cpu = 4 }
        ..
      
      Committer note:
      
      To build perf with libabeltrace, use:
      
        $ mkdir -p /tmp/build/perf
        $ make LIBBABELTRACE=1 LIBBABELTRACE_DIR=/usr/local O=/tmp/build/perf -C tools/perf install-bin
      
      Or equivalent (no O=, fixup LIBBABELTRACE_DIR, etc).
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1464348951-179595-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ea5888b
    • Wang Nan's avatar
      perf record: Fix crash when kptr is restricted · 3dc6c1d5
      Wang Nan authored
      Before this patch, a simple 'perf record' could fail if kptr_restrict is
      set to 1 (for normal user) or 2 (for root):
      
        # perf record ls
        WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
        check /proc/sys/kernel/kptr_restrict.
      
        Samples in kernel functions may not be resolved if a suitable vmlinux
        file is not found in the buildid cache or in the vmlinux path.
      
        Samples in kernel modules won't be resolved at all.
      
        If some relocation was applied (e.g. kexec) symbols may be misresolved
        even with a suitable vmlinux or kallsyms file.
      
        Segmentation fault (core dumped)
      
      This patch skips perf_event__synthesize_kernel_mmap() when kptr is not
      available.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Fixes: 45e90056 ("perf machine: Do not bail out if not managing to read ref reloc symbol")
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1464081688-167940-2-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3dc6c1d5
    • Wang Nan's avatar
      perf symbols: Check kptr_restrict for root · 38272dc4
      Wang Nan authored
      If kptr_restrict is set to 2, even root is not allowed to see pointers.
      This patch checks kptr_restrict even if euid == 0. For root, report
      error if kptr_restrict is 2.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1464081688-167940-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      38272dc4
  6. 25 May, 2016 1 commit
  7. 24 May, 2016 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160523' of... · 0c9f790f
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-20160523' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/core improvements from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
      - Add "srcline_from" and "srcline_to" branch sort keys to 'perf top' and
        'perf report' (Andi Kleen)
      
      Infrastructure changes:
      
      - Make 'perf trace' auto-attach fd->name and ptr->name beautifiers based
        on the name of syscall arguments, this way new syscalls that have
        'const char * (path,pathname,filename)' will use the fd->name beautifier
        (vfs_getname perf probe, if in place) and the 'fd->name' (vfs_getname
        or via /proc/PID/fd/) (Arnaldo Carvalho de Melo)
      
      - Infrastructure to read from a ring buffer in backward write mode (Wang Nan)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0c9f790f
  8. 23 May, 2016 7 commits
  9. 20 May, 2016 13 commits