Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1306221 > unrolled thread

[PATCH 00/53] perf tools: Bugfix, BPF improvement and perf record flight record mode

Started byWang Nan <wangnan0@huawei.com>
First post2016-01-11 14:50 +0100
Last post2016-01-11 15:30 +0100
Articles 20 on this page of 94 — 11 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 00/53] perf tools: Bugfix, BPF improvement and perf record flight record mode Wang Nan <wangnan0@huawei.com> - 2016-01-11 14:50 +0100
    [PATCH 44/53] perf tools: Automatically add new channel according to evlist Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
      Re: [PATCH 01/53] perf tools: Add -lutil in python lib list for  broken python-config Jiri Olsa <jolsa@redhat.com> - 2016-01-12 10:50 +0100
      [tip:perf/urgent] perf tools:   Add -lutil in python lib list for broken python-config tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:10 +0100
    [PATCH 09/53] perf: bpf: Fix build breakage due to libbpf Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
      [tip:perf/urgent] perf bpf: Fix build breakage due to libbpf "tip-bot for Naveen N. Rao" <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 52/53] perf record: Toggle tailsize ring buffer for reading Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 17/53] perf test: Improve bp_signal Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
      Re: [PATCH 17/53] perf test: Improve bp_signal Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 22:40 +0100
        Re: [PATCH 17/53] perf test: Improve bp_signal "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 05:20 +0100
        Re: [PATCH 17/53] perf test: Improve bp_signal Jiri Olsa <jolsa@redhat.com> - 2016-01-12 10:30 +0100
          Re: [PATCH 17/53] perf test: Improve bp_signal Will Deacon <will.deacon@arm.com> - 2016-01-12 15:20 +0100
          Re: [PATCH 17/53] perf test: Improve bp_signal Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-12 15:20 +0100
    [PATCH 47/53] perf record: Don't read from and poll overwrite channel Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 28/53] perf tools: Move timestamp creation to util Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 39/53] perf record: Re-synthesize tracking events after output switching Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 33/53] perf record: Introduce record__finish_output() to finish a perf.data Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 46/53] perf tools: Squash overwrite setting into channel Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 34/53] perf record: Use OPT_BOOLEAN_SET for buildid cache related options Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 43/53] perf tools: Add evlist channel helpers Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 51/53] perf record: Read from tailsize ring buffer Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 42/53] perf record: Prevent reading invalid data in record__mmap_read Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
      Re: [PATCH 42/53] perf record: Prevent reading invalid data in  record__mmap_read Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-01-11 15:30 +0100
        Re: [PATCH 42/53] perf record: Prevent reading invalid data in  record__mmap_read Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-01-11 16:10 +0100
        Re: [PATCH 42/53] perf record: Prevent reading invalid data in  record__mmap_read Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-01-11 16:10 +0100
    [PATCH 40/53] perf record: Generate tracking events for process forked by perf Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 41/53] perf record: Ensure return non-zero rc when mmap fail Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 49/53] perf tools: Consider TAILSIZE bit when caclulate is_pos Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 31/53] perf tools: Add perf_data_file__switch() helper Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 50/53] perf tools: Set tailsize attribut bit for overwrite events Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 45/53] perf tools: Operate multiple channels Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 30/53] perf record: Extract synthesize code to record__synthesize() Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 07/53] tools: Move Makefile.arch from perf/config to tools/scripts Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
      Re: [PATCH 07/53] tools: Move Makefile.arch from perf/config to tools/scripts "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
        Re: [PATCH 07/53] tools: Move Makefile.arch from perf/config to  tools/scripts Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 15:20 +0100
      [tip:perf/urgent] tools: Move Makefile.arch from perf/  config to tools/scripts tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 53/53] perf record: Allow generate tracking events at the end of output Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 48/53] perf tools: Enable overwrite settings Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
    [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test  hist' Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-01-11 15:30 +0100
        Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test  hist' Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-01-11 16:00 +0100
          Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test  hist' Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 16:40 +0100
      [tip:perf/urgent] perf test: Fix false TEST_OK result for '  perf test hist' tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 15/53] perf tools: Fix symbols searching for offline module in buildid-cache Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 06/53] perf tools: Fix PowerPC native building Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      [tip:perf/urgent] perf tools: Fix PowerPC native building tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 23/53] perf tools: Support setting different slots in a BPF map separately Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 02/53] perf tools: Fix phony build target for build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      [tip:perf/urgent] perf tools:   Fix phony build target for build-test tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 19/53] perf tools: Enable BPF object configure syntax Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 05/53] perf tools: Test correct path of perf in build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 16:30 +0100
        Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:10 +0100
          Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:40 +0100
            Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:50 +0100
              Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 08:20 +0100
                Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-12 15:10 +0100
    [PATCH 20/53] perf record: Apply config to BPF objects before recording Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 14/53] perf test: Check environment before start real BPF test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      Re: [PATCH 14/53] perf test: Check environment before start real BPF  test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:00 +0100
        Re: [PATCH 14/53] perf test: Check environment before start real  BPF test "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 08:50 +0100
    [PATCH 26/53] perf data: Support converting data from bpf_perf_event_output() Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 36/53] perf record: Split output into multiple files via '--switch-output' Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 12/53] perf test: Reset err after using it hold errcode in hist testcases Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      [tip:perf/urgent] perf test:   Reset err after using it hold errcode in hist testcases tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 29/53] perf tools: Make ordered_events reusable Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      Re: [PATCH 29/53] perf tools: Make ordered_events reusable Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 22:40 +0100
    [PATCH 04/53] perf tools: Pass O option to Makefile.perf in build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 32/53] perf record: Turns auxtrace_snapshot_enable into 3 states Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 16/53] perf tools: Fix mmap2 event allocation in synthesize code Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
      Re: [PATCH 16/53] perf tools: Fix mmap2 event allocation in  synthesize code Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 22:10 +0100
        [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code Wang Nan <wangnan0@huawei.com> - 2016-01-12 11:20 +0100
          RE: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in  synthesize code 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2016-01-12 11:50 +0100
            Re: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize  code "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 12:00 +0100
              Re: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in  synthesize code "acme@kernel.org" <acme@kernel.org> - 2016-01-12 15:30 +0100
                RE: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in  synthesize code 平松雅巳 / HIRAMATU,MASAMI   <masami.hiramatsu.pt@hitachi.com> - 2016-01-13 01:50 +0100
          [tip:perf/urgent] perf tools:   Fix mmap2 event allocation in synthesize code tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-13 10:50 +0100
    [PATCH 08/53] perf tools: Add missing sources in perf's MANIFEST Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 21/53] perf tools: Enable passing event to BPF object Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
    [PATCH 25/53] perf tools: Introduce bpf-output event Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
    [PATCH 18/53] perf tools: Add API to config maps in bpf object Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
    [PATCH 24/53] perf tools: Enable indices setting syntax for BPF maps Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
    [PATCH 22/53] perf tools: Support perf event alias name Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
    [PATCH 13/53] perf tools: Prevent calling machine__delete() on non-allocated machine Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
      Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on  non-allocated machine Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 16:50 +0100
        Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on  non-allocated machine "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 08:10 +0100
          Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on  non-allocated machine Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-12 15:10 +0100
    [PATCH 10/53] tools build: Add BPF feature check to test-all Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
      [tip:perf/urgent] tools build: Add BPF feature check to test-all tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
    [PATCH 37/53] perf record: Force enable --timestamp-filename when --switch-output is provided Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
    [PATCH 03/53] perf tools: Set parallel making options build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
    [PATCH 35/53] perf record: Add '--timestamp-filename' option to append timestamp to output filename Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:30 +0100
    [PATCH 38/53] perf record: Disable buildid cache options by default in switch output mode Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:30 +0100

Page 1 of 5  [1] 2 3 4 5  Next page →


#1306221 — [PATCH 00/53] perf tools: Bugfix, BPF improvement and perf record flight record mode

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 14:50 +0100
Subject[PATCH 00/53] perf tools: Bugfix, BPF improvement and perf record flight record mode
Message-ID<qPL17-34y-5@gated-at.bofh.it>
Hi Arnaldo,

   This patch set is based on today's perf/core. It contains 3 parts:

   1. Bugfix in my local tree. Most of them are resent (patch 1 - 17).

   2. BPF related improvement. Also, you should have read them last
      year. Nearly no change (18 - 26).

   3. The most exciting feature I'd like to introduce to you and others:
      perf record overwrite mode support:

      This feature is based on a patch which is discussed but not merged
      yet [1]. I also send it in this series as patch 27. In this patch,
      kernel appends the size of an event at the end of the event data
      in the ring buffer, which enables us reading as much data as
      possible from a overwrite ring buffer, so it works like a flight
      recorder. Patch 28 - 53 add support of it. This is an example:

 # perf record -a -e cycles/overwrite/ \
	          -e raw_syscalls:sys_enter/overwrite/ \
	          -e raw_syscalls:sys_exit/overwrite/ \
	          -e sched:sched_switch/overwrite/ \
                  --switch-output --tail-tracking

 Then send 3 SIGUSR2 to 'perf' in another console:

 # kill -s SIGUSR2 `ps -e | grep 'pts.*perf' | awk '{print $1}'`

 [ perf record: dump data: Woken up 1 times ]
 [ perf record: Dump perf.data.2016011205392208 ]
 [ perf record: dump data: Woken up 1 times ]
 [ perf record: Dump perf.data.2016011205392597 ]
 [ perf record: dump data: Woken up 1 times ]
 [ perf record: Dump perf.data.2016011205392906 ]
 ^C[ perf record: Woken up 1 times to write data ]
 [ perf record: Dump perf.data.2016011205393040 

 Here's the result:

 # ls -l ./perf.data.* 
  -rw------- 1 root root 4284861 Jan 12 05:39
  ./perf.data.2016011205392208
  -rw------- 1 root root 4578477 Jan 12 05:39
  ./perf.data.2016011205392597
  -rw------- 1 root root 4602757 Jan 12 05:39
  ./perf.data.2016011205392906
  -rw------- 1 root root 5655429 Jan 12 05:39
  ./perf.data.2016011205393040

In each perf.data output, we get about 4M events before it receives
signal.

This should be useful if we have a extra monitor checks performance
metrics. When it found something unusual, it can send a SIGUSR2 to
perf to collect data near the bad things happen.

My next step is trying to trigger event dumping using eBPF. Then we can
triggeer a perf.data output immediately after a system call takes too
long or when we detect a losting of a display update.

Patch 28 - 40 add a switch-output mode, make perf dump a new perf.data
when it receive a SIGUSR2.

Patch 41 - 45 introduce a concept called 'channel', which allows perf to
collect data through more than one group of mmaped ring buffer with different
configurations.

Patch 46 - 53 are the core of flight record mode. Patch 51 does real
reading from flight recorder ring buffer.

[1] http://lkml.kernel.org/g/1452518653-1794-1-git-send-email-wangnan0@huawei.com

He Kuang (1):
  perf tools: Support perf event alias name

Jiri Olsa (1):
  perf tools: Add missing sources in perf's MANIFEST

Naveen N. Rao (1):
  perf: bpf: Fix build breakage due to libbpf

Wang Nan (50):
  perf tools: Add -lutil in python lib list for broken python-config
  perf tools: Fix phony build target for build-test
  perf tools: Set parallel making options build-test
  perf tools: Pass O option to Makefile.perf in build-test
  perf tools: Test correct path of perf in build-test
  perf tools: Fix PowerPC native building
  tools: Move Makefile.arch from perf/config to tools/scripts
  tools build: Add BPF feature check to test-all
  perf test: Fix false TEST_OK result for 'perf test hist'
  perf test: Reset err after using it hold errcode in hist testcases
  perf tools: Prevent calling machine__delete() on non-allocated machine
  perf test: Check environment before start real BPF test
  perf tools: Fix symbols searching for offline module in buildid-cache
  perf tools: Fix mmap2 event allocation in synthesize code
  perf test: Improve bp_signal
  perf tools: Add API to config maps in bpf object
  perf tools: Enable BPF object configure syntax
  perf record: Apply config to BPF objects before recording
  perf tools: Enable passing event to BPF object
  perf tools: Support setting different slots in a BPF map separately
  perf tools: Enable indices setting syntax for BPF maps
  perf tools: Introduce bpf-output event
  perf data: Support converting data from bpf_perf_event_output()
  perf/core: Put size of a sample at the end of it by
    PERF_SAMPLE_TAILSIZE
  perf tools: Move timestamp creation to util
  perf tools: Make ordered_events reusable
  perf record: Extract synthesize code to record__synthesize()
  perf tools: Add perf_data_file__switch() helper
  perf record: Turns auxtrace_snapshot_enable into 3 states
  perf record: Introduce record__finish_output() to finish a perf.data
  perf record: Use OPT_BOOLEAN_SET for buildid cache related options
  perf record: Add '--timestamp-filename' option to append timestamp to
    output filename
  perf record: Split output into multiple files via '--switch-output'
  perf record: Force enable --timestamp-filename when --switch-output is
    provided
  perf record: Disable buildid cache options by default in switch output
    mode
  perf record: Re-synthesize tracking events after output switching
  perf record: Generate tracking events for process forked by perf
  perf record: Ensure return non-zero rc when mmap fail
  perf record: Prevent reading invalid data in record__mmap_read
  perf tools: Add evlist channel helpers
  perf tools: Automatically add new channel according to evlist
  perf tools: Operate multiple channels
  perf tools: Squash overwrite setting into channel
  perf record: Don't read from and poll overwrite channel
  perf tools: Enable overwrite settings
  perf tools: Consider TAILSIZE bit when caclulate is_pos
  perf tools: Set tailsize attribut bit for overwrite events
  perf record: Read from tailsize ring buffer
  perf record: Toggle tailsize ring buffer for reading
  perf record: Allow generate tracking events at the end of output

 include/linux/perf_event.h                   |  17 +-
 include/uapi/linux/perf_event.h              |   3 +-
 kernel/events/core.c                         |  82 +++-
 kernel/events/ring_buffer.c                  |   7 +-
 tools/build/feature/test-all.c               |   5 +
 tools/build/feature/test-bpf.c               |  20 +-
 tools/lib/bpf/Makefile                       |  16 +-
 tools/lib/bpf/bpf.c                          |   4 +-
 tools/perf/MANIFEST                          |   2 +
 tools/perf/builtin-buildid-cache.c           |  14 +-
 tools/perf/builtin-record.c                  | 549 +++++++++++++++++----
 tools/perf/config/Makefile                   |   4 +-
 tools/perf/perf.h                            |   1 +
 tools/perf/tests/bp_signal.c                 | 140 +++++-
 tools/perf/tests/bpf.c                       |  37 ++
 tools/perf/tests/hists_common.c              |   5 -
 tools/perf/tests/hists_cumulate.c            |   1 +
 tools/perf/tests/hists_filter.c              |   1 +
 tools/perf/tests/hists_link.c                |   1 +
 tools/perf/tests/hists_output.c              |   1 +
 tools/perf/tests/make                        |  72 ++-
 tools/perf/tests/vmlinux-kallsyms.c          |   4 +-
 tools/perf/util/bpf-loader.c                 | 699 +++++++++++++++++++++++++++
 tools/perf/util/bpf-loader.h                 |  59 +++
 tools/perf/util/build-id.c                   |  44 ++
 tools/perf/util/build-id.h                   |   1 +
 tools/perf/util/data-convert-bt.c            | 112 ++++-
 tools/perf/util/data.c                       |  36 ++
 tools/perf/util/data.h                       |  11 +-
 tools/perf/util/event.c                      |  28 +-
 tools/perf/util/evlist.c                     | 307 ++++++++++--
 tools/perf/util/evlist.h                     |  67 ++-
 tools/perf/util/evsel.c                      |  42 +-
 tools/perf/util/evsel.h                      |  13 +
 tools/perf/util/machine.c                    |  13 +-
 tools/perf/util/machine.h                    |   3 +-
 tools/perf/util/ordered-events.c             |   9 +
 tools/perf/util/ordered-events.h             |   1 +
 tools/perf/util/parse-events.c               | 139 +++++-
 tools/perf/util/parse-events.h               |  24 +-
 tools/perf/util/parse-events.l               |  18 +-
 tools/perf/util/parse-events.y               | 123 ++++-
 tools/perf/util/session.c                    |   4 +-
 tools/perf/util/symbol.c                     |   4 +
 tools/perf/util/util.c                       |  17 +
 tools/perf/util/util.h                       |   1 +
 tools/{perf/config => scripts}/Makefile.arch |   0
 47 files changed, 2482 insertions(+), 279 deletions(-)
 rename tools/{perf/config => scripts}/Makefile.arch (100%)

-- 
1.8.3.4

[toc] | [next] | [standalone]


#1306223 — [PATCH 44/53] perf tools: Automatically add new channel according to evlist

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 44/53] perf tools: Automatically add new channel according to evlist
Message-ID<qPLaO-38k-1@gated-at.bofh.it>
In reply to#1306221
perf_evlist__channel_find() can be used to find a proper channel based
on propreties of a evsel. If the channel doesn't exist, it can create
new one for it. After this patch there's no need to create default
channel explicitly.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c |  5 -----
 tools/perf/util/evlist.c    | 47 ++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 21da64d..1f9fb6e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -356,11 +356,6 @@ try_again:
 	}
 
 	perf_evlist__channel_reset(evlist);
