Skip to content

Commit

Permalink
perf evlist: Adopt backwards ring buffer state enum
Browse files Browse the repository at this point in the history
As this isn't used at all in mmap.h but in evlist.h, so to cut down the
header dependency tree, move it to where it is used.

Also add mmap.h to the places using it but previously getting it
indirectly via evlist.h.

Add missing pthread.h to evlist.h, as it has a pthread_t struct member
and was getting the header via mmap.h.

Noticed while processing a Jiri's libperf batch touching mmap.h, where
almost everything gets rebuilt because evlist.h is so popular, so cut
down't this rebuild the world party.

Cc: Adrian Hunter <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Song Liu <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Sep 25, 2019
1 parent d80a554 commit e0fcfb0
Show file tree
Hide file tree
Showing 26 changed files with 53 additions and 29 deletions.
1 change: 1 addition & 0 deletions tools/perf/arch/s390/util/auxtrace.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdbool.h>
#include <stdlib.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/bitops.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/x86/tests/perf-time-to-tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "thread_map.h"
#include "record.h"
#include "tsc.h"
#include "util/mmap.h"
#include "tests/tests.h"

#include "arch-tests.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/x86/util/intel-bts.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "../../util/event.h"
#include "../../util/evsel.h"
#include "../../util/evlist.h"
#include "../../util/mmap.h"
#include "../../util/session.h"
#include "../../util/pmu.h"
#include "../../util/debug.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/x86/util/intel-pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "../../util/evlist.h"
#include "../../util/evsel.h"
#include "../../util/cpumap.h"
#include "../../util/mmap.h"
#include <subcmd/parse-options.h>
#include "../../util/parse-events.h"
#include "../../util/pmu.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "util/build-id.h"
#include "util/evsel.h"
#include "util/evlist.h"
#include "util/mmap.h"
#include "util/term.h"
#include "util/symbol.h"
#include "util/thread.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "util/evlist.h"
#include "util/evsel.h"
#include "util/debug.h"
#include "util/mmap.h"
#include "util/target.h"
#include "util/session.h"
#include "util/tool.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "util/event.h"
#include "util/machine.h"
#include "util/map.h"
#include "util/mmap.h"
#include "util/session.h"
#include "util/symbol.h"
#include "util/synthetic-events.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "util/synthetic-events.h"
#include "util/evlist.h"
#include "util/evswitch.h"
#include "util/mmap.h"
#include <subcmd/pager.h>
#include <subcmd/exec-cmd.h>
#include "util/machine.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/backward-ring-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "tests.h"
#include "debug.h"
#include "parse-events.h"
#include "util/mmap.h"
#include <errno.h>
#include <linux/string.h>

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm.h"
#include "debug.h"
#include "parse-events.h"
#include "util/mmap.h"
#define NR_ITERS 111
#define PERF_TEST_BPF_PATH "/sys/fs/bpf/perf_test"

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/code-reading.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "symbol.h"
#include "event.h"
#include "record.h"
#include "util/mmap.h"
#include "util/synthetic-events.h"
#include "thread.h"

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/hists_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "machine.h"
#include "parse-events.h"
#include "hists_common.h"
#include "util/mmap.h"
#include <errno.h>
#include <linux/kernel.h>

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/keep-tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "record.h"
#include "thread_map.h"
#include "tests.h"
#include "util/mmap.h"

