perf evlist: Adopt backwards ring buffer state enum

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 <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Link: https://lkml.kernel.org/n/tip-he0uljeftl0xfveh3d6vtode@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-09-23 12:20:38 -03:00
parent d80a5540bc
commit e0fcfb086f
26 changed files with 53 additions and 29 deletions

View File

@ -1,4 +1,5 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/bitops.h> #include <linux/bitops.h>

View File

@ -17,6 +17,7 @@
#include "thread_map.h" #include "thread_map.h"
#include "record.h" #include "record.h"
#include "tsc.h" #include "tsc.h"
#include "util/mmap.h"
#include "tests/tests.h" #include "tests/tests.h"
#include "arch-tests.h" #include "arch-tests.h"

View File

@ -15,6 +15,7 @@
#include "../../util/event.h" #include "../../util/event.h"
#include "../../util/evsel.h" #include "../../util/evsel.h"
#include "../../util/evlist.h" #include "../../util/evlist.h"
#include "../../util/mmap.h"
#include "../../util/session.h" #include "../../util/session.h"
#include "../../util/pmu.h" #include "../../util/pmu.h"
#include "../../util/debug.h" #include "../../util/debug.h"

View File

@ -18,6 +18,7 @@
#include "../../util/evlist.h" #include "../../util/evlist.h"
#include "../../util/evsel.h" #include "../../util/evsel.h"
#include "../../util/cpumap.h" #include "../../util/cpumap.h"
#include "../../util/mmap.h"
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "../../util/parse-events.h" #include "../../util/parse-events.h"
#include "../../util/pmu.h" #include "../../util/pmu.h"

View File

@ -5,6 +5,7 @@
#include "util/build-id.h" #include "util/build-id.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/evlist.h" #include "util/evlist.h"
#include "util/mmap.h"
#include "util/term.h" #include "util/term.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/thread.h" #include "util/thread.h"

View File

@ -20,6 +20,7 @@
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/mmap.h"
#include "util/target.h" #include "util/target.h"
#include "util/session.h" #include "util/session.h"
#include "util/tool.h" #include "util/tool.h"

View File

@ -30,6 +30,7 @@
#include "util/event.h" #include "util/event.h"
#include "util/machine.h" #include "util/machine.h"
#include "util/map.h" #include "util/map.h"
#include "util/mmap.h"
#include "util/session.h" #include "util/session.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/synthetic-events.h" #include "util/synthetic-events.h"

View File

@ -31,6 +31,7 @@
#include "util/synthetic-events.h" #include "util/synthetic-events.h"
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evswitch.h" #include "util/evswitch.h"
#include "util/mmap.h"
#include <subcmd/pager.h> #include <subcmd/pager.h>
#include <subcmd/exec-cmd.h> #include <subcmd/exec-cmd.h>
#include "util/machine.h" #include "util/machine.h"

View File

@ -10,6 +10,7 @@
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include "parse-events.h" #include "parse-events.h"
#include "util/mmap.h"
#include <errno.h> #include <errno.h>
#include <linux/string.h> #include <linux/string.h>

View File

@ -19,6 +19,7 @@
#include "llvm.h" #include "llvm.h"
#include "debug.h" #include "debug.h"
#include "parse-events.h" #include "parse-events.h"
#include "util/mmap.h"
#define NR_ITERS 111 #define NR_ITERS 111
#define PERF_TEST_BPF_PATH "/sys/fs/bpf/perf_test" #define PERF_TEST_BPF_PATH "/sys/fs/bpf/perf_test"

View File

@ -24,6 +24,7 @@
#include "symbol.h" #include "symbol.h"
#include "event.h" #include "event.h"
#include "record.h" #include "record.h"
#include "util/mmap.h"
#include "util/synthetic-events.h" #include "util/synthetic-events.h"
#include "thread.h" #include "thread.h"

View File

@ -8,6 +8,7 @@
#include "machine.h" #include "machine.h"
#include "parse-events.h" #include "parse-events.h"
#include "hists_common.h" #include "hists_common.h"
#include "util/mmap.h"
#include <errno.h> #include <errno.h>
#include <linux/kernel.h> #include <linux/kernel.h>

View File