-	rc = perf_evlist__channel_add(evlist, 0, true);
-	if (rc < 0)
-		goto out;
-	rc = 0;
-
 	if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, false,
 				 opts->auxtrace_mmap_pages,
 				 opts->auxtrace_snapshot_mode) < 0) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index ff1beac..5a898be 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -943,6 +943,43 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
 	return 0;
 }
 
+static unsigned long
+perf_evlist__channel_for_evsel(struct perf_evsel *evsel __maybe_unused)
+{
+	return 0;
+}
+
+static int
+perf_evlist__channel_find(struct perf_evlist *evlist,
+			  struct perf_evsel *evsel,
+			  bool add_new)
+{
+	unsigned long flag = perf_evlist__channel_for_evsel(evsel);
+	int i;
+
+	flag |= PERF_EVLIST__CHANNEL_ENABLED;
+	for (i = 0; i < perf_evlist__channel_nr(evlist); i++)
+		if (evlist->channel_flags[i] == flag)
+			return i;
+	if (add_new)
+		return perf_evlist__channel_add(evlist, flag, false);
+	return -ENOENT;
+}
+
+static int
+perf_evlist__channel_complete(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+	int err;
+
+	evlist__for_each(evlist, evsel) {
+		err = perf_evlist__channel_find(evlist, evsel, true);
+		if (err < 0)
+			return err;
+	}
+	return 0;
+}
+
 static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
 				       struct mmap_params *mp, int cpu,
 				       int thread, int *output)
@@ -1162,6 +1199,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 			 bool overwrite, unsigned int auxtrace_pages,
 			 bool auxtrace_overwrite)
 {
+	int err;
 	struct perf_evsel *evsel;
 	const struct cpu_map *cpus = evlist->cpus;
 	const struct thread_map *threads = evlist->threads;
@@ -1169,6 +1207,10 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 		.prot = PROT_READ | (overwrite ? 0 : PROT_WRITE),
 	};
 
+	err = perf_evlist__channel_complete(evlist);
+	if (err)
+		return err;
+
 	if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0)
 		return -ENOMEM;
 
