linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 00/73] libperf: Add sampling interface
@ 2019-09-13 13:22 Jiri Olsa
  2019-09-13 13:22 ` [PATCH 01/73] tools: Add missing stdio.h include to asm/bug.h header Jiri Olsa
                   ` (73 more replies)
  0 siblings, 74 replies; 80+ messages in thread
From: Jiri Olsa @ 2019-09-13 13:22 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Kan Liang, Steven Rostedt, Adrian Hunter, Ian Rogers,
	Stephane Eranian, Song Liu, Alexey Budankov, Andi Kleen, lkml,
	Ingo Molnar, Namhyung Kim, Alexander Shishkin, Peter Zijlstra,
	Michael Petlan

hi,
sending changes for exporting basic sampling interface
in libperf. It's now possible to use following code in
applications via libperf:

--- (example is without error checks for simplicity)

  struct perf_event_attr attr = {
          .type             = PERF_TYPE_TRACEPOINT,
          .sample_period    = 1,
          .wakeup_watermark = 1,
          .disabled         = 1,
  };
  /* ... setup attr */

  cpus = perf_cpu_map__new(NULL);

  evlist = perf_evlist__new();
  evsel  = perf_evsel__new(&attr);
  perf_evlist__add(evlist, evsel);

  perf_evlist__set_maps(evlist, cpus, NULL);

  err = perf_evlist__open(evlist);
  err = perf_evlist__mmap(evlist, 4);

  err = perf_evlist__enable(evlist);

  /* ... monitored area, plus all the other cpus */

  err = perf_evlist__disable(evlist);

  perf_evlist__for_each_mmap(evlist, map) {
          if (perf_mmap__read_init(map) < 0)
                  continue;

          while ((event = perf_mmap__read_event(map)) != NULL) {
                  perf_mmap__consume(map);
          }

          perf_mmap__read_done(map);
  }

  perf_evlist__delete(evlist);
  perf_cpu_map__put(cpus);

--- (end)

Nothing is carved in stone so far, the interface is exported
as is available in perf now and we can change it as we want.

New tests are added in test-evlist.c to do thread and cpu based
sampling.

All the functionality should not change, however there's considerable
mmap code rewrite, so would be great if guys could run your usual
workloads to see if all is fine.. so far so good in my tests ;-)

It's also available in here:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/lib