@ -13,6 +13,7 @@
#include "record.h" #include "record.h"
#include "thread_map.h" #include "thread_map.h"
#include "tests.h" #include "tests.h"
#include "util/mmap.h"
#define CHECK__(x) { \ #define CHECK__(x) { \
while ((x) < 0) { \ while ((x) < 0) { \

View File

@ -11,6 +11,7 @@
#include "evsel.h" #include "evsel.h"
#include "thread_map.h" #include "thread_map.h"
#include "tests.h" #include "tests.h"
#include "util/mmap.h"
#include <linux/err.h> #include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>

View File

@ -11,6 +11,7 @@
#include "record.h" #include "record.h"
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
#include "util/mmap.h"
#include <errno.h> #include <errno.h>
#ifndef O_DIRECTORY #ifndef O_DIRECTORY

View File

@ -11,6 +11,7 @@
#include "debug.h" #include "debug.h"
#include "record.h" #include "record.h"
#include "tests.h" #include "tests.h"
#include "util/mmap.h"
static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp) static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp)
{ {

View File

@ -12,6 +12,7 @@
#include "util/evsel.h" #include "util/evsel.h"
#include "util/evlist.h" #include "util/evlist.h"
#include "util/cpumap.h" #include "util/cpumap.h"
#include "util/mmap.h"
#include "util/thread_map.h" #include "util/thread_map.h"
#include <perf/evlist.h> #include <perf/evlist.h>

View File

@ -16,6 +16,7 @@
#include "thread_map.h" #include "thread_map.h"
#include "record.h" #include "record.h"
#include "tests.h" #include "tests.h"
#include "util/mmap.h"
static int spin_sleep(void) static int spin_sleep(void)
{ {

View File

@ -5,6 +5,7 @@
#include "target.h" #include "target.h"
#include "thread_map.h" #include "thread_map.h"
#include "tests.h" #include "tests.h"
#include "util/mmap.h"
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>

View File

@ -8,6 +8,7 @@
#include "../string2.h" #include "../string2.h"
#include "gtk.h" #include "gtk.h"
#include <signal.h> #include <signal.h>
#include <stdlib.h>
#include <linux/string.h> #include <linux/string.h>
#define MAX_COLUMNS 32 #define MAX_COLUMNS 32

View File

@ -34,6 +34,7 @@
#include "bpf-event.h" #include "bpf-event.h"
#include "block-range.h" #include "block-range.h"
#include "string2.h" #include "string2.h"
#include "util/mmap.h"
#include "arch/common.h" #include "arch/common.h"
#include <regex.h> #include <regex.h>
#include <pthread.h> #include <pthread.h>

View File

@ -51,6 +51,7 @@
#include "arm-spe.h" #include "arm-spe.h"
#include "s390-cpumsf.h" #include "s390-cpumsf.h"
#include "util.h" // page_size #include "util.h" // page_size
#include "util/mmap.h"
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/kernel.h> #include <linux/kernel.h>

View File

@ -10,6 +10,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <poll.h> #include <poll.h>
#include "cpumap.h" #include "cpumap.h"
#include "util/mmap.h"
#include "thread_map.h" #include "thread_map.h"
#include "target.h" #include "target.h"
#include "evlist.h" #include "evlist.h"

View File

@ -11,7 +11,7 @@
#include <internal/evlist.h> #include <internal/evlist.h>
#include "events_stats.h" #include "events_stats.h"
#include "evsel.h" #include "evsel.h"
#include "mmap.h" #include <pthread.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
@ -20,6 +20,34 @@ struct thread_map;
struct perf_cpu_map; struct perf_cpu_map;
struct record_opts; 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_BITS 8
#define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS) #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)

View File

@ -45,34 +45,6 @@ struct mmap {
int comp_level; 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 { struct mmap_params {
int prot, mask, nr_cblocks, affinity, flush, comp_level; int prot, mask, nr_cblocks, affinity, flush, comp_level;
struct auxtrace_mmap_params auxtrace_mp; struct auxtrace_mmap_params auxtrace_mp;

View File

@ -34,6 +34,7 @@
#include "asm/bug.h" #include "asm/bug.h"
#include "util/parse-branch-options.h" #include "util/parse-branch-options.h"
#include "metricgroup.h" #include "metricgroup.h"
#include "util/mmap.h"
#define MAX_NAME_LEN 100 #define MAX_NAME_LEN 100