@@ -1199,12 +1241,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 		      bool overwrite)
 {
-	int err;
-
 	perf_evlist__channel_reset(evlist);
-	err = perf_evlist__channel_add(evlist, 0, true);
-	if (err < 0)
-		return err;
 	return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false);
 }
 
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306224 — [PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config
Message-ID<qPLaO-38k-3@gated-at.bofh.it>
In reply to#1306221
On some system the perf-config is broken, causes link failure like this:

 /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_forkpty':
 /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3816: undefined reference to `forkpty'
 /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_openpty':
 /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3756: undefined reference to `openpty'
 collect2: error: ld returned 1 exit status
make[1]: *** [/home/wangnan/kernel-hydrogen/tools/perf/out/perf] Error 1
make: *** [all] Error 2

 $ python-config --libs
 -lpthread -ldl -lpthread -lutil -lm -lpython2.7

In this case a '-lutil' should be appended to -lpython2.7.

(I know we have --start-group and --end-group. I can see them in
command line of collect2 by strace. However it doesn't work. Seems
I have a broken environment?)

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/config/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 254d06e..0793c76 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -493,7 +493,7 @@ else
 
       PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
       PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
+      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
       PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
       FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
 
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1307171 — Re: [PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config

FromJiri Olsa <jolsa@redhat.com>
Date2016-01-12 10:50 +0100
SubjectRe: [PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config
Message-ID<qQ3Kr-7vj-31@gated-at.bofh.it>
In reply to#1306224
On Mon, Jan 11, 2016 at 01:47:52PM +0000, Wang Nan wrote:
> On some system the perf-config is broken, causes link failure like this:

I've never got 0/53 email of this patchset.. is there any?

I was just wondering if there's git tree with patchset,
it'd make it easier for me to review it

thanks,
jirka


> 
>  /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_forkpty':
>  /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3816: undefined reference to `forkpty'
>  /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_openpty':
>  /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3756: undefined reference to `openpty'
>  collect2: error: ld returned 1 exit status
> make[1]: *** [/home/wangnan/kernel-hydrogen/tools/perf/out/perf] Error 1
> make: *** [all] Error 2
> 
>  $ python-config --libs
>  -lpthread -ldl -lpthread -lutil -lm -lpython2.7
> 
> In this case a '-lutil' should be appended to -lpython2.7.
> 
> (I know we have --start-group and --end-group. I can see them in
> command line of collect2 by strace. However it doesn't work. Seems
> I have a broken environment?)
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/config/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
> index 254d06e..0793c76 100644
> --- a/tools/perf/config/Makefile
> +++ b/tools/perf/config/Makefile
> @@ -493,7 +493,7 @@ else
>  
>        PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
>        PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
> -      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
> +      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
>        PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
>        FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
>  
> -- 
> 1.8.3.4
> 

[toc] | [prev] | [next] | [standalone]


#1307202 — [tip:perf/urgent] perf tools: Add -lutil in python lib list for broken python-config

Fromtip-bot for Wang Nan <tipbot@zytor.com>
Date2016-01-12 11:10 +0100
Subject[tip:perf/urgent] perf tools: Add -lutil in python lib list for broken python-config
Message-ID<qQ43N-7TO-57@gated-at.bofh.it>
In reply to#1306224
Commit-ID:  11dc0c57ba8a935dec5a3240370941a4380721c4
Gitweb:     http://git.kernel.org/tip/11dc0c57ba8a935dec5a3240370941a4380721c4
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Mon, 11 Jan 2016 13:47:52 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 11 Jan 2016 19:03:16 -0300

perf tools: Add -lutil in python lib list for broken python-config

On some system the perf-config is broken, causes link failure like this:

   /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_forkpty':
   /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3816: undefined reference to `forkpty'
   /usr/lib64/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_openpty':
   /opt/wangnan/yocto-build/tmp-eglibc/work/x86_64-oe-linux/python/2.7.3-r0.3.1/Python-2.7.3/./Modules/posixmodule.c:3756: undefined reference to `openpty'
   collect2: error: ld returned 1 exit status
  make[1]: *** [/home/wangnan/kernel-hydrogen/tools/perf/out/perf] Error 1
  make: *** [all] Error 2

  $ python-config --libs
  -lpthread -ldl -lpthread -lutil -lm -lpython2.7

In this case a '-lutil' should be appended to -lpython2.7.

(I know we have --start-group and --end-group. I can see them in command
line of collect2 by strace. However it doesn't work. Seems I have a
broken environment?)

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1452520124-2073-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/config/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 254d06e..0793c76 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -493,7 +493,7 @@ else
 
       PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
       PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
+      PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
       PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
       FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
 

[toc] | [prev] | [next] | [standalone]


#1306225 — [PATCH 09/53] perf: bpf: Fix build breakage due to libbpf

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 09/53] perf: bpf: Fix build breakage due to libbpf
Message-ID<qPLaO-38k-5@gated-at.bofh.it>
In reply to#1306221
From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>

perf build is currently (v4.4-rc5) broken on powerpc:

bpf.c:28:4: error: #error __NR_bpf not defined. libbpf does not support
your arch.
 #  error __NR_bpf not defined. libbpf does not support your arch.
    ^

Fix this by including tools/scripts/Makefile.arch for the proper
$ARCH macro. While at it, remove redundant LP64 macro definition.

Also, since libbpf require $(srctree) now, detect the path of
srctree like perf.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
[Use tools/scripts/Makefile.arch]
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 tools/lib/bpf/Makefile | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 919b717..1d446a6 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -6,6 +6,12 @@ BPF_EXTRAVERSION = 1
 
 MAKEFLAGS += --no-print-directory
 
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
 
 # Makefiles suck: This macro sets a default value of $(2) for the
 # variable named by $(1), unless the variable has been set by
@@ -31,7 +37,8 @@ INSTALL = install
 DESTDIR ?=
 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
 
-LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+include $(srctree)/tools/scripts/Makefile.arch
+
 ifeq ($(LP64), 1)
   libdir_relative = lib64
 else
@@ -57,13 +64,6 @@ ifndef VERBOSE
   VERBOSE = 0
 endif
 
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
 FEATURE_USER = .libbpf
 FEATURE_TESTS = libelf libelf-getphdrnum libelf-mmap bpf
 FEATURE_DISPLAY = libelf bpf
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1307208 — [tip:perf/urgent] perf bpf: Fix build breakage due to libbpf

From"tip-bot for Naveen N. Rao" <tipbot@zytor.com>
Date2016-01-12 11:20 +0100
Subject[tip:perf/urgent] perf bpf: Fix build breakage due to libbpf
Message-ID<qQ4dt-7Y1-13@gated-at.bofh.it>
In reply to#1306225
Commit-ID:  d5ef3140351450d240f864208317f5665e7bbd1c
Gitweb:     http://git.kernel.org/tip/d5ef3140351450d240f864208317f5665e7bbd1c
Author:     Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Mon, 11 Jan 2016 13:48:00 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 11 Jan 2016 19:22:21 -0300

perf bpf: Fix build breakage due to libbpf

perf build is currently (v4.4-rc5) broken on powerpc:

  bpf.c:28:4: error: #error __NR_bpf not defined. libbpf does not support
  your arch.
   #  error __NR_bpf not defined. libbpf does not support your arch.
      ^

Fix this by including tools/scripts/Makefile.arch for the proper $ARCH
macro. While at it, remove redundant LP64 macro definition.

Also, since libbpf require $(srctree) now, detect the path of srctree
like perf.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1452520124-2073-10-git-send-email-wangnan0@huawei.com
[Use tools/scripts/Makefile.arch]
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/bpf/Makefile | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 84e0e98..fc1bc75 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -6,6 +6,12 @@ BPF_EXTRAVERSION = 1
 
 MAKEFLAGS += --no-print-directory
 
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
 
 # Makefiles suck: This macro sets a default value of $(2) for the
 # variable named by $(1), unless the variable has been set by
@@ -31,7 +37,8 @@ INSTALL = install
 DESTDIR ?=
 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
 
-LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+include $(srctree)/tools/scripts/Makefile.arch
+
 ifeq ($(LP64), 1)
   libdir_relative = lib64
 else
@@ -57,13 +64,6 @@ ifndef VERBOSE
   VERBOSE = 0
 endif
 
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
 FEATURE_USER = .libbpf
 FEATURE_TESTS = libelf libelf-getphdrnum libelf-mmap bpf
 FEATURE_DISPLAY = libelf bpf

[toc] | [prev] | [next] | [standalone]


#1306226 — [PATCH 52/53] perf record: Toggle tailsize ring buffer for reading

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 52/53] perf record: Toggle tailsize ring buffer for reading
Message-ID<qPLaO-38k-7@gated-at.bofh.it>
In reply to#1306221
Toggel tailsize_evt_stopped director after receiving done or switch
output. After this patch it is possible to trigger a dump use SIGUSR2
when something happen.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6c8905b..6ec0529 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -591,6 +591,26 @@ static void record__init_features(struct record *rec)
 }
 
 static void
