Skip to contentSkip to conversation

perf tools: remove .. in perf includes/

PATCH In review Andi Kleen 3 participants 4 messages Jan 20, 2012 – Jan 30, 2012 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf tools: remove .. in perf includes/

From: Andi Kleen <[email protected]>

The perf user space has a lot of includes with ugly .. chains. This also makes it impossible to include any perf files from other code.

I think the original reason for this were some wrapper include files for the kernel includes, and the explicit paths were needed to avoid endless recursion. A better way to handle this is #include_next

- Add all the relevant directories as -I in the Makefile
- Remove (near) all the .. in include statements
- Remove unnecessary wrappers that do nothing
- Fix up some fallout

This makes the code more pleasant to read.

I did it all in one big patch to keep bisectability.

---
 tools/perf/Makefile                                |   10 +++-------
 tools/perf/arch/powerpc/util/header.c              |    2 +-
 tools/perf/arch/x86/util/header.c                  |    2 +-
 tools/perf/bench/bench.h                           |    2 ++
 tools/perf/bench/mem-memcpy-x86-64-asm.S           |    2 +-
 tools/perf/bench/mem-memcpy.c                      |    8 ++++----
 tools/perf/bench/sched-messaging.c                 |    8 ++++----
 tools/perf/bench/sched-pipe.c                      |    8 ++++----
 tools/perf/builtin-help.c                          |    1 +
 tools/perf/builtin-list.c                          |    1 +
 tools/perf/perf.h                                  |   17 ++++-------------
 tools/perf/scripts/perl/Perf-Trace-Util/Context.c  |    4 ++--
 tools/perf/scripts/perl/Perf-Trace-Util/Context.xs |    4 ++--
 .../perf/scripts/python/Perf-Trace-Util/Context.c  |    4 ++--
 tools/perf/util/alias.c                            |    1 +
 tools/perf/util/include/linux/const.h              |    1 -
 tools/perf/util/include/linux/poison.h             |    1 -
 tools/perf/util/include/linux/rbtree.h             |    1 -
 tools/perf/util/thread.c                           |    2 +-
 tools/perf/util/wrapper.c                          |    1 +
 20 files changed, 35 insertions(+), 45 deletions(-)
 delete mode 100644 tools/perf/util/include/linux/const.h
 delete mode 100644 tools/perf/util/include/linux/poison.h
 delete mode 100644 tools/perf/util/include/linux/rbtree.h
tools/perf/Makefile +3 -7
index ac86d67..941159c 100644
@@ -171,8 +171,9 @@ endif
 # Those must not be GNU-specific; they are shared with perl/ which may
 # be built by a different compiler. (Note that this is an artifact now
 # but it still might be nice to keep that distinction.)
-BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
-BASIC_LDFLAGS =
+BASIC_CFLAGS = -Iutil -Iutil/include -Iarch/$(ARCH)/include \
+               -Iinclude -I ../../include -I. -Iutil/ui
+BASIC_LDFLAGS = 
 
 # Guard against environment variables
 BUILTIN_OBJS =
@@ -223,22 +224,17 @@ export PERL_PATH
 LIB_FILE=$(OUTPUT)libperf.a
 
 LIB_H += ../../include/linux/perf_event.h
-LIB_H += ../../include/linux/rbtree.h
 LIB_H += ../../include/linux/list.h
-LIB_H += ../../include/linux/const.h
 LIB_H += ../../include/linux/hash.h
 LIB_H += ../../include/linux/stringify.h
 LIB_H += util/include/linux/bitmap.h
 LIB_H += util/include/linux/bitops.h
 LIB_H += util/include/linux/compiler.h
-LIB_H += util/include/linux/const.h
 LIB_H += util/include/linux/ctype.h
 LIB_H += util/include/linux/kernel.h
 LIB_H += util/include/linux/list.h
 LIB_H += util/include/linux/module.h
-LIB_H += util/include/linux/poison.h
 LIB_H += util/include/linux/prefetch.h
-LIB_H += util/include/linux/rbtree.h
 LIB_H += util/include/linux/string.h
 LIB_H += util/include/linux/types.h
 LIB_H += util/include/linux/linkage.h
tools/perf/arch/powerpc/util/header.c +1 -1
index eba80c2..f4b6e00 100644
@@ -4,7 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../../util/header.h"
+#include "util/header.h"
 
 #define __stringify_1(x)        #x
 #define __stringify(x)          __stringify_1(x)
tools/perf/arch/x86/util/header.c +1 -1
index f940060..c7d221d 100644
@@ -4,7 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../../util/header.h"
+#include "util/header.h"
 
 static inline void
 cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
