1. 19 Feb, 2016 5 commits
    • Wang Nan's avatar
      perf bpf: Rename bpf_prog_priv__clear() to clear_prog_priv() · 80cdce76
      Wang Nan authored
      The name of bpf_prog_priv__clear() doesn't follow perf's naming
      convention. bpf_prog_priv__delete() seems to be a better name. However,
      bpf_prog_priv__delete() should be a method of 'struct bpf_prog_priv',
      but its first parameter is 'struct bpf_program'.
      
      It is callback from libbpf to clear priv structures when destroying a
      bpf program. It is actually a method of bpf_program (libbpf object), but
      bpf_program__ functions should be provided by libbpf.
      
      This patch removes the prefix of that function.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Cody P Schafer <dev@codyps.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kirill Smelkov <kirr@nexedi.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1455882283-79592-4-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      80cdce76
    • Andi Kleen's avatar
      perf stat: Handled scaled == -1 case for counters · b002f3bb
      Andi Kleen authored
      Arnaldo pointed out that the earlier cb110f47 ("perf stat: Move
      noise/running printing into printout") change changed behavior for not
      counted counters. This patch fixes it again.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Fixes: cb110f47 ("perf stat: Move noise/running printing into printout")
      Link: http://lkml.kernel.org/r/1455749045-18098-2-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b002f3bb
    • Arnaldo Carvalho de Melo's avatar
      perf test: Reduce the sample_freq for the 'object code reading' test · 5243ba76
      Arnaldo Carvalho de Melo authored
      Using 4 kHz is not necessary and sometimes is more than what was
      auto-tuned:
      
        # dmesg | grep max_sample_rate | tail -2
        [ 2499.144373] perf interrupt took too long (2501 > 2500), lowering kernel.perf_event_max_sample_rate to 50000
        [ 3592.413606] perf interrupt took too long (5069 > 5000), lowering kernel.perf_event_max_sample_rate to 25000
      
      Simulating a auto-tune of 2000 we make the test fail, as reported
      by Steven Noonan for one of his machines, so reduce it to 500 HZ,
      it is enough to get a good number of samples for this test:
      
        # perf test -v 21 2>&1  | grep '^Reading object code for memory address' | tee /tmp/out | tail -5
        Reading object code for memory address: 0x479f40
        Reading object code for memory address: 0x7f29b7eea80d
        Reading object code for memory address: 0x7f29b7eea80d
        Reading object code for memory address: 0x7f29b7eea800
        Reading object code for memory address: 0xffffffff813b2f23
        [root@jouet ~]# wc -l /tmp/out
        40 /tmp/out
        [root@jouet ~]#
      
      For systems that auto-tune below that, the previous patches will tell the
      user what is happening so that he may either ignore the result of this test or
      bump /proc/sys/kernel/perf_event_max_sample_rate.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Steven Noonan <steven@uplinklabs.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-6kufyy1iprdfzrbtuqgxir70@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5243ba76
    • Arnaldo Carvalho de Melo's avatar
      perf tests: Use perf_evlist__strerror_open() to provide hints about max_freq · 6880bbf9
      Arnaldo Carvalho de Melo authored
      Before:
      
        # perf test -v "code reading" 2>&1 | tail -4
        perf_evlist__open failed
        test child finished with -1
        ---- end ----
        Test object code reading: FAILED!
        #
      
      After:
      
        # perf test -v "code reading" 2>&1 | tail -7
        perf_evlist__open() failed!
        Error: Invalid argument.
        Hint:  Check /proc/sys/kernel/perf_event_max_sample_rate.
        Hint:  The current value is 1000 and 4000 is being requested.
        test child finished with -1
        ---- end ----
        Test object code reading: FAILED!
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Steven Noonan <steven@uplinklabs.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-ifbx7vmrc38loe6317owz2jx@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6880bbf9
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Handle -EINVAL for sample_freq > max_sample_rate in strerror_open() · d9aade7f
      Arnaldo Carvalho de Melo authored
      When running the "code reading" test we get:
      
        # perf test -v "code reading" 2>&1 | tail -5
        Parsing event 'cycles:u'
        perf_evlist__open failed
        test child finished with -1
        ---- end ----
        Test object code reading: FAILED!
        #
      
      And with -vv we get the errno value, -22, i.e. -EINVAL, but we can do
      better and handle the case at hand, with this patch it becomes:
      
        # perf test -v "code reading" 2>&1 | tail -7
        perf_evlist__open() failed!
        Error: Invalid argument.
        Hint:  Check /proc/sys/kernel/perf_event_max_sample_rate.
        Hint:  The current value is 1000 and 4000 is being requested.
        test child finished with -1
        ---- end ----
        Test object code reading: FAILED!
        #
      
      Next patch will make this 'perf test' entry to use perf_evlist__strerror()
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Steven Noonan <steven@uplinklabs.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-i31ai6kfefn75eapejjokfhc@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d9aade7f
  2. 18 Feb, 2016 2 commits
    • Jiri Olsa's avatar
      perf record: Add --all-user/--all-kernel options · 85723885
      Jiri Olsa authored
      Allow user to easily switch all events to user or kernel space with simple
      --all-user or --all-kernel options.
      
      This will be handy within perf mem/c2c wrappers to switch easily monitoring
      modes.
      
      Committer note:
      
      Testing it:
      
        # perf record --all-kernel --all-user -a sleep 2
         Error: option `all-user' cannot be used with all-kernel
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
              --all-user        Configure all used events to run in user space.
              --all-kernel      Configure all used events to run in kernel space.
        # perf record --all-user --all-kernel -a sleep 2
         Error: option `all-kernel' cannot be used with all-user
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
              --all-kernel      Configure all used events to run in kernel space.
              --all-user        Configure all used events to run in user space.
        # perf record --all-user -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.416 MB perf.data (162 samples) ]
        # perf report | grep '\[k\]'
        # perf record --all-kernel -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.423 MB perf.data (296 samples) ]
        # perf report | grep '\[\.\]'
        #
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1455525293-8671-2-git-send-email-jolsa@kernel.org
      [ Made those options to be mutually exclusive ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      85723885
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Reference count the cpu and thread maps at set_maps() · a55e5663
      Arnaldo Carvalho de Melo authored
      We were dropping the reference we possibly held but not obtaining one
      for the new maps, which we will drop at perf_evlist__delete(), fix it.
      
      This was caught by Steven Noonan in some of the machines which would
      produce this output when caught by glibc debug mechanisms:
      
        $ sudo perf test 21
        21: Test object code reading                                 :***
        Error in `perf': corrupted double-linked list: 0x00000000023ffcd0 ***
        ======= Backtrace: =========
        /usr/lib/libc.so.6(+0x72055)[0x7f25be0f3055]
        /usr/lib/libc.so.6(+0x779b6)[0x7f25be0f89b6]
        /usr/lib/libc.so.6(+0x7a0ed)[0x7f25be0fb0ed]
        /usr/lib/libc.so.6(__libc_calloc+0xba)[0x7f25be0fceda]
        perf(parse_events_lex_init_extra+0x38)[0x4cfff8]
        perf(parse_events+0x55)[0x4a0615]
        perf(perf_evlist__config+0xcf)[0x4eeb2f]
        perf[0x479f82]
        perf(test__code_reading+0x1e)[0x47ad4e]
        perf(cmd_test+0x5dd)[0x46452d]
        perf[0x47f4e3]
        perf(main+0x603)[0x42c723]
        /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f25be0a1610]
        perf(_start+0x29)[0x42c859]
      
      Further investigation using valgrind led to the reference count imbalance fixed
      in this patch.
      Reported-and-Tested-by: default avatarSteven Noonan <steven@uplinklabs.net>
      Report-Link: http://lkml.kernel.org/r/CAKbGBLjC2Dx5vshxyGmQkcD+VwiAQLbHoXA9i7kvRB2-2opHZQ@mail.gmail.com
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: f30a79b0 ("perf tools: Add reference counting for cpu_map object")
      Link: http://lkml.kernel.org/n/tip-j0u1bdhr47sa511sgg76kb8h@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a55e5663
  3. 17 Feb, 2016 24 commits
  4. 16 Feb, 2016 9 commits