+record__toggle_tailsize_evsels(struct record *rec, bool stop)
+{
+	struct perf_evsel *pos;
+	struct perf_evlist *evlist = rec->evlist;
+
+	evlist__for_each(evlist, pos) {
+		if (!pos->tailsize)
+			continue;
+		if (!pos->overwrite)
+			continue;
+		if (stop)
+			perf_evsel__disable(pos);
+		else
+			perf_evsel__enable(pos);
+	}
+
+	rec->tailsize_evt_stopped = stop;
+}
+
+static void
 record__finish_output(struct record *rec)
 {
 	struct perf_data_file *file = &rec->file;
@@ -925,6 +945,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 	for (;;) {
 		unsigned long long hits = rec->samples;
 
+		if (switch_output_started || done)
+			record__toggle_tailsize_evsels(rec, true);
+
 		if (record__mmap_read_all(rec) < 0) {
 			auxtrace_snapshot_disable();
 			err = -1;
@@ -943,7 +966,20 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
 		}
 
 		if (switch_output_started) {
+			/*
+			 * SIGUSR2 raise after or during record__mmap_read_all().
+			 * continue to read again.
+			 */
+			if (!rec->tailsize_evt_stopped)
+				continue;
+
 			switch_output_started = 0;
+			/* 
+			 * Reenable events in tailsize ring buffer after
+			 * record__mmap_read_all(): we have collected
+			 * data from it.
+			 */
+			record__toggle_tailsize_evsels(rec, false);
 
 			if (!quiet)
 				fprintf(stderr, "[ perf record: dump data: Woken up %ld times ]\n",
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306227 — [PATCH 17/53] perf test: Improve bp_signal

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 17/53] perf test: Improve bp_signal
Message-ID<qPLaO-38k-11@gated-at.bofh.it>
In reply to#1306221
Will Deacon [1] has some question on patch [2]. This patch improves
test__bp_signal so we can test:

 1. A watchpoint and a breakpoint that fire on the same instruction
 2. Nested signals

Test result:

 On x86_64 and ARM64 (result are similar with patch [2] on ARM64):

 # ./perf test -v signal
 17: Test breakpoint overflow signal handler                  :
 --- start ---
 test child forked, pid 10213
 count1 1, count2 3, count3 2, overflow 3, overflows_2 3
 test child finished with 0
 ---- end ----
 Test breakpoint overflow signal handler: Ok

So at least 2 cases Will doubted are handled correctly.

[1] http://lkml.kernel.org/g/20160104165535.GI1616@arm.com
[2] http://lkml.kernel.org/g/1450921362-198371-1-git-send-email-wangnan0@huawei.com

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/bp_signal.c | 140 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 118 insertions(+), 22 deletions(-)

diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index fb80c9e..1d1bb48 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -29,14 +29,59 @@
 
 static int fd1;
 static int fd2;
+static int fd3;
 static int overflows;
+static int overflows_2;
+
+volatile long the_var;
+
+
+/*
+ * Use ASM to ensure watchpoint and breakpoint can be triggered
+ * at one instruction.
+ */
+#if defined (__x86_64__)
+extern void __test_function(volatile long *ptr);
+asm (
+	".globl __test_function\n"
+	"__test_function:\n"
+	"incq (%rdi)\n"
+	"ret\n");
+#elif defined (__aarch64__)
+extern void __test_function(volatile long *ptr);
+asm (
+	".globl __test_function\n"
+	"__test_function:\n"
+	"str x30, [x0]\n"
+	"ret\n");
+
+#else
+static void __test_function(volatile long *ptr)
+{
+	*ptr = 0x1234;
+}
+#endif
 
 __attribute__ ((noinline))
 static int test_function(void)
 {
+	__test_function(&the_var);
+	the_var++;
 	return time(NULL);
 }
 
+static void sig_handler_2(int signum __maybe_unused,
+			  siginfo_t *oh __maybe_unused,
+			  void *uc __maybe_unused)
+{
+	overflows_2++;
+	if (overflows_2 > 10) {
+		ioctl(fd1, PERF_EVENT_IOC_DISABLE, 0);
+		ioctl(fd2, PERF_EVENT_IOC_DISABLE, 0);
+		ioctl(fd3, PERF_EVENT_IOC_DISABLE, 0);
+	}
+}
+
 static void sig_handler(int signum __maybe_unused,
 			siginfo_t *oh __maybe_unused,
 			void *uc __maybe_unused)
@@ -54,10 +99,11 @@ static void sig_handler(int signum __maybe_unused,
 		 */
 		ioctl(fd1, PERF_EVENT_IOC_DISABLE, 0);
 		ioctl(fd2, PERF_EVENT_IOC_DISABLE, 0);
+		ioctl(fd3, PERF_EVENT_IOC_DISABLE, 0);
 	}
 }
 
-static int bp_event(void *fn, int setup_signal)
+static int __event(bool is_x, void *addr, int signal)
 {
 	struct perf_event_attr pe;
 	int fd;
@@ -67,8 +113,8 @@ static int bp_event(void *fn, int setup_signal)
 	pe.size = sizeof(struct perf_event_attr);
 
 	pe.config = 0;
-	pe.bp_type = HW_BREAKPOINT_X;
-	pe.bp_addr = (unsigned long) fn;
+	pe.bp_type = is_x ? HW_BREAKPOINT_X : HW_BREAKPOINT_W;
+	pe.bp_addr = (unsigned long) addr;
 	pe.bp_len = sizeof(long);
 
 	pe.sample_period = 1;
@@ -86,17 +132,25 @@ static int bp_event(void *fn, int setup_signal)
 		return TEST_FAIL;
 	}
 
-	if (setup_signal) {
-		fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC);
-		fcntl(fd, F_SETSIG, SIGIO);
-		fcntl(fd, F_SETOWN, getpid());
-	}
+	fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC);
+	fcntl(fd, F_SETSIG, signal);
+	fcntl(fd, F_SETOWN, getpid());
 
 	ioctl(fd, PERF_EVENT_IOC_RESET, 0);
 
 	return fd;
 }
 