thanks,
jirka


Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
---
Jiri Olsa (73):
      tools: Add missing stdio.h include to asm/bug.h header
      perf tests: Fix static build test
      perf tools: Rename struct perf_mmap to struct mmap
      perf tools: Rename perf_evlist__mmap() to evlist__mmap()
      perf tools: Rename perf_evlist__munmap() to evlist__munmap()
      perf tools: Rename perf_evlist__alloc_mmap() to evlist__alloc_mmap()
      perf tools: Rename perf_evlist__exit() to evlist__exit()
      perf tools: Rename perf_evlist__purge() to evlist__purge()
      libperf: Link libapi.a in libperf.so
      libperf: Add perf_mmap struct
      libperf: Add mask to struct perf_mmap
      libperf: Add fd to struct perf_mmap
      libperf: Add cpu to struct perf_mmap
      libperf: Add refcnt to struct perf_mmap
      libperf: Add prev/start/end to struct perf_mmap
      libperf: Add overwrite to struct perf_mmap
      libperf: Add event_copy to struct perf_mmap
      libperf: Add flush to struct perf_mmap
      libperf: Move system_wide from struct evsel to struct perf_evsel
      libperf: Move nr_mmaps from struct evlist to struct perf_evlist
      libperf: Move mmap_len from struct evlist to struct perf_evlist
      libperf: Move pollfd from struct evlist to struct perf_evlist
      libperf: Move sample_id from struct evsel to struct perf_evsel
      libperf: Move id from struct evsel to struct perf_evsel
      libperf: Move ids from struct evsel to struct perf_evsel
      libperf: Move heads from struct evlist to struct perf_evlist
      libperf: Add perf_evsel__alloc_id/perf_evsel__free_id functions
      libperf: Add perf_evlist__first/last functions
      libperf: Add perf_evlist__read_format function
      libperf: Add perf_evlist__id_add function
      libperf: Add perf_evlist__id_add_fd function
      libperf: Move page_size into libperf
      libperf: Merge libperf_set_print in libperf_init
      libperf: Add libperf_init call to tests
      libperf: Add libperf dependency for tests targets
      libperf: Add perf_evlist__alloc_pollfd function
      libperf: Add perf_evlist__add_pollfd function
      libperf: Add perf_evlist__poll function
      libperf: Add perf_mmap__init function
      libperf: Add struct perf_mmap_param
      libperf: Add perf_mmap__mmap_len function
      libperf: Add perf_mmap__mmap function
      libperf: Add perf_mmap__get function
      libperf: Add perf_mmap__unmap function
      libperf: Add perf_mmap__put function
      libperf: Add perf_mmap__new function
      perf tools: Use perf_mmap way to detect aux mmap
      libperf: Add perf_mmap__consume function
      libperf: Add perf_mmap__read_init function
      libperf: Add perf_mmap__read_done function
      libperf: Add perf_mmap__read_event function
      libperf: Add perf_evlist__mmap/munmap function
      libperf: Add perf_evlist__mmap_ops function
      libperf: Add perf_evlist_mmap_ops::idx callback
      libperf: Add perf_evlist_mmap_ops::new callback
      libperf: Add perf_evlist_mmap_ops::mmap callback
      perf tools: Add perf_evlist__mmap_cb_idx function
      perf tools: Add perf_evlist__mmap_cb_new function
      perf tools: Add perf_evlist__mmap_cb_mmap function
      perf tools: Switch to libperf mmap interface
      libperf: Move pollfd allocation to libperf
      libperf: Add perf_evlist__exit function
      libperf: Add perf_evlist__purge function
      libperf: Call perf_evlist__munmap/close on perf_evlist__delete
      libperf: Add perf_evlist__filter_pollfd function
      libperf: Add perf_evlist__for_each_mmap function
      libperf: Link static tests with libapi.a
      libperf: Add _GNU_SOURCE define to compilation
      libperf: Add tests_mmap_thread test
      libperf: Add tests_mmap_cpus test
      libperf: Keep count of failed tests
      libperf: Do not export perf_evsel__init/perf_evlist__init
      libperf: Add pr_err macro

 tools/include/asm/bug.h                      |   1 +
 tools/perf/arch/arm/util/cs-etm.c            |   4 +-
 tools/perf/arch/arm64/util/arm-spe.c         |   4 +-
 tools/perf/arch/x86/tests/intel-cqm.c        |   4 +-
 tools/perf/arch/x86/tests/perf-time-to-tsc.c |  19 +-
 tools/perf/arch/x86/util/intel-bts.c         |   6 +-
 tools/perf/arch/x86/util/intel-pt.c          |  14 +-
 tools/perf/builtin-kvm.c                     |  23 +-
 tools/perf/builtin-record.c                  |  90 ++---
 tools/perf/builtin-script.c                  |   4 +-
 tools/perf/builtin-stat.c                    |   6 +-
 tools/perf/builtin-top.c                     |  29 +-
 tools/perf/builtin-trace.c                   |  21 +-
 tools/perf/lib/Build                         |   1 +
 tools/perf/lib/Makefile                      |  42 ++-
 tools/perf/lib/core.c                        |  13 +-
 tools/perf/lib/evlist.c                      | 440 +++++++++++++++++++++++++
 tools/perf/lib/evsel.c                       |  30 ++
 tools/perf/lib/include/internal/evlist.h     |  74 +++++
 tools/perf/lib/include/internal/evsel.h      |  32 ++
 tools/perf/lib/include/internal/lib.h        |   2 +
 tools/perf/lib/include/internal/mmap.h       |  59 ++++
 tools/perf/lib/include/internal/tests.h      |  20 +-
 tools/perf/lib/include/perf/core.h           |   5 +-
 tools/perf/lib/include/perf/evlist.h         |  14 +-
 tools/perf/lib/include/perf/evsel.h          |   2 -
 tools/perf/lib/include/perf/mmap.h           |  14 +
 tools/perf/lib/internal.h                    |   5 +
 tools/perf/lib/lib.c                         |   2 +
 tools/perf/lib/libperf.map                   |  13 +-
 tools/perf/lib/mmap.c                        | 289 +++++++++++++++++
 tools/perf/lib/tests/Makefile                |   8 +-
 tools/perf/lib/tests/test-cpumap.c           |  10 +-
 tools/perf/lib/tests/test-evlist.c           | 228 ++++++++++++-
 tools/perf/lib/tests/test-evsel.c            |  10 +-
 tools/perf/lib/tests/test-threadmap.c        |  10 +-
 tools/perf/perf.c                            |  10 +-
 tools/perf/tests/backward-ring-buffer.c      |  17 +-
 tools/perf/tests/bpf.c                       |  15 +-
 tools/perf/tests/code-reading.c              |  19 +-
 tools/perf/tests/event-times.c               |  14 +-
 tools/perf/tests/event_update.c              |   6 +-
 tools/perf/tests/evsel-roundtrip-name.c      |   2 +-
 tools/perf/tests/hists_cumulate.c            |   2 +-
 tools/perf/tests/hists_link.c                |   4 +-
 tools/perf/tests/hists_output.c              |   2 +-
 tools/perf/tests/keep-tracking.c             |  19 +-
 tools/perf/tests/make                        |   2 +-
 tools/perf/tests/mmap-basic.c                |  13 +-
 tools/perf/tests/openat-syscall-tp-fields.c  |  19 +-
 tools/perf/tests/parse-events.c              | 116 +++----
 tools/perf/tests/perf-record.c               |  21 +-
 tools/perf/tests/sw-clock.c                  |  13 +-
 tools/perf/tests/switch-tracking.c           |  37 ++-
 tools/perf/tests/task-exit.c                 |  17 +-
 tools/perf/ui/browsers/hists.c               |   6 +-
 tools/perf/util/auxtrace.c                   |   6 +-
 tools/perf/util/auxtrace.h                   |   8 +-
 tools/perf/util/bpf-loader.c                 |   2 +-
 tools/perf/util/evlist.c                     | 469 +++++++--------------------
 tools/perf/util/evlist.h                     |  50 ++-
 tools/perf/util/evsel.c                      |  44 +--
 tools/perf/util/evsel.h                      |  29 --
 tools/perf/util/header.c                     |  38 +--
 tools/perf/util/intel-bts.c                  |   4 +-
 tools/perf/util/intel-pt.c                   |  10 +-
 tools/perf/util/jitdump.c                    |   2 +-
 tools/perf/util/mmap.c                       | 309 +++---------------
 tools/perf/util/mmap.h                       |  51 +--
 tools/perf/util/parse-events.c               |   6 +-
 tools/perf/util/python.c                     |  29 +-
 tools/perf/util/record.c                     |   6 +-
 tools/perf/util/session.c                    |  10 +-
 tools/perf/util/sort.c                       |   2 +-
 tools/perf/util/stat.c                       |   2 +-
 tools/perf/util/top.c                        |   2 +-
 tools/perf/util/util.h                       |   2 -
 77 files changed, 1862 insertions(+), 1121 deletions(-)
 create mode 100644 tools/perf/lib/include/internal/mmap.h
 create mode 100644 tools/perf/lib/include/perf/mmap.h
 create mode 100644 tools/perf/lib/mmap.c

