lkml.org 
[lkml]   [2019]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC 00/73] libperf: Add sampling interface
    On Fri, Sep 13, 2019 at 03:22:42PM +0200, Jiri Olsa wrote:
    > 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

    hi,
    I rebased the branch to latest Arnaldo's perf/core branch

    jirka

    \
     
     \ /
      Last update: 2019-09-22 16:47    [W:6.053 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site