Skip to content

Commit

Permalink
perf tools: Move everything related to sys_perf_event_open() to perf-…
Browse files Browse the repository at this point in the history
…sys.h

And remove unneeded include directives from perf-sys.h to prune the
header dependency tree.

Fixup the fallout in places where definitions were being used without
the needed include directives that were being satisfied because they
were in perf-sys.h.

Cc: Adrian Hunter <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Aug 29, 2019
1 parent a774940 commit 91854f9
Show file tree
Hide file tree
Showing 23 changed files with 34 additions and 23 deletions.
1 change: 1 addition & 0 deletions tools/perf/arch/common.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "common.h"
#include "../util/env.h"
#include "../util/debug.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/tests/rdpmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <linux/types.h>
#include "perf.h"
#include "perf-sys.h"
#include "debug.h"
#include "tests/tests.h"
#include "cloexec.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/x86/util/perf_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <regex.h>
#include <linux/zalloc.h>

#include "../../perf.h"
#include "../../perf-sys.h"
#include "../../util/perf_regs.h"
#include "../../util/debug.h"

Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/x86/util/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "../../../perf.h"
#include <linux/types.h>
#include <asm/barrier.h>
#include "../../../util/debug.h"
#include "../../../util/tsc.h"

Expand Down
1 change: 1 addition & 0 deletions tools/perf/bench/epoll-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <inttypes.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <sys/time.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/bench/epoll-wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
/* For the CLR_() macros */
#include <string.h>
#include <pthread.h>
#include <unistd.h>

#include <errno.h>
#include <inttypes.h>
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/bench/mem-functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

#include "debug.h"
#include "../perf.h"
#include "../perf-sys.h"
#include <subcmd/parse-options.h>
#include "../util/header.h"
#include "../util/cloexec.h"
Expand All @@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#include <linux/time64.h>
Expand Down
1 change: 1 addition & 0 deletions tools/perf/builtin-sched.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "builtin.h"
#include "perf.h"
#include "perf-sys.h"

#include "util/evlist.h"
#include "util/cache.h"
Expand Down
13 changes: 10 additions & 3 deletions tools/perf/perf-sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/perf_event.h>
#include <asm/barrier.h>

struct perf_event_attr;

extern bool test_attr__enabled;
void test_attr__ready(void);
void test_attr__init(void);
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
int fd, int group_fd, unsigned long flags);

#define HAVE_ATTR_TEST

static inline int
sys_perf_event_open(struct perf_event_attr *attr,
Expand Down
1 change: 1 addition & 0 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "util/debug.h"
#include "util/event.h"
#include "util/util.h"
#include "perf-sys.h"
#include <api/fs/fs.h>
#include <api/fs/tracing_path.h>
#include <errno.h>
Expand Down
12 changes: 0 additions & 12 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

#include <time.h>
#include <stdbool.h>
#include <linux/types.h>
#include <linux/stddef.h>
#include <linux/perf_event.h>

extern bool test_attr__enabled;
void test_attr__ready(void);
void test_attr__init(void);
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
int fd, int group_fd, unsigned long flags);

#define HAVE_ATTR_TEST
#include "perf-sys.h"

static inline unsigned long long rdclock(void)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../perf.h"
#include "../perf-sys.h"
#include <subcmd/exec-cmd.h>
#include "tests.h"

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/bp_account.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "tests.h"
#include "debug.h"
#include "perf.h"
#include "../perf-sys.h"
#include "cloexec.h"

volatile long the_var;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/bp_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "tests.h"
#include "debug.h"
#include "perf.h"
#include "perf-sys.h"
#include "cloexec.h"

static int fd1;
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/bp_signal_overflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "tests.h"
#include "debug.h"
#include "perf.h"
#include "../perf-sys.h"
#include "cloexec.h"

static int overflows;
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/tests/wp.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/hw_breakpoint.h>
#include "tests.h"
#include "debug.h"
#include "cloexec.h"
#include "../perf-sys.h"

#define WP_TEST_ASSERT_VAL(fd, text, val) \
do { \
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/auxtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/perf_event.h>
#include <linux/types.h>
#include <asm/bitsperlong.h>
#include <asm/barrier.h>

#include "../perf.h"
#include "event.h"
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/cloexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <errno.h>
#include <sched.h>
#include "util.h"
#include "../perf.h"
#include "../perf-sys.h"
#include "cloexec.h"
#include "asm/bug.h"
#include "debug.h"
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "string2.h"
#include "memswap.h"
#include "util.h"
#include "../perf-sys.h"
#include "util/parse-branch-options.h"
#include <internal/xyarray.h>

Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/genelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <libelf.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <limits.h>
#include <fcntl.h>
Expand All @@ -25,6 +26,7 @@
#include "perf.h"
#include "genelf.h"
#include "../util/jitdump.h"
#include <linux/compiler.h>

#ifndef NT_GNU_BUILD_ID
#define NT_GNU_BUILD_ID 3
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "thread_map.h"
#include "mmap.h"
#include "util.h"
#include "../perf-sys.h"

#if PY_MAJOR_VERSION < 3
#define _PyUnicode_FromString(arg) \
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "util.h"
#include "cloexec.h"
#include "record.h"
#include "../perf-sys.h"

typedef void (*setup_probe_fn_t)(struct evsel *evsel);

Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/zalloc.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>

/*
* Used as the default ->buf value, so that people can always assume
Expand Down

0 comments on commit 91854f9

Please sign in to comment.