tools/perf/bench/bench.h +2 -0
index f7781c6..0c7ee07 100644
@@ -1,6 +1,8 @@
 #ifndef BENCH_H
 #define BENCH_H
 
+#include <linux/compiler.h>
+
 extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
 extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
 extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
tools/perf/bench/mem-memcpy-x86-64-asm.S +1 -1
index a57b66e..1e55988 100644
@@ -1,2 +1,2 @@
 
-#include "../../../arch/x86/lib/memcpy_64.S"
+#include "../../arch/x86/lib/memcpy_64.S"
tools/perf/bench/mem-memcpy.c +4 -4
index db82021..da2e2e7 100644
@@ -7,10 +7,10 @@
  */
 #include <ctype.h>
 
-#include "../perf.h"
-#include "../util/util.h"
-#include "../util/parse-options.h"
-#include "../util/header.h"
+#include "perf.h"
+#include "util/util.h"
+#include "util/parse-options.h"
+#include "util/header.h"
 #include "bench.h"
 #include "mem-memcpy-arch.h"
 
tools/perf/bench/sched-messaging.c +4 -4
index d1d1b30..50fdef3 100644
@@ -9,10 +9,10 @@
  *
  */
 
-#include "../perf.h"
-#include "../util/util.h"
-#include "../util/parse-options.h"
-#include "../builtin.h"
+#include "perf.h"
+#include "util/util.h"
+#include "util/parse-options.h"
+#include "builtin.h"
 #include "bench.h"
 
 /* Test groups of 20 processes spraying to 20 receivers */
tools/perf/bench/sched-pipe.c +4 -4
index 0c7454f..036a79a 100644
@@ -10,10 +10,10 @@
  *
  */
 
-#include "../perf.h"
-#include "../util/util.h"
-#include "../util/parse-options.h"
-#include "../builtin.h"
+#include "perf.h"
+#include "util/util.h"
+#include "util/parse-options.h"
+#include "builtin.h"
 #include "bench.h"
 
 #include <unistd.h>
tools/perf/builtin-help.c +1 -0
index 6d5a8a7..7d2cff6 100644
@@ -3,6 +3,7 @@
  *
  * Builtin help command
  */
+#include <linux/compiler.h>
 #include "perf.h"
 #include "util/cache.h"
 #include "builtin.h"
tools/perf/builtin-list.c +1 -0
index 6313b6e..c6ae88a 100644
@@ -7,6 +7,7 @@
  * Copyright (C) 2008-2009, Red Hat Inc, Ingo Molnar <[email protected]>
  * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]>
  */
+#include <linux/compiler.h>
 #include "builtin.h"
 
 #include "perf.h"
tools/perf/perf.h +4 -13
index 64f8bee..95720f4 100644
@@ -5,35 +5,32 @@ struct winsize;
 
 void get_term_dimensions(struct winsize *ws);
 
+#include "asm/unistd.h"
+
 #if defined(__i386__)
-#include "../../arch/x86/include/asm/unistd.h"
 #define rmb()		asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 #define CPUINFO_PROC	"model name"
 #endif
 
 #if defined(__x86_64__)
-#include "../../arch/x86/include/asm/unistd.h"
 #define rmb()		asm volatile("lfence" ::: "memory")
 #define cpu_relax()	asm volatile("rep; nop" ::: "memory");
 #define CPUINFO_PROC	"model name"
 #endif
 
 #ifdef __powerpc__
-#include "../../arch/powerpc/include/asm/unistd.h"
 #define rmb()		asm volatile ("sync" ::: "memory")
 #define cpu_relax()	asm volatile ("" ::: "memory");
 #define CPUINFO_PROC	"cpu"
 #endif
 
 #ifdef __s390__
-#include "../../arch/s390/include/asm/unistd.h"
 #define rmb()		asm volatile("bcr 15,0" ::: "memory")
 #define cpu_relax()	asm volatile("" ::: "memory");
 #endif
 
 #ifdef __sh__
-#include "../../arch/sh/include/asm/unistd.h"
 #if defined(__SH4A__) || defined(__SH5__)
 # define rmb()		asm volatile("synco" ::: "memory")
 #else
@@ -44,35 +41,30 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #ifdef __hppa__
-#include "../../arch/parisc/include/asm/unistd.h"
 #define rmb()		asm volatile("" ::: "memory")
 #define cpu_relax()	asm volatile("" ::: "memory");
 #define CPUINFO_PROC	"cpu"
 #endif
 
 #ifdef __sparc__
-#include "../../arch/sparc/include/asm/unistd.h"
 #define rmb()		asm volatile("":::"memory")
 #define cpu_relax()	asm volatile("":::"memory")
 #define CPUINFO_PROC	"cpu"
 #endif
 
 #ifdef __alpha__