+static int bp_event(void *addr, int signal)
+{
+	return __event(true, addr, signal);
+}
+
+static int wp_event(void *addr, int signal)
+{
+	return __event(false, addr, signal);
+}
+
 static long long bp_count(int fd)
 {
 	long long count;
@@ -114,7 +168,7 @@ static long long bp_count(int fd)
 int test__bp_signal(int subtest __maybe_unused)
 {
 	struct sigaction sa;
-	long long count1, count2;
+	long long count1, count2, count3;
 
 	/* setup SIGIO signal handler */
 	memset(&sa, 0, sizeof(struct sigaction));
@@ -126,21 +180,52 @@ int test__bp_signal(int subtest __maybe_unused)
 		return TEST_FAIL;
 	}
 
+	sa.sa_sigaction = (void *) sig_handler_2;
+	if (sigaction(SIGUSR1, &sa, NULL) < 0) {
+		pr_debug("failed setting up signal handler 2\n");
+		return TEST_FAIL;
+	}
+
 	/*
 	 * We create following events:
 	 *
-	 * fd1 - breakpoint event on test_function with SIGIO
+	 * fd1 - breakpoint event on __test_function with SIGIO
 	 *       signal configured. We should get signal
 	 *       notification each time the breakpoint is hit
 	 *
-	 * fd2 - breakpoint event on sig_handler without SIGIO
+	 * fd2 - breakpoint event on sig_handler with SIGUSR1
+	 *       configured. We should get SIGUSR1 each time when
+	 *       breakpoint is hit
+	 *
+	 * fd3 - watchpoint event on __test_function with SIGIO
 	 *       configured.
 	 *
 	 * Following processing should happen:
-	 *   - execute test_function
-	 *   - fd1 event breakpoint hit -> count1 == 1
-	 *   - SIGIO is delivered       -> overflows == 1
-	 *   - fd2 event breakpoint hit -> count2 == 1
+	 *   Exec:               Action:                       Result:
+	 *   incq (%rdi)       - fd1 event breakpoint hit   -> count1 == 1
+	 *                     - SIGIO is delivered
+	 *   sig_handler       - fd2 event breakpoint hit   -> count2 == 1
+	 *                     - SIGUSR1 is delivered
+	 *   sig_handler_2                                  -> overflows_2 == 1  (nested signal)
+	 *   sys_rt_sigreturn  - return from sig_handler_2
+	 *   overflows++                                    -> overflows = 1
+	 *   sys_rt_sigreturn  - return from sig_handler
+	 *   incq (%rdi)       - fd3 event watchpoint hit   -> count3 == 1       (wp and bp in one insn)
+	 *                     - SIGIO is delivered
+	 *   sig_handler       - fd2 event breakpoint hit   -> count2 == 2
+	 *                     - SIGUSR1 is delivered
+	 *   sig_handler_2                                  -> overflows_2 == 2  (nested signal)
+	 *   sys_rt_sigreturn  - return from sig_handler_2
+	 *   overflows++                                    -> overflows = 2
+	 *   sys_rt_sigreturn  - return from sig_handler
+	 *   the_var++         - fd3 event watchpoint hit   -> count3 == 2       (standalone watchpoint)
+	 *                     - SIGIO is delivered
+	 *   sig_handler       - fd2 event breakpoint hit   -> count2 == 3
+	 *                     - SIGUSR1 is delivered
+	 *   sig_handler_2                                  -> overflows_2 == 3  (nested signal)
+	 *   sys_rt_sigreturn  - return from sig_handler_2
+	 *   overflows++                                    -> overflows == 3
+	 *   sys_rt_sigreturn  - return from sig_handler
 	 *
 	 * The test case check following error conditions:
 	 * - we get stuck in signal handler because of debug
@@ -152,11 +237,13 @@ int test__bp_signal(int subtest __maybe_unused)
 	 *
 	 */
 
-	fd1 = bp_event(test_function, 1);
-	fd2 = bp_event(sig_handler, 0);
+	fd1 = bp_event(__test_function, SIGIO);
+	fd2 = bp_event(sig_handler, SIGUSR1);
+	fd3 = wp_event((void *)&the_var, SIGIO);
 
 	ioctl(fd1, PERF_EVENT_IOC_ENABLE, 0);
 	ioctl(fd2, PERF_EVENT_IOC_ENABLE, 0);
+	ioctl(fd3, PERF_EVENT_IOC_ENABLE, 0);
 
 	/*
 	 * Kick off the test by trigering 'fd1'
@@ -166,15 +253,18 @@ int test__bp_signal(int subtest __maybe_unused)
 
 	ioctl(fd1, PERF_EVENT_IOC_DISABLE, 0);
 	ioctl(fd2, PERF_EVENT_IOC_DISABLE, 0);
+	ioctl(fd3, PERF_EVENT_IOC_DISABLE, 0);
 
 	count1 = bp_count(fd1);
 	count2 = bp_count(fd2);
+	count3 = bp_count(fd3);
 
 	close(fd1);
 	close(fd2);
+	close(fd3);
 
-	pr_debug("count1 %lld, count2 %lld, overflow %d\n",
-		 count1, count2, overflows);
+	pr_debug("count1 %lld, count2 %lld, count3 %lld, overflow %d, overflows_2 %d\n",
+		 count1, count2, count3, overflows, overflows_2);
 
 	if (count1 != 1) {
 		if (count1 == 11)
@@ -183,12 +273,18 @@ int test__bp_signal(int subtest __maybe_unused)
 			pr_debug("failed: wrong count for bp1%lld\n", count1);
 	}
 
-	if (overflows != 1)
+	if (overflows != 3)
 		pr_debug("failed: wrong overflow hit\n");
 
-	if (count2 != 1)
+	if (overflows_2 != 3)
+		pr_debug("failed: wrong overflow_2 hit\n");
+
+	if (count2 != 3)
 		pr_debug("failed: wrong count for bp2\n");
 
-	return count1 == 1 && overflows == 1 && count2 == 1 ?
+	if (count3 != 2)
+		pr_debug("failed: wrong count for bp3\n");
+
+	return count1 == 1 && overflows == 3 && count2 == 3 && overflows_2 == 3 && count3 == 2 ?
 		TEST_OK : TEST_FAIL;
 }
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306720 — Re: [PATCH 17/53] perf test: Improve bp_signal

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-01-11 22:40 +0100
SubjectRe: [PATCH 17/53] perf test: Improve bp_signal
Message-ID<qPSlZ-84V-15@gated-at.bofh.it>
In reply to#1306227
Em Mon, Jan 11, 2016 at 01:48:08PM +0000, Wang Nan escreveu:
> Will Deacon [1] has some question on patch [2]. This patch improves
> test__bp_signal so we can test:
> 
>  1. A watchpoint and a breakpoint that fire on the same instruction
>  2. Nested signals
> 
> Test result:
> 
>  On x86_64 and ARM64 (result are similar with patch [2] on ARM64):
> 
>  # ./perf test -v signal
>  17: Test breakpoint overflow signal handler                  :
>  --- start ---
>  test child forked, pid 10213
>  count1 1, count2 3, count3 2, overflow 3, overflows_2 3
>  test child finished with 0
>  ---- end ----
>  Test breakpoint overflow signal handler: Ok
> 
> So at least 2 cases Will doubted are handled correctly.
> 
> [1] http://lkml.kernel.org/g/20160104165535.GI1616@arm.com
> [2] http://lkml.kernel.org/g/1450921362-198371-1-git-send-email-wangnan0@huawei.com
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Cc: Will Deacon <will.deacon@arm.com>

Will, are you ok with this one? Can I have an Acked-by or better,
Tested-by for the AARCH64 base?

IIRC Jiri made some comment about this one?

- Arnaldo

> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/tests/bp_signal.c | 140 ++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 118 insertions(+), 22 deletions(-)
> 
> diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
> index fb80c9e..1d1bb48 100644
> --- a/tools/perf/tests/bp_signal.c
> +++ b/tools/perf/tests/bp_signal.c
> @@ -29,14 +29,59 @@
>  
>  static int fd1;
>  static int fd2;
> +static int fd3;
>  static int overflows;
> +static int overflows_2;
> +
> +volatile long the_var;
> +
> +
> +/*
> + * Use ASM to ensure watchpoint and breakpoint can be triggered
> + * at one instruction.
> + */
> +#if defined (__x86_64__)
> +extern void __test_function(volatile long *ptr);
> +asm (
> +	".globl __test_function\n"
> +	"__test_function:\n"
> +	"incq (%rdi)\n"
> +	"ret\n");
> +#elif defined (__aarch64__)
> +extern void __test_function(volatile long *ptr);
> +asm (
> +	".globl __test_function\n"
> +	"__test_function:\n"
> +	"str x30, [x0]\n"
> +	"ret\n");
> +
> +#else
> +static void __test_function(volatile long *ptr)
> +{
> +	*ptr = 0x1234;
> +}
> +#endif
>  
>  __attribute__ ((noinline))
>  static int test_function(void)
>  {
> +	__test_function(&the_var);
> +	the_var++;
>  	return time(NULL);
>  }
>  
> +static void sig_handler_2(int signum __maybe_unused,
> +			  siginfo_t *oh __maybe_unused,
> +			  void *uc __maybe_unused)
> +{
> +	overflows_2++;
> +	if (overflows_2 > 10) {
> +		ioctl(fd1, PERF_EVENT_IOC_DISABLE, 0);
> +		ioctl(fd2, PERF_EVENT_IOC_DISABLE, 0);
> +		ioctl(fd3, PERF_EVENT_IOC_DISABLE, 0);
> +	}
> +}
> +
>  static void sig_handler(int signum __maybe_unused,
>  			siginfo_t *oh __maybe_unused,
>  			void *uc __maybe_unused)
> @@ -54,10 +99,11 @@ static void sig_handler(int signum __maybe_unused,
>  		 */
>  		ioctl(fd1, PERF_EVENT_IOC_DISABLE, 0);
>  		ioctl(fd2, PERF_EVENT_IOC_DISABLE, 0);
> +		ioctl(fd3, PERF_EVENT_IOC_DISABLE, 0);
>  	}
>  }
>  
> -static int bp_event(void *fn, int setup_signal)
> +static int __event(bool is_x, void *addr, int signal)
>  {
>  	struct perf_event_attr pe;
>  	int fd;
> @@ -67,8 +113,8 @@ static int bp_event(void *fn, int setup_signal)
>  	pe.size = sizeof(struct perf_event_attr);
>  
>  	pe.config = 0;
> -	pe.bp_type = HW_BREAKPOINT_X;
> -	pe.bp_addr = (unsigned long) fn;
> +	pe.bp_type = is_x ? HW_BREAKPOINT_X : HW_BREAKPOINT_W;
> +	pe.bp_addr = (unsigned long) addr;
>  	pe.bp_len = sizeof(long);
>  
>  	pe.sample_period = 1;
> @@ -86,17 +132,25 @@ static int bp_event(void *fn, int setup_signal)
>  		return TEST_FAIL;
>  	}
>  
> -	if (setup_signal) {
> -		fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC);
> -		fcntl(fd, F_SETSIG, SIGIO);
> -		fcntl(fd, F_SETOWN, getpid());
> -	}
> +	fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC);
> +	fcntl(fd, F_SETSIG, signal);
> +	fcntl(fd, F_SETOWN, getpid());
>  
>  	ioctl(fd, PERF_EVENT_IOC_RESET, 0);
>  
>  	return fd;
>  }
>  
> +static int bp_event(void *addr, int signal)
> +{
> +	return __event(true, addr, signal);
> +}
> +
> +static int wp_event(void *addr, int signal)
> +{
> +	return __event(false, addr, signal);
> +}
> +
>  static long long bp_count(int fd)
>  {
>  	long long count;
> @@ -114,7 +168,7 @@ static long long bp_count(int fd)
>  int test__bp_signal(int subtest __maybe_unused)
>  {
>  	struct sigaction sa;
> -	long long count1, count2;
> +	long long count1, count2, count3;
>  
>  	/* setup SIGIO signal handler */
>  	memset(&sa, 0, sizeof(struct sigaction));
> @@ -126,21 +180,52 @@ int test__bp_signal(int subtest __maybe_unused)
>  		return TEST_FAIL;
>  	}
>  
> +	sa.sa_sigaction = (void *) sig_handler_2;
> +	if (sigaction(SIGUSR1, &sa, NULL) < 0) {
> +		pr_debug("failed setting up signal handler 2\n");
> +		return TEST_FAIL;
> +	}
> +
>  	/*
>  	 * We create following events:
>  	 *
> -	 * fd1 - breakpoint event on test_function with SIGIO
> +	 * fd1 - breakpoint event on __test_function with SIGIO
>  	 *       signal configured. We should get signal
>  	 *       notification each time the breakpoint is hit
>  	 *
> -	 * fd2 - breakpoint event on sig_handler without SIGIO
> +	 * fd2 - breakpoint event on sig_handler with SIGUSR1
> +	 *       configured. We should get SIGUSR1 each time when
> +	 *       breakpoint is hit
> +	 *
> +	 * fd3 - watchpoint event on __test_function with SIGIO
>  	 *       configured.
>  	 *
>  	 * Following processing should happen:
> -	 *   - execute test_function
> -	 *   - fd1 event breakpoint hit -> count1 == 1
> -	 *   - SIGIO is delivered       -> overflows == 1
> -	 *   - fd2 event breakpoint hit -> count2 == 1
> +	 *   Exec:               Action:                       Result:
> +	 *   incq (%rdi)       - fd1 event breakpoint hit   -> count1 == 1
> +	 *                     - SIGIO is delivered
> +	 *   sig_handler       - fd2 event breakpoint hit   -> count2 == 1
> +	 *                     - SIGUSR1 is delivered
> +	 *   sig_handler_2                                  -> overflows_2 == 1  (nested signal)
> +	 *   sys_rt_sigreturn  - return from sig_handler_2
> +	 *   overflows++                                    -> overflows = 1
> +	 *   sys_rt_sigreturn  - return from sig_handler
> +	 *   incq (%rdi)       - fd3 event watchpoint hit   -> count3 == 1       (wp and bp in one insn)
> +	 *                     - SIGIO is delivered
> +	 *   sig_handler       - fd2 event breakpoint hit   -> count2 == 2
> +	 *                     - SIGUSR1 is delivered
> +	 *   sig_handler_2                                  -> overflows_2 == 2  (nested signal)
> +	 *   sys_rt_sigreturn  - return from sig_handler_2
> +	 *   overflows++                                    -> overflows = 2
> +	 *   sys_rt_sigreturn  - return from sig_handler
> +	 *   the_var++         - fd3 event watchpoint hit   -> count3 == 2       (standalone watchpoint)
> +	 *                     - SIGIO is delivered
> +	 *   sig_handler       - fd2 event breakpoint hit   -> count2 == 3
> +	 *                     - SIGUSR1 is delivered
> +	 *   sig_handler_2                                  -> overflows_2 == 3  (nested signal)
> +	 *   sys_rt_sigreturn  - return from sig_handler_2
> +	 *   overflows++                                    -> overflows == 3
> +	 *   sys_rt_sigreturn  - return from sig_handler
>  	 *
>  	 * The test case check following error conditions:
>  	 * - we get stuck in signal handler because of debug
> @@ -152,11 +237,13 @@ int test__bp_signal(int subtest __maybe_unused)
>  	 *
>  	 */
>  
> -	fd1 = bp_event(test_function, 1);
> -	fd2 = bp_event(sig_handler, 0);
> +	fd1 = bp_event(__test_function, SIGIO);
> +	fd2 = bp_event(sig_handler, SIGUSR1);
> +	fd3 = wp_event((void *)&the_var, SIGIO);
>  
>  	ioctl(fd1, PERF_EVENT_IOC_ENABLE, 0);
>  	ioctl(fd2, PERF_EVENT_IOC_ENABLE, 0);
> +	ioctl(fd3, PERF_EVENT_IOC_ENABLE, 0);
>  
>  	/*
>  	 * Kick off the test by trigering 'fd1'
> @@ -166,15 +253,18 @@ int test__bp_signal(int subtest __maybe_unused)
>  
>  	ioctl(fd1, PERF_EVENT_IOC_DISABLE, 0);
>  	ioctl(fd2, PERF_EVENT_IOC_DISABLE, 0);
> +	ioctl(fd3, PERF_EVENT_IOC_DISABLE, 0);
>  
>  	count1 = bp_count(fd1);
>  	count2 = bp_count(fd2);
> +	count3 = bp_count(fd3);
>  
>  	close(fd1);
>  	close(fd2);
> +	close(fd3);
>  
> -	pr_debug("count1 %lld, count2 %lld, overflow %d\n",
> -		 count1, count2, overflows);
> +	pr_debug("count1 %lld, count2 %lld, count3 %lld, overflow %d, overflows_2 %d\n",
> +		 count1, count2, count3, overflows, overflows_2);
>  
>  	if (count1 != 1) {
>  		if (count1 == 11)
> @@ -183,12 +273,18 @@ int test__bp_signal(int subtest __maybe_unused)
>  			pr_debug("failed: wrong count for bp1%lld\n", count1);
>  	}
>  
> -	if (overflows != 1)
> +	if (overflows != 3)
>  		pr_debug("failed: wrong overflow hit\n");
>  
> -	if (count2 != 1)
> +	if (overflows_2 != 3)
> +		pr_debug("failed: wrong overflow_2 hit\n");
> +
> +	if (count2 != 3)
>  		pr_debug("failed: wrong count for bp2\n");
>  
> -	return count1 == 1 && overflows == 1 && count2 == 1 ?
> +	if (count3 != 2)
> +		pr_debug("failed: wrong count for bp3\n");
> +
> +	return count1 == 1 && overflows == 3 && count2 == 3 && overflows_2 == 3 && count3 == 2 ?
>  		TEST_OK : TEST_FAIL;
>  }
> -- 
> 1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306977 — Re: [PATCH 17/53] perf test: Improve bp_signal

From"Wangnan (F)" <wangnan0@huawei.com>
Date2016-01-12 05:20 +0100
SubjectRe: [PATCH 17/53] perf test: Improve bp_signal
Message-ID<qPYB4-4aA-13@gated-at.bofh.it>
In reply to#1306720

On 2016/1/12 5:37, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jan 11, 2016 at 01:48:08PM +0000, Wang Nan escreveu:
>> Will Deacon [1] has some question on patch [2]. This patch improves
>> test__bp_signal so we can test:
>>
>>   1. A watchpoint and a breakpoint that fire on the same instruction
>>   2. Nested signals
>>
>> Test result:
>>
>>   On x86_64 and ARM64 (result are similar with patch [2] on ARM64):
>>
>>   # ./perf test -v signal
>>   17: Test breakpoint overflow signal handler                  :
>>   --- start ---
>>   test child forked, pid 10213
>>   count1 1, count2 3, count3 2, overflow 3, overflows_2 3
>>   test child finished with 0
>>   ---- end ----
>>   Test breakpoint overflow signal handler: Ok
>>
>> So at least 2 cases Will doubted are handled correctly.
>>
>> [1] http://lkml.kernel.org/g/20160104165535.GI1616@arm.com
>> [2] http://lkml.kernel.org/g/1450921362-198371-1-git-send-email-wangnan0@huawei.com
>>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> Cc: Will Deacon <will.deacon@arm.com>
> Will, are you ok with this one? Can I have an Acked-by or better,
> Tested-by for the AARCH64 base?

Patch [2] is still in question. On AArch64 this test will fail even
without this patch.

Thank you.

[toc] | [prev] | [next] | [standalone]


#1307139 — Re: [PATCH 17/53] perf test: Improve bp_signal

FromJiri Olsa <jolsa@redhat.com>
Date2016-01-12 10:30 +0100
SubjectRe: [PATCH 17/53] perf test: Improve bp_signal
Message-ID<qQ3r3-7nB-3@gated-at.bofh.it>
In reply to#1306720
On Mon, Jan 11, 2016 at 06:37:29PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jan 11, 2016 at 01:48:08PM +0000, Wang Nan escreveu:
> > Will Deacon [1] has some question on patch [2]. This patch improves
> > test__bp_signal so we can test:
> > 
> >  1. A watchpoint and a breakpoint that fire on the same instruction
> >  2. Nested signals
> > 
> > Test result:
> > 
> >  On x86_64 and ARM64 (result are similar with patch [2] on ARM64):
> > 
> >  # ./perf test -v signal
> >  17: Test breakpoint overflow signal handler                  :
> >  --- start ---
> >  test child forked, pid 10213
> >  count1 1, count2 3, count3 2, overflow 3, overflows_2 3
> >  test child finished with 0
> >  ---- end ----
> >  Test breakpoint overflow signal handler: Ok
> > 
> > So at least 2 cases Will doubted are handled correctly.
> > 
> > [1] http://lkml.kernel.org/g/20160104165535.GI1616@arm.com
> > [2] http://lkml.kernel.org/g/1450921362-198371-1-git-send-email-wangnan0@huawei.com
> > 
> > Signed-off-by: Wang Nan <wangnan0@huawei.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> 
> Will, are you ok with this one? Can I have an Acked-by or better,
> Tested-by for the AARCH64 base?
> 
> IIRC Jiri made some comment about this one?

I thought I acked this one.. all comments were addresses, so:

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

[toc] | [prev] | [next] | [standalone]


#1307459 — Re: [PATCH 17/53] perf test: Improve bp_signal

FromWill Deacon <will.deacon@arm.com>
Date2016-01-12 15:20 +0100
SubjectRe: [PATCH 17/53] perf test: Improve bp_signal
Message-ID<qQ7XI-23e-21@gated-at.bofh.it>
In reply to#1307139
On Tue, Jan 12, 2016 at 11:11:23AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 12, 2016 at 10:21:29AM +0100, Jiri Olsa escreveu:
> > On Mon, Jan 11, 2016 at 06:37:29PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Mon, Jan 11, 2016 at 01:48:08PM +0000, Wang Nan escreveu:
> > > > Will Deacon [1] has some question on patch [2]. This patch improves
> > > > test__bp_signal so we can test:
> > > > 
> > > >  1. A watchpoint and a breakpoint that fire on the same instruction
> > > >  2. Nested signals
> > > > 
> > > > Test result:
> > > > 
> > > >  On x86_64 and ARM64 (result are similar with patch [2] on ARM64):
> > > > 
> > > >  # ./perf test -v signal
> > > >  17: Test breakpoint overflow signal handler                  :
> > > >  --- start ---
> > > >  test child forked, pid 10213
> > > >  count1 1, count2 3, count3 2, overflow 3, overflows_2 3
> > > >  test child finished with 0
> > > >  ---- end ----
> > > >  Test breakpoint overflow signal handler: Ok
> > > > 
> > > > So at least 2 cases Will doubted are handled correctly.
> > > > 
> > > > [1] http://lkml.kernel.org/g/20160104165535.GI1616@arm.com
> > > > [2] http://lkml.kernel.org/g/1450921362-198371-1-git-send-email-wangnan0@huawei.com
> > > > 
> > > > Signed-off-by: Wang Nan <wangnan0@huawei.com>
> > > > Cc: Will Deacon <will.deacon@arm.com>
> > > 
> > > Will, are you ok with this one? Can I have an Acked-by or better,
> > > Tested-by for the AARCH64 base?
> > > 
> > > IIRC Jiri made some comment about this one?
> > 
> > I thought I acked this one.. all comments were addresses, so:
> > 
> > Acked-by: Jiri Olsa <jolsa@kernel.org>
> 
> Ok, so, Will, any comments? Nack?

Sorry, snowed under at the moment. I need to go back over the arch/arm64
patch, since I did have some concerns on that and the changes to the
perf tool don't do a lot without the corresponding architecture update
which I'm extremely nervous about.

I'll revisit that patch once I've got through the more pressing changes
in the queue.

Will

[toc] | [prev] | [next] | [standalone]


#1307465 — Re: [PATCH 17/53] perf test: Improve bp_signal

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-01-12 15:20 +0100
SubjectRe: [PATCH 17/53] perf test: Improve bp_signal
Message-ID<qQ7XI-23e-23@gated-at.bofh.it>
In reply to#1307139
Em Tue, Jan 12, 2016 at 10:21:29AM +0100, Jiri Olsa escreveu:
> On Mon, Jan 11, 2016 at 06:37:29PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Jan 11, 2016 at 01:48:08PM +0000, Wang Nan escreveu:
> > > Will Deacon [1] has some question on patch [2]. This patch improves
> > > test__bp_signal so we can test:
> > > 
> > >  1. A watchpoint and a breakpoint that fire on the same instruction
> > >  2. Nested signals
> > > 
> > > Test result:
> > > 
> > >  On x86_64 and ARM64 (result are similar with patch [2] on ARM64):
> > > 
> > >  # ./perf test -v signal
> > >  17: Test breakpoint overflow signal handler                  :
> > >  --- start ---
> > >  test child forked, pid 10213
> > >  count1 1, count2 3, count3 2, overflow 3, overflows_2 3
> > >  test child finished with 0
> > >  ---- end ----
> > >  Test breakpoint overflow signal handler: Ok
> > > 
> > > So at least 2 cases Will doubted are handled correctly.
> > > 
> > > [1] http://lkml.kernel.org/g/20160104165535.GI1616@arm.com
> > > [2] http://lkml.kernel.org/g/1450921362-198371-1-git-send-email-wangnan0@huawei.com
> > > 
> > > Signed-off-by: Wang Nan <wangnan0@huawei.com>
> > > Cc: Will Deacon <will.deacon@arm.com>
> > 
> > Will, are you ok with this one? Can I have an Acked-by or better,
> > Tested-by for the AARCH64 base?
> > 
> > IIRC Jiri made some comment about this one?
> 
> I thought I acked this one.. all comments were addresses, so:
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Ok, so, Will, any comments? Nack?

- Arnaldo

[toc] | [prev] | [next] | [standalone]


#1306229 — [PATCH 47/53] perf record: Don't read from and poll overwrite channel

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 47/53] perf record: Don't read from and poll overwrite channel
Message-ID<qPLaO-38k-15@gated-at.bofh.it>
In reply to#1306221
Read from overwritable ring buffer is unreliable. Also, there's
no need to poll on a overwritable channel because we don't need
consuming data from it. Only select PULLHUP and PULLERR events.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c | 15 ++++++++++++++-
 tools/perf/util/evlist.c    | 27 +++++++++++++++++++++++----
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index fafcee7..e55a23f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -453,6 +453,19 @@ static struct perf_event_header finished_round_event = {
 	.type = PERF_RECORD_FINISHED_ROUND,
 };
 
+static bool record__mmap_should_read(struct record *rec, int idx)
+{
+	int channel = -1;
+
+	if (!rec->evlist->mmap[idx].base)
+		return false;
+	if (perf_evlist__channel_idx(rec->evlist, &channel, &idx))
+		return false;
+	if (perf_evlist__channel_check(rec->evlist, channel, RDONLY))
+		return false;
+	return true;
+}
+
 static int record__mmap_read_all(struct record *rec)
 {
 	u64 bytes_written = rec->bytes_written;
@@ -463,7 +476,7 @@ static int record__mmap_read_all(struct record *rec)
 	for (i = 0; i < total_mmaps; i++) {
 		struct auxtrace_mmap *mm = &rec->evlist->mmap[i].auxtrace_mmap;
 
-		if (rec->evlist->mmap[i].base) {
+		if (record__mmap_should_read(rec, i)) {
 			if (record__mmap_read(rec, i) != 0) {
 				rc = -1;
 				goto out;
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index dc00840..0511fd2 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -461,9 +461,9 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist)
 	return 0;
 }
 
-static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx)
+static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx, short revent)
 {
-	int pos = fdarray__add(&evlist->pollfd, fd, POLLIN | POLLERR | POLLHUP);
+	int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP);
 	/*
 	 * Save the idx so that when we filter out fds POLLHUP'ed we can
 	 * close the associated evlist->mmap[] entry.
@@ -479,7 +479,7 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx
 
 int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd)
 {
-	return __perf_evlist__add_pollfd(evlist, fd, -1);
+	return __perf_evlist__add_pollfd(evlist, fd, -1, POLLIN);
 }
 
 static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd)
@@ -1007,6 +1007,22 @@ perf_evlist__channel_complete(struct perf_evlist *evlist)
 	return 0;
 }
 
+static bool
+perf_evlist__should_poll(struct perf_evlist *evlist,
+			 struct perf_evsel *evsel,
+			 int channel, int idx)
+{
+	int err = perf_evlist__channel_idx(evlist, &channel, &idx);
+
+	if (err)
+		return false;
+	if (evsel->system_wide)
+		return false;
+	if (perf_evlist__channel_check(evlist, channel, RDONLY))
+		return false;
+	return true;
+}
+
 static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
 				       struct mmap_params *mp, int cpu,
 				       int thread, int *outputs)
@@ -1015,6 +1031,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
 
 	evlist__for_each(evlist, evsel) {
 		int fd, channel, idx, err;
+		short revent = POLLIN;
 
 		channel = perf_evlist__channel_find(evlist, evsel, false);
 		if (channel < 0) {
@@ -1044,6 +1061,8 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
 			perf_evlist__mmap_get(evlist, idx);
 		}
 
+		if (!perf_evlist__should_poll(evlist, evsel, channel, idx))
+			revent = 0;
 		/*
 		 * The system_wide flag causes a selected event to be opened
 		 * always without a pid.  Consequently it will never get a
@@ -1052,7 +1071,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int _idx,
 		 * Therefore don't add it for polling.
 		 */
 		if (!evsel->system_wide &&
-		    __perf_evlist__add_pollfd(evlist, fd, idx) < 0) {
+		    __perf_evlist__add_pollfd(evlist, fd, idx, revent) < 0) {
 			perf_evlist__mmap_put(evlist, idx);
 			return -1;
 		}
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306230 — [PATCH 28/53] perf tools: Move timestamp creation to util

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 28/53] perf tools: Move timestamp creation to util
Message-ID<qPLaO-38k-19@gated-at.bofh.it>
In reply to#1306221
Timestamp generation becomes a public available helper. Which will
be used by 'perf record', help it output to split output file based
on time.