#define CHECK__(x) { \
while ((x) < 0) { \
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/mmap-basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "evsel.h"
#include "thread_map.h"
#include "tests.h"
#include "util/mmap.h"
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/string.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/openat-syscall-tp-fields.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "record.h"
#include "tests.h"
#include "debug.h"
#include "util/mmap.h"
#include <errno.h>

#ifndef O_DIRECTORY
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/perf-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "debug.h"
#include "record.h"
#include "tests.h"
#include "util/mmap.h"

static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp)
{
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/sw-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "util/evsel.h"
#include "util/evlist.h"
#include "util/cpumap.h"
#include "util/mmap.h"
#include "util/thread_map.h"
#include <perf/evlist.h>

Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/switch-tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "thread_map.h"
#include "record.h"
#include "tests.h"
#include "util/mmap.h"

static int spin_sleep(void)
{
Expand Down
1 change: 1 addition & 0 deletions tools/perf/tests/task-exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "target.h"
#include "thread_map.h"
#include "tests.h"
#include "util/mmap.h"

#include <errno.h>
#include <signal.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/ui/gtk/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../string2.h"
#include "gtk.h"
#include <signal.h>
#include <stdlib.h>
#include <linux/string.h>

#define MAX_COLUMNS 32
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "bpf-event.h"
#include "block-range.h"
#include "string2.h"
#include "util/mmap.h"
#include "arch/common.h"
#include <regex.h>
#include <pthread.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/auxtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "arm-spe.h"
#include "s390-cpumsf.h"
#include "util.h" // page_size
#include "util/mmap.h"

#include <linux/ctype.h>
#include <linux/kernel.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <inttypes.h>
#include <poll.h>
#include "cpumap.h"
#include "util/mmap.h"
#include "thread_map.h"
#include "target.h"
#include "evlist.h"
Expand Down
30 changes: 29 additions & 1 deletion tools/perf/util/evlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <internal/evlist.h>
#include "events_stats.h"
#include "evsel.h"
#include "mmap.h"
#include <pthread.h>
#include <signal.h>
#include <unistd.h>

Expand All @@ -20,6 +20,34 @@ struct thread_map;
struct perf_cpu_map;
struct record_opts;

/*
* State machine of bkw_mmap_state:
*
* .________________(forbid)_____________.
* | V
* NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
* ^ ^ | ^ |
* | |__(forbid)____/ |___(forbid)___/|
* | |
* \_________________(3)_______________/
*
* NOTREADY : Backward ring buffers are not ready
* RUNNING : Backward ring buffers are recording
* DATA_PENDING : We are required to collect data from backward ring buffers
* EMPTY : We have collected data from backward ring buffers.
*
* (0): Setup backward ring buffer
* (1): Pause ring buffers for reading
* (2): Read from ring buffers
* (3): Resume ring buffers for recording
*/
enum bkw_mmap_state {
BKW_MMAP_NOTREADY,
BKW_MMAP_RUNNING,
BKW_MMAP_DATA_PENDING,
BKW_MMAP_EMPTY,
};

#define PERF_EVLIST__HLIST_BITS 8
#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)

Expand Down
28 changes: 0 additions & 28 deletions tools/perf/util/mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,6 @@ struct mmap {
int comp_level;
};

/*
* State machine of bkw_mmap_state:
*
* .________________(forbid)_____________.
* | V
* NOTREADY --(0)--> RUNNING --(1)--> DATA_PENDING --(2)--> EMPTY
* ^ ^ | ^ |
* | |__(forbid)____/ |___(forbid)___/|
* | |
* \_________________(3)_______________/
*
* NOTREADY : Backward ring buffers are not ready
* RUNNING : Backward ring buffers are recording
* DATA_PENDING : We are required to collect data from backward ring buffers
* EMPTY : We have collected data from backward ring buffers.
*
* (0): Setup backward ring buffer
* (1): Pause ring buffers for reading
* (2): Read from ring buffers
* (3): Resume ring buffers for recording
*/
enum bkw_mmap_state {
BKW_MMAP_NOTREADY,
BKW_MMAP_RUNNING,
BKW_MMAP_DATA_PENDING,
BKW_MMAP_EMPTY,
};

struct mmap_params {
int prot, mask, nr_cblocks, affinity, flush, comp_level;
struct auxtrace_mmap_params auxtrace_mp;
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "asm/bug.h"
#include "util/parse-branch-options.h"
#include "metricgroup.h"
#include "util/mmap.h"

#define MAX_NAME_LEN 100

Expand Down

0 comments on commit e0fcfb0

Please sign in to comment.