-#include "../../arch/alpha/include/asm/unistd.h"
 #define rmb()		asm volatile("mb" ::: "memory")
 #define cpu_relax()	asm volatile("" ::: "memory")
 #define CPUINFO_PROC	"cpu model"
 #endif
 
 #ifdef __ia64__
-#include "../../arch/ia64/include/asm/unistd.h"
 #define rmb()		asm volatile ("mf" ::: "memory")
 #define cpu_relax()	asm volatile ("hint @pause" ::: "memory")
 #define CPUINFO_PROC	"model name"
 #endif
 
 #ifdef __arm__
-#include "../../arch/arm/include/asm/unistd.h"
 /*
  * Use the __kuser_memory_barrier helper in the CPU helper page. See
  * arch/arm/kernel/entry-armv.S in the kernel source for details.
@@ -83,7 +75,6 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #ifdef __mips__
-#include "../../arch/mips/include/asm/unistd.h"
 #define rmb()		asm volatile(					\
 				".set	mips2\n\t"			\
 				"sync\n\t"				\
@@ -100,8 +91,8 @@ void get_term_dimensions(struct winsize *ws);
 #include <sys/types.h>
 #include <sys/syscall.h>
 
-#include "../../include/linux/perf_event.h"
-#include "util/types.h"
+#include "linux/perf_event.h"
+#include "types.h"
 #include <stdbool.h>
 
 struct perf_mmap {
tools/perf/scripts/perl/Perf-Trace-Util/Context.c +2 -2
index 790ceba..260bcac 100644
@@ -31,8 +31,8 @@
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
-#include "../../../perf.h"
-#include "../../../util/trace-event.h"
+#include "perf.h"
+#include "util/trace-event.h"
 
 #ifndef PERL_UNUSED_VAR
 #  define PERL_UNUSED_VAR(var) if (0) var = var
tools/perf/scripts/perl/Perf-Trace-Util/Context.xs +2 -2
index c1e2ed1..846ed5a 100644
@@ -22,8 +22,8 @@
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
-#include "../../../perf.h"
-#include "../../../util/script-event.h"
+#include "perf.h"
+#include "script-event.h"
 
 MODULE = Perf::Trace::Context		PACKAGE = Perf::Trace::Context
 PROTOTYPES: ENABLE
tools/perf/scripts/python/Perf-Trace-Util/Context.c +2 -2
index 315067b..573c179 100644
@@ -20,8 +20,8 @@
  */
 
 #include <Python.h>
-#include "../../../perf.h"
-#include "../../../util/trace-event.h"
+#include "perf.h"
+#include "util/trace-event.h"
 
 PyMODINIT_FUNC initperf_trace_context(void);
 
tools/perf/util/alias.c +1 -0
index b8144e8..2dc6cce 100644
@@ -1,3 +1,4 @@
+#include <linux/compiler.h>
 #include "cache.h"
 
 static const char *alias_key;
tools/perf/util/include/linux/const.h deleted +0 -1
deleted file mode 100644
index 1b476c9..0000000
@@ -1 +0,0 @@
-#include "../../../../include/linux/const.h"
tools/perf/util/include/linux/poison.h deleted +0 -1
deleted file mode 100644
index fef6dbc..0000000
@@ -1 +0,0 @@
-#include "../../../../include/linux/poison.h"
tools/perf/util/include/linux/rbtree.h deleted +0 -1
deleted file mode 100644
index 7a243a1..0000000
@@ -1 +0,0 @@
-#include "../../../../include/linux/rbtree.h"
tools/perf/util/thread.c +1 -1
index fb4b7ea..11e217a 100644
@@ -1,4 +1,4 @@
-#include "../perf.h"
+#include "perf.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
tools/perf/util/wrapper.c +1 -0
index 73e900e..e9901a7 100644
@@ -1,6 +1,7 @@
 /*
  * Various trivial helper wrappers around standard functions
  */