For example:

 perf.data.2015122620363710
 perf.data.2015122620364092
 perf.data.2015122620365423
 ...

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-buildid-cache.c | 14 +-------------
 tools/perf/util/util.c             | 17 +++++++++++++++++
 tools/perf/util/util.h             |  1 +
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index d93bff7..632efc6 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -38,19 +38,7 @@ static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
 
 static int build_id_cache__kcore_dir(char *dir, size_t sz)
 {
-	struct timeval tv;
-	struct tm tm;
-	char dt[32];
-
-	if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm))
-		return -1;
-
-	if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm))
-		return -1;
-
-	scnprintf(dir, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000);
-
-	return 0;
+	return fetch_current_timestamp(dir, sz);
 }
 
 static bool same_kallsyms_reloc(const char *from_dir, char *to_dir)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 88b8f8d..5b8259b 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -690,3 +690,20 @@ out:
 
 	return tip;
 }
+
+int fetch_current_timestamp(char *buf, size_t sz)
+{
+	struct timeval tv;
+	struct tm tm;
+	char dt[32];
+
+	if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm))
+		return -1;
+
+	if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm))
+		return -1;
+
+	scnprintf(buf, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000);
+
+	return 0;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index fe915e6..ef97038 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -343,5 +343,6 @@ int fetch_kernel_version(unsigned int *puint,
 #define KVER_PARAM(x)	KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)
 
 const char *perf_tip(const char *dirpath);
+int fetch_current_timestamp(char *buf, size_t sz);
 
 #endif /* GIT_COMPAT_UTIL_H */
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306231 — [PATCH 39/53] perf record: Re-synthesize tracking events after output switching

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 39/53] perf record: Re-synthesize tracking events after output switching
Message-ID<qPLaP-38k-21@gated-at.bofh.it>
In reply to#1306221
Tracking events describe kernel and threads. They are generated by
reading /proc/kallsyms, /proc/*/maps and /proc/*/task/* during
initialization of 'perf record', serialized into event sequences and put
at the head of 'perf.data'. In case of output switching, each output
file should contain those events.

This patch calls record__synthesize() during output switching, so the
event sequences described above can be collected again.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 790361b..5305a30 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -525,6 +525,8 @@ record__finish_output(struct record *rec)
 	return;
 }
 
+static int record__synthesize(struct record *rec);
+
 static int
 record__switch_output(struct record *rec, bool at_exit)
 {
@@ -553,6 +555,15 @@ record__switch_output(struct record *rec, bool at_exit)
 	if (!quiet)
 		fprintf(stderr, "[ perf record: Dump %s.%s ]\n",
 			file->path, timestamp);
+
+	/* Reinit machine */
+	if (!at_exit) {
+		machines__exit(&rec->session->machines);
+		machines__init(&rec->session->machines);
+		perf_session__create_kernel_maps(rec->session);
+		perf_session__set_id_hdr_size(rec->session);
+		record__synthesize(rec);
+	}
 	return fd;
 }
 
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306233 — [PATCH 33/53] perf record: Introduce record__finish_output() to finish a perf.data

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 33/53] perf record: Introduce record__finish_output() to finish a perf.data
Message-ID<qPLaP-38k-23@gated-at.bofh.it>
In reply to#1306221
Move code for finalizing 'perf.data' to record__finish_output(). It
will be used by following commits to split output to multiple files.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c | 45 +++++++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 318b90f..91bf4b1 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -493,6 +493,33 @@ static void record__init_features(struct record *rec)
 	perf_header__clear_feat(&session->header, HEADER_STAT);
 }
 