^ permalink raw reply	[flat|nested] 80+ messages in thread

end of thread, other threads:[~2019-09-23 19:17 UTC | newest]

Thread overview: 80+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 13:22 [RFC 00/73] libperf: Add sampling interface Jiri Olsa
2019-09-13 13:22 ` [PATCH 01/73] tools: Add missing stdio.h include to asm/bug.h header Jiri Olsa
2019-09-13 13:22 ` [PATCH 02/73] perf tests: Fix static build test Jiri Olsa
2019-09-13 13:22 ` [PATCH 03/73] perf tools: Rename struct perf_mmap to struct mmap Jiri Olsa
2019-09-13 13:22 ` [PATCH 04/73] perf tools: Rename perf_evlist__mmap() to evlist__mmap() Jiri Olsa
2019-09-13 13:22 ` [PATCH 05/73] perf tools: Rename perf_evlist__munmap() to evlist__munmap() Jiri Olsa
2019-09-13 13:22 ` [PATCH 06/73] perf tools: Rename perf_evlist__alloc_mmap() to evlist__alloc_mmap() Jiri Olsa
2019-09-13 13:22 ` [PATCH 07/73] perf tools: Rename perf_evlist__exit() to evlist__exit() Jiri Olsa
2019-09-13 13:22 ` [PATCH 08/73] perf tools: Rename perf_evlist__purge() to evlist__purge() Jiri Olsa
2019-09-13 13:22 ` [PATCH 09/73] libperf: Link libapi.a in libperf.so Jiri Olsa
2019-09-13 13:22 ` [PATCH 10/73] libperf: Add perf_mmap struct Jiri Olsa
2019-09-23 15:05   ` Arnaldo Carvalho de Melo
2019-09-23 15:09     ` Jiri Olsa
2019-09-13 13:22 ` [PATCH 11/73] libperf: Add mask to struct perf_mmap Jiri Olsa
2019-09-13 13:22 ` [PATCH 12/73] libperf: Add fd " Jiri Olsa
2019-09-13 13:22 ` [PATCH 13/73] libperf: Add cpu " Jiri Olsa
2019-09-13 13:22 ` [PATCH 14/73] libperf: Add refcnt " Jiri Olsa
2019-09-13 13:22 ` [PATCH 15/73] libperf: Add prev/start/end " Jiri Olsa
2019-09-13 13:22 ` [PATCH 16/73] libperf: Add overwrite " Jiri Olsa
2019-09-13 13:22 ` [PATCH 17/73] libperf: Add event_copy " Jiri Olsa
2019-09-13 13:23 ` [PATCH 18/73] libperf: Add flush " Jiri Olsa
2019-09-13 13:23 ` [PATCH 19/73] libperf: Move system_wide from struct evsel to struct perf_evsel Jiri Olsa
2019-09-23 18:08   ` Arnaldo Carvalho de Melo
2019-09-13 13:23 ` [PATCH 20/73] libperf: Move nr_mmaps from struct evlist to struct perf_evlist Jiri Olsa
2019-09-13 13:23 ` [PATCH 21/73] libperf: Move mmap_len " Jiri Olsa
2019-09-13 13:23 ` [PATCH 22/73] libperf: Move pollfd " Jiri Olsa
2019-09-13 13:23 ` [PATCH 23/73] libperf: Move sample_id from struct evsel to struct perf_evsel Jiri Olsa
2019-09-13 13:23 ` [PATCH 24/73] libperf: Move id " Jiri Olsa
2019-09-13 13:23 ` [PATCH 25/73] libperf: Move ids " Jiri Olsa
2019-09-13 13:23 ` [PATCH 26/73] libperf: Move heads from struct evlist to struct perf_evlist Jiri Olsa
2019-09-13 13:23 ` [PATCH 27/73] libperf: Add perf_evsel__alloc_id/perf_evsel__free_id functions Jiri Olsa
2019-09-13 13:23 ` [PATCH 28/73] libperf: Add perf_evlist__first/last functions Jiri Olsa
2019-09-13 13:23 ` [PATCH 29/73] libperf: Add perf_evlist__read_format function Jiri Olsa
2019-09-13 13:23 ` [PATCH 30/73] libperf: Add perf_evlist__id_add function Jiri Olsa
2019-09-13 13:23 ` [PATCH 31/73] libperf: Add perf_evlist__id_add_fd function Jiri Olsa
2019-09-13 13:23 ` [PATCH 32/73] libperf: Move page_size into libperf Jiri Olsa
2019-09-23 19:10   ` Arnaldo Carvalho de Melo
2019-09-23 19:17     ` Jiri Olsa
2019-09-13 13:23 ` [PATCH 33/73] libperf: Merge libperf_set_print in libperf_init Jiri Olsa
2019-09-13 13:23 ` [PATCH 34/73] libperf: Add libperf_init call to tests Jiri Olsa
2019-09-13 13:23 ` [PATCH 35/73] libperf: Add libperf dependency for tests targets Jiri Olsa
2019-09-13 13:23 ` [PATCH 36/73] libperf: Add perf_evlist__alloc_pollfd function Jiri Olsa
2019-09-13 13:23 ` [PATCH 37/73] libperf: Add perf_evlist__add_pollfd function Jiri Olsa
2019-09-13 13:23 ` [PATCH 38/73] libperf: Add perf_evlist__poll function Jiri Olsa
2019-09-13 13:23 ` [PATCH 39/73] libperf: Add perf_mmap__init function Jiri Olsa
2019-09-13 13:23 ` [PATCH 40/73] libperf: Add struct perf_mmap_param Jiri Olsa
2019-09-13 13:23 ` [PATCH 41/73] libperf: Add perf_mmap__mmap_len function Jiri Olsa
2019-09-13 13:23 ` [PATCH 42/73] libperf: Add perf_mmap__mmap function Jiri Olsa
2019-09-13 13:23 ` [PATCH 43/73] libperf: Add perf_mmap__get function Jiri Olsa
2019-09-13 13:23 ` [PATCH 44/73] libperf: Add perf_mmap__unmap function Jiri Olsa
2019-09-13 13:23 ` [PATCH 45/73] libperf: Add perf_mmap__put function Jiri Olsa
2019-09-13 13:23 ` [PATCH 46/73] libperf: Add perf_mmap__new function Jiri Olsa
2019-09-13 13:23 ` [PATCH 47/73] perf tools: Use perf_mmap way to detect aux mmap Jiri Olsa
2019-09-13 13:23 ` [PATCH 48/73] libperf: Add perf_mmap__consume function Jiri Olsa
2019-09-13 13:23 ` [PATCH 49/73] libperf: Add perf_mmap__read_init function Jiri Olsa
2019-09-13 13:23 ` [PATCH 50/73] libperf: Add perf_mmap__read_done function Jiri Olsa
2019-09-13 13:23 ` [PATCH 51/73] libperf: Add perf_mmap__read_event function Jiri Olsa
2019-09-13 13:23 ` [PATCH 52/73] libperf: Add perf_evlist__mmap/munmap function Jiri Olsa
2019-09-13 13:23 ` [PATCH 53/73] libperf: Add perf_evlist__mmap_ops function Jiri Olsa
2019-09-13 13:23 ` [PATCH 54/73] libperf: Add perf_evlist_mmap_ops::idx callback Jiri Olsa
2019-09-13 13:23 ` [PATCH 55/73] libperf: Add perf_evlist_mmap_ops::new callback Jiri Olsa
2019-09-13 13:23 ` [PATCH 56/73] libperf: Add perf_evlist_mmap_ops::mmap callback Jiri Olsa
2019-09-13 13:23 ` [PATCH 57/73] perf tools: Add perf_evlist__mmap_cb_idx function Jiri Olsa
2019-09-13 13:23 ` [PATCH 58/73] perf tools: Add perf_evlist__mmap_cb_new function Jiri Olsa
2019-09-13 13:23 ` [PATCH 59/73] perf tools: Add perf_evlist__mmap_cb_mmap function Jiri Olsa
2019-09-13 13:23 ` [PATCH 60/73] perf tools: Switch to libperf mmap interface Jiri Olsa
2019-09-13 13:23 ` [PATCH 61/73] libperf: Move pollfd allocation to libperf Jiri Olsa
2019-09-13 13:23 ` [PATCH 62/73] libperf: Add perf_evlist__exit function Jiri Olsa
2019-09-13 13:23 ` [PATCH 63/73] libperf: Add perf_evlist__purge function Jiri Olsa
2019-09-13 13:23 ` [PATCH 64/73] libperf: Call perf_evlist__munmap/close on perf_evlist__delete Jiri Olsa
2019-09-13 13:23 ` [PATCH 65/73] libperf: Add perf_evlist__filter_pollfd function Jiri Olsa
2019-09-13 13:23 ` [PATCH 66/73] libperf: Add perf_evlist__for_each_mmap function Jiri Olsa
2019-09-13 13:23 ` [PATCH 67/73] libperf: Link static tests with libapi.a Jiri Olsa
2019-09-13 13:23 ` [PATCH 68/73] libperf: Add _GNU_SOURCE define to compilation Jiri Olsa
2019-09-13 13:23 ` [PATCH 69/73] libperf: Add tests_mmap_thread test Jiri Olsa
2019-09-13 13:23 ` [PATCH 70/73] libperf: Add tests_mmap_cpus test Jiri Olsa
2019-09-13 13:23 ` [PATCH 71/73] libperf: Keep count of failed tests Jiri Olsa
2019-09-13 13:23 ` [PATCH 72/73] libperf: Do not export perf_evsel__init/perf_evlist__init Jiri Olsa
2019-09-13 13:23 ` [PATCH 73/73] libperf: Add pr_err macro Jiri Olsa
2019-09-22 14:47 ` [RFC 00/73] libperf: Add sampling interface Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).