+#include <linux/compiler.h>
 #include "cache.h"
 
 /*
Signature · 1 line
1.7.7.5
#1 lore raw

Em Fri, Jan 20, 2012 at 12:36:44PM -0800, Andi Kleen escreveu:

Quoted 9 lines

From: Andi Kleen <[email protected]>

The perf user space has a lot of includes with ugly .. chains. This also makes it impossible to include any perf files from other code.

I think the original reason for this were some wrapper include files for the kernel includes, and the explicit paths were needed to avoid endless recursion. A better way to handle this is #include_next

Quoted 8 lines

- Add all the relevant directories as -I in the Makefile
- Remove (near) all the .. in include statements
- Remove unnecessary wrappers that do nothing
- Fix up some fallout

This makes the code more pleasant to read.

I did it all in one big patch to keep bisectability.

It builds, but breaks this:

[acme@emilia linux]$ make help | grep perf
perf-tar-src-pkg - Build perf-3.2.0.tar source tarball
perf-targz-src-pkg - Build perf-3.2.0.tar.gz source tarball perf-tarbz2-src-pkg - Build perf-3.2.0.tar.bz2 source tarball perf-tarxz-src-pkg - Build perf-3.2.0.tar.xz source tarball
[acme@emilia linux]$ make perf-tarxz-src-pkg
TAR
[acme@emilia linux]$ ls -la perf-3.2.0.tar.xz
-rw-rw-r-- 1 acme acme 391180 Jan 30 14:48 perf-3.2.0.tar.xz
[acme@emilia linux]$ mv perf-3.2.0.tar.xz /tmp [acme@emilia linux]$ cd /tmp
[acme@emilia tmp]$ tar xvf perf-3.2.0.tar.xz perf-3.2.0/
perf-3.2.0/arch/
perf-3.2.0/arch/alpha/
<SNIP>
[acme@emilia tmp]$ cd perf-3.2.0
[acme@emilia perf-3.2.0]$ l
total 36
drwxrwxr-x 6 acme acme 4096 Jan 30 14:48 ./
drwxrwxrwt. 6 root root 12288 Jan 30 14:48 ../ drwxrwxr-x 27 acme acme 4096 Jan 30 14:48 arch/

-rw-rw-r--   1 acme acme    41 Jan 30 14:48 HEAD
drwxrwxr-x   3 acme acme  4096 Jan 30 14:48 include/
drwxrwxr-x   2 acme acme  4096 Jan 30 14:48 lib/
drwxrwxr-x   3 acme acme  4096 Jan 30 14:48 tools/

[acme@emilia perf-3.2.0]$ make -C tools/perf/ install
make: Entering directory /tmp/perf-3.2.0/tools/perf' make[1]: *** No rule to make target kernelversion'. Stop. PERF_VERSION =
make: Leaving directory `/tmp/perf-3.2.0/tools/perf'
make: Entering directory /tmp/perf-3.2.0/tools/perf' make[1]: *** No rule to make target kernelversion'. Stop.
GEN common-cmds.h
* new build flags or prefix
CC perf.o
make: *** No rule to make target ../../arch/x86/lib/memset_64.S', needed by builtin-annotate.o'. Stop.
make: Leaving directory `/tmp/perf-3.2.0/tools/perf' [acme@emilia perf-3.2.0]$

I mean jusst the:

make: *** No rule to make target `../../arch/x86/lib/memset_64.S',

part, the other one (kernelversion), if you fix, double brownie points to ya :-)

- Arnaldo

#2 lore raw
Quoted 15 lines · Arnaldo Carvalho de Melo

Em Fri, Jan 20, 2012 at 12:36:44PM -0800, Andi Kleen escreveu:

Quoted 14 lines

From: Andi Kleen<[email protected]>

The perf user space has a lot of includes with ugly .. chains. This also makes it impossible to include any perf files from other code.

I think the original reason for this were some wrapper include files for the kernel includes, and the explicit paths were needed to avoid endless recursion. A better way to handle this is #include_next

- Add all the relevant directories as -I in the Makefile
- Remove (near) all the .. in include statements
- Remove unnecessary wrappers that do nothing
- Fix up some fallout

Quoted 4 lines
Quoted 3 lines

This makes the code more pleasant to read.

I did it all in one big patch to keep bisectability.

It builds, but breaks this:

Hmm cannot reproduce. The extra tarball builds fine and includes memset_64.S with my patch on Linus latest.

-Andi

#3 lore raw

Em Mon, Jan 30, 2012 at 01:45:11PM -0800, Andi Kleen escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 7 lines

Em Fri, Jan 20, 2012 at 12:36:44PM -0800, Andi Kleen escreveu:

Quoted 6 lines

From: Andi Kleen<[email protected]>
- Add all the relevant directories as -I in the Makefile
- Remove (near) all the .. in include statements
- Remove unnecessary wrappers that do nothing
- Fix up some fallout

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

This makes the code more pleasant to read.

I did it all in one big patch to keep bisectability.

It builds, but breaks this:

Hmm cannot reproduce. The extra tarball builds fine and includes memset_64.S with my patch on Linus latest.

Humm, there was a patch for 'perf bench' that came after your patch and I applied before yours, I bet that is the problem, I'll get that checked.

Thanks,

- Arnaldo