+static void
+record__finish_output(struct record *rec)
+{
+	struct perf_data_file *file = &rec->file;
+	int fd = perf_data_file__fd(file);
+
+	if (file->is_pipe)
+		return;
+
+	rec->session->header.data_size += rec->bytes_written;
+	file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
+
+	if (!rec->no_buildid) {
+		process_buildids(rec);
+		/*
+		 * We take all buildids when the file contains
+		 * AUX area tracing data because we do not decode the
+		 * trace because it would take too long.
+		 */
+		if (rec->opts.full_auxtrace)
+			dsos__hit_all(rec->session);
+	}
+	perf_session__write_header(rec->session, rec->evlist, fd, true);
+
+	return;
+}
+
 static volatile int workload_exec_errno;
 
 /*
@@ -820,22 +847,8 @@ out_child:
 	/* this will be recalculated during process_buildids() */
 	rec->samples = 0;
 
-	if (!err && !file->is_pipe) {
-		rec->session->header.data_size += rec->bytes_written;
-		file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
-
-		if (!rec->no_buildid) {
-			process_buildids(rec);
-			/*
-			 * We take all buildids when the file contains
-			 * AUX area tracing data because we do not decode the
-			 * trace because it would take too long.
-			 */
-			if (rec->opts.full_auxtrace)
-				dsos__hit_all(rec->session);
-		}
-		perf_session__write_header(rec->session, rec->evlist, fd, true);
-	}
+	if (!err)
+		record__finish_output(rec);
 
 	if (!err && !quiet) {
 		char samples[128];
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306235 — [PATCH 46/53] perf tools: Squash overwrite setting into channel

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 46/53] perf tools: Squash overwrite setting into channel
Message-ID<qPLaQ-38k-29@gated-at.bofh.it>
In reply to#1306221
Make 'overwrite' a channel configuration other than a evlist global
option. With this setting an evlist can have two channels, one is
normal channel, another is overwritable channel.
perf_evlist__channel_for_evsel() ensures events with 'overwrite'
configuration inserted to overwritable channel.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c |  2 +-
 tools/perf/util/evlist.c    | 42 +++++++++++++++++++++++++++---------------
 tools/perf/util/evlist.h    |  5 ++---
 tools/perf/util/evsel.h     |  1 +
 4 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index fee5fd2..fafcee7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -356,7 +356,7 @@ try_again:
 	}
 
 	perf_evlist__channel_reset(evlist);
-	if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, false,
+	if (perf_evlist__mmap_ex(evlist, opts->mmap_pages,
 				 opts->auxtrace_mmap_pages,
 				 opts->auxtrace_snapshot_mode) < 0) {
 		if (errno == EPERM) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 9187747..dc00840 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -731,7 +731,7 @@ union perf_event *perf_evlist__mmap_read_ex(struct perf_evlist *evlist,
 		return NULL;
 
 	head = perf_mmap__read_head(md);
-	if (evlist->overwrite) {
+	if (perf_evlist__channel_check(evlist, channel, RDONLY)) {
 		/*
 		 * If we're further behind than half the buffer, there's a chance
 		 * the writer will bite our tail and mess up the samples under us.
@@ -820,7 +820,7 @@ void perf_evlist__mmap_consume_ex(struct perf_evlist *evlist,
 		return;
 	}
 
-	if (!evlist->overwrite) {
+	if (!perf_evlist__channel_check(evlist, channel, RDONLY)) {
 		u64 old = md->prev;
 
 		perf_mmap__write_tail(md, old);
@@ -918,7 +918,6 @@ static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 }
 
 struct mmap_params {
-	int prot;
 	int mask;
 	struct auxtrace_mmap_params auxtrace_mp;
 };
@@ -926,6 +925,15 @@ struct mmap_params {
 static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
 			       struct mmap_params *mp, int fd)
 {
+	int channel = perf_evlist__idx_channel(evlist, idx);
+	int prot = PROT_READ;
+
+	if (channel < 0)
+		return -1;
+
+	if (!perf_evlist__channel_check(evlist, channel, RDONLY))
+		prot |= PROT_WRITE;
+
 	/*
 	 * The last one will be done at perf_evlist__mmap_consume(), so that we
 	 * make sure we don't prevent tools from consuming every last event in
@@ -942,7 +950,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
 	atomic_set(&evlist->mmap[idx].refcnt, 2);
 	evlist->mmap[idx].prev = 0;
 	evlist->mmap[idx].mask = mp->mask;
-	evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, mp->prot,
+	evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
 				      MAP_SHARED, fd, 0);
 	if (evlist->mmap[idx].base == MAP_FAILED) {
 		pr_debug2("failed to mmap perf event ring buffer, error %d\n",
@@ -959,9 +967,13 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
 }
 
 static unsigned long
-perf_evlist__channel_for_evsel(struct perf_evsel *evsel __maybe_unused)
+perf_evlist__channel_for_evsel(struct perf_evsel *evsel)
 {
-	return 0;
+	unsigned long flag = 0;
+
+	if (evsel->overwrite)
+		flag |= PERF_EVLIST__CHANNEL_RDONLY;
+	return flag;
 }
 
 static int
@@ -1211,11 +1223,10 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
  * perf_evlist__mmap_ex - Create mmaps to receive events.
  * @evlist: list of events
  * @pages: map length in pages
- * @overwrite: overwrite older events?
  * @auxtrace_pages - auxtrace map length in pages
  * @auxtrace_overwrite - overwrite older auxtrace data?
  *
- * If @overwrite is %false the user needs to signal event consumption using
+ * For writable channel, the user needs to signal event consumption using
  * perf_mmap__write_tail().  Using perf_evlist__mmap_read() does this
  * automatically.
  *
@@ -1225,16 +1236,13 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
  * Return: %0 on success, negative error code otherwise.
  */
 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
-			 bool overwrite, unsigned int auxtrace_pages,
-			 bool auxtrace_overwrite)
+			 unsigned int auxtrace_pages, bool auxtrace_overwrite)
 {
 	int err;
 	struct perf_evsel *evsel;
 	const struct cpu_map *cpus = evlist->cpus;
 	const struct thread_map *threads = evlist->threads;
-	struct mmap_params mp = {
-		.prot = PROT_READ | (overwrite ? 0 : PROT_WRITE),
-	};
+	struct mmap_params mp;
 
 	err = perf_evlist__channel_complete(evlist);
 	if (err)
@@ -1246,7 +1254,6 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 	if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0)
 		return -ENOMEM;
 
-	evlist->overwrite = overwrite;
 	evlist->mmap_len = perf_evlist__mmap_size(pages);
 	pr_debug("mmap size %zuB\n", evlist->mmap_len);
 	mp.mask = evlist->mmap_len - page_size - 1;
@@ -1270,8 +1277,13 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 		      bool overwrite)
 {
+	struct perf_evsel *evsel;
+
 	perf_evlist__channel_reset(evlist);
-	return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false);
+	evlist__for_each(evlist, evsel)
+		evsel->overwrite = overwrite;
+
+	return perf_evlist__mmap_ex(evlist, pages, 0, false);
 }
 
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index b652587..21a8b85 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -23,6 +23,7 @@ struct record_opts;
 #define PERF_EVLIST__NR_CHANNELS	2
 enum perf_evlist_mmap_flag {
 	PERF_EVLIST__CHANNEL_ENABLED	= 1,
+	PERF_EVLIST__CHANNEL_RDONLY	= 2,
 };
 
 /**
@@ -45,7 +46,6 @@ struct perf_evlist {
 	int		 nr_entries;
 	int		 nr_groups;
 	int		 nr_mmaps;
-	bool		 overwrite;
 	bool		 enabled;
 	bool		 has_user_cpus;
 	size_t		 mmap_len;
@@ -203,8 +203,7 @@ int perf_evlist__parse_mmap_pages(const struct option *opt,
 				  int unset);
 
 int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,
-			 bool overwrite, unsigned int auxtrace_pages,
-			 bool auxtrace_overwrite);
+			 unsigned int auxtrace_pages, bool auxtrace_overwrite);
 int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
 		      bool overwrite);
 void perf_evlist__munmap(struct perf_evlist *evlist);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 022fcff..8932a5c 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -115,6 +115,7 @@ struct perf_evsel {
 	bool			tracking;
 	bool			per_pkg;
 	bool			precise_max;
+	bool			overwrite;
 	/* parse modifier helper */
 	int			exclude_GH;
 	int			nr_members;
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


#1306236 — [PATCH 34/53] perf record: Use OPT_BOOLEAN_SET for buildid cache related options

FromWang Nan <wangnan0@huawei.com>
Date2016-01-11 15:00 +0100
Subject[PATCH 34/53] perf record: Use OPT_BOOLEAN_SET for buildid cache related options
Message-ID<qPLaQ-38k-37@gated-at.bofh.it>
In reply to#1306221
'perf record' knows whether buildid cache is enabled (via
--no-no-buildid-cache) deliberately. Buildid cache can be turned off
in some situations.

Output switching support needs this feature to turn off buildid cache
by default.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/builtin-record.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 91bf4b1..7a26cb5 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -50,7 +50,9 @@ struct record {
 	const char		*progname;
 	int			realtime_prio;
 	bool			no_buildid;
+	bool			no_buildid_set;
 	bool			no_buildid_cache;
+	bool			no_buildid_cache_set;
 	unsigned long long	samples;
 };
 
@@ -1176,10 +1178,12 @@ struct option __record_options[] = {
 	OPT_BOOLEAN('P', "period", &record.opts.period, "Record the sample period"),
 	OPT_BOOLEAN('n', "no-samples", &record.opts.no_samples,
 		    "don't sample"),
-	OPT_BOOLEAN('N', "no-buildid-cache", &record.no_buildid_cache,
-		    "do not update the buildid cache"),
-	OPT_BOOLEAN('B', "no-buildid", &record.no_buildid,
-		    "do not collect buildids in perf.data"),
+	OPT_BOOLEAN_SET('N', "no-buildid-cache", &record.no_buildid_cache,
+			&record.no_buildid_cache_set,
+			"do not update the buildid cache"),
+	OPT_BOOLEAN_SET('B', "no-buildid", &record.no_buildid,
+			&record.no_buildid_set,
+			"do not collect buildids in perf.data"),
 	OPT_CALLBACK('G', "cgroup", &record.evlist, "name",
 		     "monitor event in cgroup name only",
 		     parse_cgroups),
-- 
1.8.3.4

[toc] | [prev] | [next] | [standalone]


Page 1 of 5  [1] 2 3 4 5  Next page →

Back to top | Article view | linux.kernel


csiph-web