Skip to contentSkip to conversation

perf tool: Carve out ctype.h et al

PATCH In review Borislav Petkov 4 participants 17 messages Jun 25, 2014 – Jul 7, 2014 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tool: Carve out ctype.h et al

From: Borislav Petkov <[email protected]>

Carve out ctype.* and util.* stuff into tools/lib/util/. We're keeping those as standalone object files in TOOLS_OBJS and add them to the targets that need them.

This way we don't do lib archives but single objects only.

---
 tools/lib/Makefile                    | 35 ++++++++++++++++++++++++++
 tools/lib/symbol/kallsyms.c           |  2 +-
 tools/lib/symbol/kallsyms.h           |  4 ++-
 tools/{perf => lib}/util/ctype.c      |  2 +-
 tools/lib/util/ctype.h                | 46 +++++++++++++++++++++++++++++++++++
 tools/lib/util/util.c                 | 34 ++++++++++++++++++++++++++
 tools/lib/util/util.h                 |  9 +++++++
 tools/perf/MANIFEST                   |  1 +
 tools/perf/Makefile.perf              | 27 ++++++--------------
 tools/perf/arch/common.c              |  2 ++
 tools/perf/builtin-top.c              |  2 ++
 tools/perf/ui/browser.c               |  2 ++
 tools/perf/ui/browsers/map.c          |  2 ++
 tools/perf/util/alias.c               |  2 ++
 tools/perf/util/annotate.c            |  2 ++
 tools/perf/util/color.c               |  2 ++
 tools/perf/util/config.c              |  2 ++
 tools/perf/util/cpumap.c              |  1 +
 tools/perf/util/debug.c               |  2 ++
 tools/perf/util/header.c              |  1 +
 tools/perf/util/include/linux/ctype.h |  1 -
 tools/perf/util/probe-finder.h        |  2 ++
 tools/perf/util/python-ext-sources    |  1 -
 tools/perf/util/strfilter.c           |  2 ++
 tools/perf/util/string.c              |  2 ++
 tools/perf/util/symbol.c              |  2 ++
 tools/perf/util/util.c                | 33 -------------------------
 tools/perf/util/util.h                | 43 --------------------------------
 tools/scripts/Makefile.include        | 12 +++++++++
 29 files changed, 177 insertions(+), 101 deletions(-)
 create mode 100644 tools/lib/Makefile
 rename tools/{perf => lib}/util/ctype.c (98%)
 create mode 100644 tools/lib/util/ctype.h
 create mode 100644 tools/lib/util/util.c
 create mode 100644 tools/lib/util/util.h
 delete mode 100644 tools/perf/util/include/linux/ctype.h
tools/lib/Makefile new file +35 -0
new file mode 100644
index 000000000000..9f26cec44cea
@@ -0,0 +1,35 @@
+include ../scripts/Makefile.include
+include ../perf/config/utilities.mak		# QUIET_CLEAN
+
+HEADERS=
+OBJECTS=
+
+HEADERS += symbol/kallsyms.h
+HEADERS += util/ctype.h
+HEADERS += util/util.h
+
+OBJECTS += $(OUTPUT)symbol/kallsyms.o
+OBJECTS += $(OUTPUT)util/ctype.o
+OBJECTS += $(OUTPUT)util/util.o
+
+INCLUDE := -I$(srctree)/tools/include
+CFLAGS = -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(INCLUDE)
+EXTLIBS = -lelf -lpthread -lrt -lm
+ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ALL_LDFLAGS = $(LDFLAGS)
+
+RM = rm -f
+
+all: $(OBJECTS)
+
+$(OBJECTS): $(HEADERS)
+
+$(OUTPUT)%.o: %.c
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+$(OUTPUT)%.s: %.c
+	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
+$(OUTPUT)%.o: %.S
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+
+clean:
+	$(RM) $(OBJECTS)
tools/lib/symbol/kallsyms.c +1 -1
index 18bc271a4bbc..ab124d5ced82 100644
@@ -1,4 +1,4 @@
-#include "symbol/kallsyms.h"
+#include "kallsyms.h"
 #include <stdio.h>
 #include <stdlib.h>
 
tools/lib/symbol/kallsyms.h +3 -1
index 6084f5e18b3c..f8734487d3a7 100644
@@ -2,9 +2,11 @@
 #define __TOOLS_KALLSYMS_H_ 1
 
 #include <elf.h>
-#include <linux/ctype.h>
 #include <linux/types.h>
 
+#include "../util/util.h"
+#include "../util/ctype.h"
+
 #ifndef KSYM_NAME_LEN
 #define KSYM_NAME_LEN 256
 #endif
tools/lib/util/ctype.c renamed from tools/perf/util/ctype.c +1 -1
similarity index 98%
rename from tools/perf/util/ctype.c
rename to tools/lib/util/ctype.c
index aada3ac5e891..5cbe3f792c59 100644
@@ -3,7 +3,7 @@
  *
  * No surprises, and works with signed and unsigned chars.
  */
-#include "util.h"
+#include "ctype.h"
 
 enum {
 	S = GIT_SPACE,
tools/lib/util/ctype.h new file +46 -0

46 lines not on this page · raw message

tools/lib/util/util.c new file +34 -0
new file mode 100644
index 000000000000..091c8b990744
@@ -0,0 +1,34 @@
+#include "util.h"
+
+static int hex(char ch)
+{
+	if ((ch >= '0') && (ch <= '9'))
+		return ch - '0';
+	if ((ch >= 'a') && (ch <= 'f'))
+		return ch - 'a' + 10;
+	if ((ch >= 'A') && (ch <= 'F'))
+		return ch - 'A' + 10;
+	return -1;
+}
+
+/*
+ * While we find nice hex chars, build a long_val.
+ * Return number of chars processed.
+ */
+int hex2u64(const char *ptr, u64 *long_val)
+{
+	const char *p = ptr;
+	*long_val = 0;
+
+	while (*p) {
+		const int hex_val = hex(*p);
+
+		if (hex_val < 0)
+			break;
+
+		*long_val = (*long_val << 4) | hex_val;
+		p++;
+	}
+
+	return p - ptr;
+}
tools/lib/util/util.h new file +9 -0
new file mode 100644
index 000000000000..575c41f4f3f3
@@ -0,0 +1,9 @@
+#ifndef __TOOLS_UTIL_H__
+#define __TOOLS_UTIL_H__
+
+#include <linux/types.h>
+
+int hex2u64(const char *ptr, u64 *val);
+
+#endif /* __TOOLS_UTIL_H__ */
+
tools/perf/MANIFEST +1 -0
index 45da209b6ed3..3608c5bf33cf 100644
@@ -4,6 +4,7 @@ tools/lib/traceevent
 tools/lib/api
 tools/lib/symbol/kallsyms.c
 tools/lib/symbol/kallsyms.h
+tools/lib/util/*.[ch]
 tools/include/asm/bug.h
 tools/include/linux/compiler.h
 tools/include/linux/hash.h
tools/perf/Makefile.perf +7 -20
index 9670a16fa577..d359370d78c0 100644
@@ -61,16 +61,6 @@ include config/utilities.mak
 # Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
 # for dwarf backtrace post unwind.
 
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
-ifneq ($(objtree),)
-#$(info Determined 'objtree' to be $(objtree))
-endif
-
 ifneq ($(OUTPUT),)
 #$(info Determined 'OUTPUT' to be $(OUTPUT))
 endif
@@ -124,6 +114,7 @@ LIB_OBJS =
 GTK_OBJS =
 PYRF_OBJS =
 SCRIPT_SH =
+TOOLS_OBJS =
 
 SCRIPT_SH += perf-archive.sh
 
@@ -148,6 +139,9 @@ export LIBTRACEEVENT
 LIBAPIKFS = $(LIB_PATH)libapikfs.a
 export LIBAPIKFS
 
+TOOLS_OBJS += $(patsubst %.c,%.o,$(wildcard $(srctree)/tools/lib/symbol/*.c))
+TOOLS_OBJS += $(patsubst %.c,%.o,$(wildcard $(srctree)/tools/lib/util/*.c))
+
 # python extension build directories
 PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
 PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
@@ -157,7 +151,7 @@ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
 python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
 
 PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
-PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS)
+PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS) $(TOOLS_OBJS)
 
 $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
 	$(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
@@ -208,7 +202,6 @@ $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
 
 LIB_FILE=$(OUTPUT)libperf.a
 
-LIB_H += ../lib/symbol/kallsyms.h
 LIB_H += ../../include/uapi/linux/perf_event.h
 LIB_H += ../../include/linux/rbtree.h
 LIB_H += ../../include/linux/list.h
@@ -219,7 +212,6 @@ LIB_H += util/include/linux/bitmap.h
 LIB_H += util/include/linux/bitops.h
 LIB_H += ../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 += ../include/linux/export.h
@@ -306,7 +298,6 @@ LIB_OBJS += $(OUTPUT)util/alias.o
 LIB_OBJS += $(OUTPUT)util/annotate.o
 LIB_OBJS += $(OUTPUT)util/build-id.o
 LIB_OBJS += $(OUTPUT)util/config.o
-LIB_OBJS += $(OUTPUT)util/ctype.o
 LIB_OBJS += $(OUTPUT)util/pmu.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
@@ -314,7 +305,6 @@ LIB_OBJS += $(OUTPUT)util/evlist.o
 LIB_OBJS += $(OUTPUT)util/evsel.o
 LIB_OBJS += $(OUTPUT)util/exec_cmd.o
 LIB_OBJS += $(OUTPUT)util/help.o
-LIB_OBJS += $(OUTPUT)util/kallsyms.o
 LIB_OBJS += $(OUTPUT)util/levenshtein.o
 LIB_OBJS += $(OUTPUT)util/parse-options.o
 LIB_OBJS += $(OUTPUT)util/parse-events.o
@@ -699,9 +689,6 @@ $(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
 $(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
 
-$(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c $(OUTPUT)PERF-CFLAGS
-	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
-
 $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
 
@@ -741,8 +728,8 @@ $(DIRECTORY_DEPS): | $(OUTPUT_DIRECTORIES)
 $(OUTPUT_DIRECTORIES):
 	$(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
 
-$(LIB_FILE): $(LIB_OBJS)
-	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
+$(LIB_FILE): $(LIB_OBJS) $(TOOLS_OBJS)
+	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) $(TOOLS_OBJS)
 
 # libtraceevent.a
 TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
tools/perf/arch/common.c +2 -0
index 42faf369211c..a86e75f66b68 100644
@@ -3,6 +3,8 @@
 #include "common.h"
 #include "../util/debug.h"
 
+#include <util/ctype.h>
+
 const char *const arm_triplets[] = {
 	"arm-eabi-",
 	"arm-linux-androideabi-",
tools/perf/builtin-top.c +2 -0
index 377971dc89a3..8cc7a361e756 100644
@@ -66,6 +66,8 @@
 #include <sys/utsname.h>
 #include <sys/mman.h>
 
+#include <util/ctype.h>
+
 #include <linux/unistd.h>
 #include <linux/types.h>
 
tools/perf/ui/browser.c +2 -0
index 9d2294efc00c..09b9f28849b5 100644
@@ -14,6 +14,8 @@
 #include "keysyms.h"
 #include "../color.h"
 
+#include <util/ctype.h>
+
 static int ui_browser__percent_color(struct ui_browser *browser,
 				     double percent, bool current)
 {
tools/perf/ui/browsers/map.c +2 -0
index b11639f33682..e77ee26aa5e9 100644
@@ -12,6 +12,8 @@
 #include "../keysyms.h"
 #include "map.h"
 
+#include <util/ctype.h>
+
 struct map_browser {
 	struct ui_browser b;
 	struct map	  *map;
tools/perf/util/alias.c +2 -0
index c0b43ee40d95..c9c8429ade1e 100644
@@ -1,5 +1,7 @@
 #include "cache.h"
 
+#include <util/ctype.h>
+
 static const char *alias_key;
 static char *alias_val;
 
tools/perf/util/annotate.c +2 -0
index 809b4c50beae..947c871737f1 100644
@@ -20,6 +20,8 @@
 #include <pthread.h>
 #include <linux/bitops.h>
 
+#include <util/ctype.h>
+
 const char 	*disassembler_style;
 const char	*objdump_path;
 
tools/perf/util/color.c +2 -0
index 87b8672eb413..d933e1daa19a 100644
@@ -3,6 +3,8 @@
 #include "color.h"
 #include <math.h>
 
+#include <util/ctype.h>
+
 int perf_use_color_default = -1;
 
 static int parse_color(const char *name, int len)
tools/perf/util/config.c +2 -0
index 24519e14ac56..ca6a6c24361b 100644
@@ -13,6 +13,8 @@
 #include "exec_cmd.h"
 #include "util/hist.h"  /* perf_hist_config */
 
+#include <util/ctype.h>
+
 #define MAXNAME (256)
 
 #define DEBUG_CACHE_DIR ".debug"
tools/perf/util/cpumap.c +1 -0
index c4e55b71010c..43ec84c77d87 100644
@@ -1,5 +1,6 @@
 #include "util.h"
 #include <api/fs/fs.h>
+#include <util/ctype.h>
 #include "../perf.h"
 #include "cpumap.h"
 #include <assert.h>
tools/perf/util/debug.c +2 -0
index 299b55586502..b705653b776d 100644
@@ -1,5 +1,7 @@
 /* For general debugging purposes */
 
+#include <util/ctype.h>
+
 #include "../perf.h"
 
 #include <string.h>
tools/perf/util/header.c +1 -0
index 893f8e2df928..3e0455e53302 100644
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <sys/utsname.h>
+#include <util/ctype.h>
 
 #include "evlist.h"
 #include "evsel.h"
tools/perf/util/include/linux/ctype.h deleted +0 -1
deleted file mode 100644
index a53d4ee1e0b7..000000000000
@@ -1 +0,0 @@
-#include "../util.h"
tools/perf/util/probe-finder.h +2 -0
index 92590b2c7e1c..f8a50e89dc3b 100644
@@ -6,6 +6,8 @@
 #include "intlist.h"
 #include "probe-event.h"
 
+#include <util/ctype.h>
+
 #define MAX_PROBE_BUFFER	1024
 #define MAX_PROBES		 128
 #define MAX_PROBE_ARGS		 128
tools/perf/util/python-ext-sources +0 -1
index 16a475a7d492..24a991a7d9e8 100644
@@ -6,7 +6,6 @@
 #
 
 util/python.c
-util/ctype.c
 util/evlist.c
 util/evsel.c
 util/cpumap.c
tools/perf/util/strfilter.c +2 -0
index 79a757a2a15c..4b40baf0006d 100644
@@ -2,6 +2,8 @@
 #include "string.h"
 #include "strfilter.h"
 
+#include <util/ctype.h>
+
 /* Operators */
 static const char *OP_and	= "&";	/* Logical AND */
 static const char *OP_or	= "|";	/* Logical OR */
tools/perf/util/string.c +2 -0
index 2553e5b55b89..4017e56cc513 100644
@@ -1,6 +1,8 @@
 #include "util.h"
 #include "linux/string.h"
 
+#include <util/ctype.h>
+
 #define K 1024LL
 /*
  * perf_atoll()
tools/perf/util/symbol.c +2 -0
index 7b9096f29cdb..38a370d906b8 100644
@@ -21,6 +21,8 @@
 #include <symbol/kallsyms.h>
 #include <sys/utsname.h>
 
+#include <util/util.h>
+
 static int dso__load_kernel_sym(struct dso *dso, struct map *map,
 				symbol_filter_t filter);
 static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
tools/perf/util/util.c +0 -33
index 95aefa78bb07..175e6909ceb3 100644
@@ -206,39 +206,6 @@ size_t hex_width(u64 v)
 	return n;
 }
 
-static int hex(char ch)
-{
-	if ((ch >= '0') && (ch <= '9'))
-		return ch - '0';
-	if ((ch >= 'a') && (ch <= 'f'))
-		return ch - 'a' + 10;
-	if ((ch >= 'A') && (ch <= 'F'))
-		return ch - 'A' + 10;
-	return -1;
-}
-
-/*
- * While we find nice hex chars, build a long_val.
- * Return number of chars processed.
- */
-int hex2u64(const char *ptr, u64 *long_val)
-{
-	const char *p = ptr;
-	*long_val = 0;
-
-	while (*p) {
-		const int hex_val = hex(*p);
-
-		if (hex_val < 0)
-			break;
-
-		*long_val = (*long_val << 4) | hex_val;
-		p++;
-	}
-
-	return p - ptr;
-}
-
 /* Obtain a backtrace and print it to stdout. */
 #ifdef HAVE_BACKTRACE_SUPPORT
 void dump_stack(void)
tools/perf/util/util.h +0 -43

61 lines not on this page · raw message

tools/scripts/Makefile.include +12 -0
index 8abbef164b4e..7439b9de1a4a 100644
@@ -82,3 +82,15 @@ ifneq ($(findstring $(MAKEFLAGS),s),s)
 	QUIET_INSTALL  = @printf '  INSTALL  %s\n' $1;
   endif
 endif
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
+
+ifneq ($(objtree),)
+#$(info Determined 'objtree' to be $(objtree))
+endif
+
+
Signature · 1 line
2.0.0
#1 lore raw
Quoted 7 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Carve out ctype.* and util.* stuff into tools/lib/util/. We're keeping those as standalone object files in TOOLS_OBJS and add them to the targets that need them.

This way we don't do lib archives but single objects only.

heya,
got following error;

[jolsa@krava perf]$ make

  BUILD:   Doing 'make -j4' parallel build
  CC       util/pmu.o
  CC       util/parse-events-flex.o
  SUBDIR   /home/jolsa/kernel.org/linux-perf/tools/lib/traceevent/

util/pmu.c: In function ‘wordwrap’:
util/pmu.c:788:3: error: implicit declaration of function ‘isspace’ [-Werror=implicit-function-declaration]
while (isspace(*s))
^
cc1: all warnings being treated as errors
make[1]: *** [util/pmu.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

Anyway, so you moved hex2u64, ctype interface under tools/lib and made several Makefile changes to compile tools/lib objects.

Besides that we'd need all those changes separated, who is the other user of this library? I dont see any in the patch.

thanks,
jirka

#2 lore raw

Em Wed, Jun 25, 2014 at 09:25:47PM +0200, Jiri Olsa escreveu:

Quoted 2 lines

Besides that we'd need all those changes separated, who is the other user of this library? I dont see any in the patch.

Probably will come in a separate patchkit that is dependent on this, but not strictly related?

- Arnaldo

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

Probably will come in a separate patchkit that is dependent on this, but not strictly related?

Yeah, so roughly speaking, we want to carve out the code which opens and handles events in perf tool so that we can use it in other tools. In the particular example with the ras daemon, we want to be able to open a tracepoint in userspace and read from it.

We're doing this piecewise because perf tool changes too fast and I've done a full conversion patchset a couple of times already only to realize that it grows obsolete practically only days after sending it out. (Btw, for that it is all your fault, of course :-P). Which makes preparing a full patchset almost impossible.

Does this explanation make sense?

@jirka: I'll try to reproduce your build error.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#4 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Arnaldo Carvalho de Melo

Probably will come in a separate patchkit that is dependent on this, but not strictly related?

Yeah, so roughly speaking, we want to carve out the code which opens and handles events in perf tool so that we can use it in other tools. In the

this functionality is inside evlist/evsel/target(...) objects

Quoted 2 lines

particular example with the ras daemon, we want to be able to open a tracepoint in userspace and read from it.

the ras daemon is not in tree yet is it? cant find it..

Quoted 8 lines

We're doing this piecewise because perf tool changes too fast and I've done a full conversion patchset a couple of times already only to realize that it grows obsolete practically only days after sending it out. (Btw, for that it is all your fault, of course :-P). Which makes preparing a full patchset almost impossible.

Does this explanation make sense?

I think we should librarize only stuff we will share. Whats the plan about the ras daemon (if I did not overlook it) to be put into tools?

thanks,
jirka

#5 lore raw
Quoted 1 line · Jiri Olsa

this functionality is inside evlist/evsel/target(...) objects

Yep, and that functionality depends on generic stuff which we're trying to export first. :-)

Quoted 1 line

the ras daemon is not in tree yet is it? cant find it..

Here's an old version: http://thread.gmane.org/gmane.linux.kernel/1090275

Quoted 1 line

I think we should librarize only stuff we will share.

You sound just like acme! :-) But yeah, this is what he said at the time and this is what we want to do - we don't want to do more work than necessary after all :-)

Quoted 2 lines

Whats the plan about the ras daemon (if I did not overlook it) to be put into tools?

I'd say no initially, after the kvmtool explosion last time. Which is still ok I guess.

If it remains out of tree, we will probably have some issues if the exported pieces change and we'll have to readjust the external code which depends on it. We'll see.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#6 lore raw
In reply to Jiri Olsa
Quoted 8 lines · Jiri Olsa

heya,
got following error;

[jolsa@krava perf]$ make

  BUILD:   Doing 'make -j4' parallel build
  CC       util/pmu.o
  CC       util/parse-events-flex.o
  SUBDIR   /home/jolsa/kernel.org/linux-perf/tools/lib/traceevent/
Quoted 8 lines

util/pmu.c: In function ‘wordwrap’:
util/pmu.c:788:3: error: implicit declaration of function ‘isspace’ [-Werror=implicit-function-declaration]
while (isspace(*s))
^
cc1: all warnings being treated as errors
make[1]: *** [util/pmu.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

This is a perfect example why doing this piecewise is the only way to go! And even that is not easy:

I don't have this line in util/pmu.c:788 so I can't trigger it:

   782  bool pmu_have_event(const char *pname, const char *name)
   783  {
   784          struct perf_pmu *pmu;
   785          struct perf_pmu_alias *alias;
   786  
   787          pmu = NULL;
   788          while ((pmu = perf_pmu__scan(pmu)) != NULL) {
   789                  if (strcmp(pname, pmu->name))
   790                          continue;
   791                  list_for_each_entry(alias, &pmu->aliases, list)
   792                          if (!strcmp(alias->name, name))
   793                                  return true;
   794          }
   795          return false;
   796  }

So, I've done the patch ontop of those branches:

commit 279a8cc64fada4b0e7ebf4e4631d67c8ca715f27
Merge: 9724066c49ba 1545d8aca9ac
Author: Borislav Petkov <[email protected]>
Date: Tue Jun 24 15:45:51 2014 +0200

Merge remote-tracking branch 'jolsa/perf/core' into ptool-v0.5

commit 9724066c49baab314a0c3d3f84ec102cd0f76b86
Merge: ecdac96899e3 a93f0e551af9
Author: Borislav Petkov <[email protected]>
Date: Tue Jun 24 15:45:44 2014 +0200

Merge remote-tracking branch 'jolsa/perf/urgent' into ptool-v0.5

commit a93f0e551af9e194db38bfe16001e17a3a1d189a

Author: Simon Que <[email protected]>
Date:   Mon Jun 16 11:32:09 2014 -0700

perf symbols: Get kernel start address by symbol name

by checking out acme/perf/core first.

So, guys, can we agree on a common branch to apply patches ontop please?

Thanks a lot.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#7 lore raw

Em Wed, Jun 25, 2014 at 10:38:36PM +0200, Borislav Petkov escreveu:

Quoted 18 lines · Jiri Olsa
Quoted 8 lines

heya,
got following error;

[jolsa@krava perf]$ make

  BUILD:   Doing 'make -j4' parallel build
  CC       util/pmu.o
  CC       util/parse-events-flex.o
  SUBDIR   /home/jolsa/kernel.org/linux-perf/tools/lib/traceevent/
Quoted 8 lines

util/pmu.c: In function ‘wordwrap’:
util/pmu.c:788:3: error: implicit declaration of function ‘isspace’ [-Werror=implicit-function-declaration]
while (isspace(*s))
^
cc1: all warnings being treated as errors
make[1]: *** [util/pmu.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

Quoted 2 lines

This is a perfect example why doing this piecewise is the only way to go! And even that is not easy:

Yeah, and albeit it can take time, its how it would be done if this was touching core kernel code, right? So lets try to do it that way ;-)

Quoted 35 lines

I don't have this line in util/pmu.c:788 so I can't trigger it:

   782  bool pmu_have_event(const char *pname, const char *name)
   783  {
   784          struct perf_pmu *pmu;
   785          struct perf_pmu_alias *alias;
   786  
   787          pmu = NULL;
   788          while ((pmu = perf_pmu__scan(pmu)) != NULL) {
   789                  if (strcmp(pname, pmu->name))
   790                          continue;
   791                  list_for_each_entry(alias, &pmu->aliases, list)
   792                          if (!strcmp(alias->name, name))
   793                                  return true;
   794          }
   795          return false;
   796  }

So, I've done the patch ontop of those branches:

commit 279a8cc64fada4b0e7ebf4e4631d67c8ca715f27
Merge: 9724066c49ba 1545d8aca9ac
Author: Borislav Petkov <[email protected]>
Date: Tue Jun 24 15:45:51 2014 +0200

Merge remote-tracking branch 'jolsa/perf/core' into ptool-v0.5

commit 9724066c49baab314a0c3d3f84ec102cd0f76b86
Merge: ecdac96899e3 a93f0e551af9
Author: Borislav Petkov <[email protected]>
Date: Tue Jun 24 15:45:44 2014 +0200

Merge remote-tracking branch 'jolsa/perf/urgent' into ptool-v0.5

commit a93f0e551af9e194db38bfe16001e17a3a1d189a

Quoted 8 lines
Author: Simon Que <[email protected]>
Date:   Mon Jun 16 11:32:09 2014 -0700

perf symbols: Get kernel start address by symbol name

by checking out acme/perf/core first.

So, guys, can we agree on a common branch to apply patches ontop please?

I'd say work on tip/perf/core, if it doesn't apply on mine or jolsa's, we'll fix it up, right Jiri?

We try not to keep too much stuff queued up, so there should be no problems 99.9% of the time...

- Arnaldo

#8 lore raw
Quoted 3 lines · Arnaldo Carvalho de Melo

Yeah, and albeit it can take time, its how it would be done if this was touching core kernel code, right? So lets try to do it that way ;-)

Oh sure, I'm not complaining - I'm just discussing our process and how to optimize it.

Quoted 5 lines

I'd say work on tip/perf/core, if it doesn't apply on mine or jolsa's, we'll fix it up, right Jiri?

We try not to keep too much stuff queued up, so there should be no problems 99.9% of the time...

Ok, good.

I'll rebase the patch ontop of it tomorrow. Now back to the football game! :-)

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#9 lore raw
In reply to Arnaldo Carvalho de Melo

On Wed, Jun 25, 2014 at 06:17:57PM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

Quoted 7 lines
Quoted 7 lines

Merge remote-tracking branch 'jolsa/perf/urgent' into ptool-v0.5

commit a93f0e551af9e194db38bfe16001e17a3a1d189a

Author: Simon Que <[email protected]>
Date:   Mon Jun 16 11:32:09 2014 -0700
Quoted 8 lines
Quoted 5 lines

perf symbols: Get kernel start address by symbol name

by checking out acme/perf/core first.

So, guys, can we agree on a common branch to apply patches ontop please?

I'd say work on tip/perf/core, if it doesn't apply on mine or jolsa's, we'll fix it up, right Jiri?

yep, tip/perf/core maybe plus merges from acme/perf/core and jolsa/perf/core should do it ;-)

jirka

#10 lore raw
Quoted 2 lines · Jiri Olsa

yep, tip/perf/core maybe plus merges from acme/perf/core and jolsa/perf/core should do it ;-)

Ok, just did this (jolsa/perf/coreas up-to-date) nd I still can't trigger the build failure:

commit f05523d9b9aaf18fb28acd009dc9142b2da16380
Merge: 80f0ae409ee9 07100877ea8f
Author: Borislav Petkov <[email protected]>
Date: Thu Jun 26 11:59:07 2014 +0200

Merge remote-tracking branch 'acme/perf/core' into ptool-v0.5.2

commit 80f0ae409ee945d598fa982efff53d9f887cc5d5
Merge: d7933ab727ed 2f88993d53c5
Author: Borislav Petkov <[email protected]>
Date: Thu Jun 26 11:58:24 2014 +0200

Merge remote-tracking branch 'tip/master' into rc2+-3

commit d7933ab727ed035bdf420d7381b831ba959cecc5
Merge: 2a80ff867f35 ce36d9ab3bab
Author: Linus Torvalds <[email protected]>
Date: Wed Jun 25 21:47:28 2014 -0700

Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6

Maybe we're having different libraries installed?

Auto-detecting system features:

...                         dwarf: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ on  ]
...                      libaudit: [ on  ]
...                        libbfd: [ OFF ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...                       libperl: [ on  ]
...                     libpython: [ on  ]
...                      libslang: [ on  ]
...                     libunwind: [ on  ]

... libdw-dwarf-unwind: [ OFF ]
... DWARF post unwind library: libunwind

jirka?

Here's the patch again, attached.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
Quoted 1 line

From b9f9ef3709e7b28470bbbba2bdf57e27ee094e59 Mon Sep 17 00:00:00 2001

From: Borislav Petkov <[email protected]>
Date: Tue, 24 Jun 2014 22:05:38 +0200
Subject: [PATCH] perf tool: Carve out ctype.h et al

Carve out ctype.* and util.* stuff into tools/lib/util/. We're keeping those as standalone object files in TOOLS_OBJS and add them to the targets that need them.

This way we don't do lib archives but single objects only.

---
 tools/lib/Makefile                    | 35 ++++++++++++++++++++++++++
 tools/lib/symbol/kallsyms.c           |  2 +-
 tools/lib/symbol/kallsyms.h           |  4 ++-
 tools/{perf => lib}/util/ctype.c      |  2 +-
 tools/lib/util/ctype.h                | 46 +++++++++++++++++++++++++++++++++++
 tools/lib/util/util.c                 | 34 ++++++++++++++++++++++++++
 tools/lib/util/util.h                 |  9 +++++++
 tools/perf/MANIFEST                   |  1 +
 tools/perf/Makefile.perf              | 27 ++++++--------------
 tools/perf/arch/common.c              |  2 ++
 tools/perf/builtin-top.c              |  2 ++
 tools/perf/ui/browser.c               |  2 ++
 tools/perf/ui/browsers/map.c          |  2 ++
 tools/perf/util/alias.c               |  2 ++
 tools/perf/util/annotate.c            |  2 ++
 tools/perf/util/color.c               |  2 ++
 tools/perf/util/config.c              |  2 ++
 tools/perf/util/cpumap.c              |  1 +
 tools/perf/util/debug.c               |  2 ++
 tools/perf/util/header.c              |  1 +
 tools/perf/util/include/linux/ctype.h |  1 -
 tools/perf/util/probe-finder.h        |  2 ++
 tools/perf/util/python-ext-sources    |  1 -
 tools/perf/util/strfilter.c           |  2 ++
 tools/perf/util/string.c              |  2 ++
 tools/perf/util/symbol.c              |  2 ++
 tools/perf/util/util.c                | 33 -------------------------
 tools/perf/util/util.h                | 43 --------------------------------
 tools/scripts/Makefile.include        | 12 +++++++++
 29 files changed, 177 insertions(+), 101 deletions(-)
 create mode 100644 tools/lib/Makefile
 rename tools/{perf => lib}/util/ctype.c (98%)
 create mode 100644 tools/lib/util/ctype.h
 create mode 100644 tools/lib/util/util.c
 create mode 100644 tools/lib/util/util.h
 delete mode 100644 tools/perf/util/include/linux/ctype.h
tools/lib/Makefile new file +35 -0
new file mode 100644
index 000000000000..9f26cec44cea
@@ -0,0 +1,35 @@
+include ../scripts/Makefile.include
+include ../perf/config/utilities.mak		# QUIET_CLEAN
+
+HEADERS=
+OBJECTS=
+
+HEADERS += symbol/kallsyms.h
+HEADERS += util/ctype.h
+HEADERS += util/util.h
+
+OBJECTS += $(OUTPUT)symbol/kallsyms.o
+OBJECTS += $(OUTPUT)util/ctype.o
+OBJECTS += $(OUTPUT)util/util.o
+
+INCLUDE := -I$(srctree)/tools/include
+CFLAGS = -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(INCLUDE)
+EXTLIBS = -lelf -lpthread -lrt -lm
+ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ALL_LDFLAGS = $(LDFLAGS)
+
+RM = rm -f
+
+all: $(OBJECTS)
+
+$(OBJECTS): $(HEADERS)
+
+$(OUTPUT)%.o: %.c
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+$(OUTPUT)%.s: %.c
+	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
+$(OUTPUT)%.o: %.S
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+
+clean:
+	$(RM) $(OBJECTS)
tools/lib/symbol/kallsyms.c +1 -1
index 18bc271a4bbc..ab124d5ced82 100644
@@ -1,4 +1,4 @@
-#include "symbol/kallsyms.h"
+#include "kallsyms.h"
 #include <stdio.h>
 #include <stdlib.h>
 
tools/lib/symbol/kallsyms.h +3 -1
index 6084f5e18b3c..f8734487d3a7 100644
@@ -2,9 +2,11 @@
 #define __TOOLS_KALLSYMS_H_ 1
 
 #include <elf.h>
-#include <linux/ctype.h>
 #include <linux/types.h>
 
+#include "../util/util.h"
+#include "../util/ctype.h"
+
 #ifndef KSYM_NAME_LEN
 #define KSYM_NAME_LEN 256
 #endif
tools/lib/util/ctype.c renamed from tools/perf/util/ctype.c +1 -1
similarity index 98%
rename from tools/perf/util/ctype.c
rename to tools/lib/util/ctype.c
index aada3ac5e891..5cbe3f792c59 100644
@@ -3,7 +3,7 @@
  *
  * No surprises, and works with signed and unsigned chars.
  */
-#include "util.h"
+#include "ctype.h"
 
 enum {
 	S = GIT_SPACE,
tools/lib/util/ctype.h new file +46 -0

46 lines not on this page · raw message

tools/lib/util/util.c new file +34 -0
new file mode 100644
index 000000000000..091c8b990744
@@ -0,0 +1,34 @@
+#include "util.h"
+
+static int hex(char ch)
+{
+	if ((ch >= '0') && (ch <= '9'))
+		return ch - '0';
+	if ((ch >= 'a') && (ch <= 'f'))
+		return ch - 'a' + 10;
+	if ((ch >= 'A') && (ch <= 'F'))
+		return ch - 'A' + 10;
+	return -1;
+}
+
+/*
+ * While we find nice hex chars, build a long_val.
+ * Return number of chars processed.
+ */
+int hex2u64(const char *ptr, u64 *long_val)
+{
+	const char *p = ptr;
+	*long_val = 0;
+
+	while (*p) {
+		const int hex_val = hex(*p);
+
+		if (hex_val < 0)
+			break;
+
+		*long_val = (*long_val << 4) | hex_val;
+		p++;
+	}
+
+	return p - ptr;
+}
tools/lib/util/util.h new file +9 -0
new file mode 100644
index 000000000000..575c41f4f3f3
@@ -0,0 +1,9 @@
+#ifndef __TOOLS_UTIL_H__
+#define __TOOLS_UTIL_H__
+
+#include <linux/types.h>
+
+int hex2u64(const char *ptr, u64 *val);
+
+#endif /* __TOOLS_UTIL_H__ */
+
tools/perf/MANIFEST +1 -0
index 45da209b6ed3..3608c5bf33cf 100644
@@ -4,6 +4,7 @@ tools/lib/traceevent
 tools/lib/api
 tools/lib/symbol/kallsyms.c
 tools/lib/symbol/kallsyms.h
+tools/lib/util/*.[ch]
 tools/include/asm/bug.h
 tools/include/linux/compiler.h
 tools/include/linux/hash.h
tools/perf/Makefile.perf +7 -20
index 9670a16fa577..d359370d78c0 100644
@@ -61,16 +61,6 @@ include config/utilities.mak
 # Define NO_LIBDW_DWARF_UNWIND if you do not want libdw support
 # for dwarf backtrace post unwind.
 
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
-ifneq ($(objtree),)
-#$(info Determined 'objtree' to be $(objtree))
-endif
-
 ifneq ($(OUTPUT),)
 #$(info Determined 'OUTPUT' to be $(OUTPUT))
 endif
@@ -124,6 +114,7 @@ LIB_OBJS =
 GTK_OBJS =
 PYRF_OBJS =
 SCRIPT_SH =
+TOOLS_OBJS =
 
 SCRIPT_SH += perf-archive.sh
 
@@ -148,6 +139,9 @@ export LIBTRACEEVENT
 LIBAPIKFS = $(LIB_PATH)libapikfs.a
 export LIBAPIKFS
 
+TOOLS_OBJS += $(patsubst %.c,%.o,$(wildcard $(srctree)/tools/lib/symbol/*.c))
+TOOLS_OBJS += $(patsubst %.c,%.o,$(wildcard $(srctree)/tools/lib/util/*.c))
+
 # python extension build directories
 PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
 PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
@@ -157,7 +151,7 @@ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
 python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
 
 PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
-PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS)
+PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS) $(TOOLS_OBJS)
 
 $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
 	$(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
@@ -208,7 +202,6 @@ $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
 
 LIB_FILE=$(OUTPUT)libperf.a
 
-LIB_H += ../lib/symbol/kallsyms.h
 LIB_H += ../../include/uapi/linux/perf_event.h
 LIB_H += ../../include/linux/rbtree.h
 LIB_H += ../../include/linux/list.h
@@ -219,7 +212,6 @@ LIB_H += util/include/linux/bitmap.h
 LIB_H += util/include/linux/bitops.h
 LIB_H += ../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 += ../include/linux/export.h
@@ -306,7 +298,6 @@ LIB_OBJS += $(OUTPUT)util/alias.o
 LIB_OBJS += $(OUTPUT)util/annotate.o
 LIB_OBJS += $(OUTPUT)util/build-id.o
 LIB_OBJS += $(OUTPUT)util/config.o
-LIB_OBJS += $(OUTPUT)util/ctype.o
 LIB_OBJS += $(OUTPUT)util/pmu.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
@@ -314,7 +305,6 @@ LIB_OBJS += $(OUTPUT)util/evlist.o
 LIB_OBJS += $(OUTPUT)util/evsel.o
 LIB_OBJS += $(OUTPUT)util/exec_cmd.o
 LIB_OBJS += $(OUTPUT)util/help.o
-LIB_OBJS += $(OUTPUT)util/kallsyms.o
 LIB_OBJS += $(OUTPUT)util/levenshtein.o
 LIB_OBJS += $(OUTPUT)util/parse-options.o
 LIB_OBJS += $(OUTPUT)util/parse-events.o
@@ -699,9 +689,6 @@ $(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
 $(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
 
-$(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c $(OUTPUT)PERF-CFLAGS
-	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
-
 $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
 	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
 
@@ -741,8 +728,8 @@ $(DIRECTORY_DEPS): | $(OUTPUT_DIRECTORIES)
 $(OUTPUT_DIRECTORIES):
 	$(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
 
-$(LIB_FILE): $(LIB_OBJS)
-	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
+$(LIB_FILE): $(LIB_OBJS) $(TOOLS_OBJS)
+	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS) $(TOOLS_OBJS)
 
 # libtraceevent.a
 TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
tools/perf/arch/common.c +2 -0
index 42faf369211c..a86e75f66b68 100644
@@ -3,6 +3,8 @@
 #include "common.h"
 #include "../util/debug.h"
 
+#include <util/ctype.h>
+
 const char *const arm_triplets[] = {
 	"arm-eabi-",
 	"arm-linux-androideabi-",
tools/perf/builtin-top.c +2 -0
index 377971dc89a3..8cc7a361e756 100644
@@ -66,6 +66,8 @@
 #include <sys/utsname.h>
 #include <sys/mman.h>
 
+#include <util/ctype.h>
+
 #include <linux/unistd.h>
 #include <linux/types.h>
 
tools/perf/ui/browser.c +2 -0
index 9d2294efc00c..09b9f28849b5 100644
@@ -14,6 +14,8 @@
 #include "keysyms.h"
 #include "../color.h"
 
+#include <util/ctype.h>
+
 static int ui_browser__percent_color(struct ui_browser *browser,
 				     double percent, bool current)
 {
tools/perf/ui/browsers/map.c +2 -0
index b11639f33682..e77ee26aa5e9 100644
@@ -12,6 +12,8 @@
 #include "../keysyms.h"
 #include "map.h"
 
+#include <util/ctype.h>
+
 struct map_browser {
 	struct ui_browser b;
 	struct map	  *map;
tools/perf/util/alias.c +2 -0
index c0b43ee40d95..c9c8429ade1e 100644
@@ -1,5 +1,7 @@
 #include "cache.h"
 
+#include <util/ctype.h>
+
 static const char *alias_key;
 static char *alias_val;
 
tools/perf/util/annotate.c +2 -0
index 809b4c50beae..947c871737f1 100644
@@ -20,6 +20,8 @@
 #include <pthread.h>
 #include <linux/bitops.h>
 
+#include <util/ctype.h>
+
 const char 	*disassembler_style;
 const char	*objdump_path;
 
tools/perf/util/color.c +2 -0
index 87b8672eb413..d933e1daa19a 100644
@@ -3,6 +3,8 @@
 #include "color.h"
 #include <math.h>
 
+#include <util/ctype.h>
+
 int perf_use_color_default = -1;
 
 static int parse_color(const char *name, int len)
tools/perf/util/config.c +2 -0
index 24519e14ac56..ca6a6c24361b 100644
@@ -13,6 +13,8 @@
 #include "exec_cmd.h"
 #include "util/hist.h"  /* perf_hist_config */
 
+#include <util/ctype.h>
+
 #define MAXNAME (256)
 
 #define DEBUG_CACHE_DIR ".debug"
tools/perf/util/cpumap.c +1 -0
index c4e55b71010c..43ec84c77d87 100644
@@ -1,5 +1,6 @@
 #include "util.h"
 #include <api/fs/fs.h>
+#include <util/ctype.h>
 #include "../perf.h"
 #include "cpumap.h"
 #include <assert.h>
tools/perf/util/debug.c +2 -0
index 299b55586502..b705653b776d 100644
@@ -1,5 +1,7 @@
 /* For general debugging purposes */
 
+#include <util/ctype.h>
+
 #include "../perf.h"
 
 #include <string.h>
tools/perf/util/header.c +1 -0
index 893f8e2df928..3e0455e53302 100644
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/bitops.h>
 #include <sys/utsname.h>
+#include <util/ctype.h>
 
 #include "evlist.h"
 #include "evsel.h"
tools/perf/util/include/linux/ctype.h deleted +0 -1
deleted file mode 100644
index a53d4ee1e0b7..000000000000
@@ -1 +0,0 @@
-#include "../util.h"
tools/perf/util/probe-finder.h +2 -0
index 92590b2c7e1c..f8a50e89dc3b 100644
@@ -6,6 +6,8 @@
 #include "intlist.h"
 #include "probe-event.h"
 
+#include <util/ctype.h>
+
 #define MAX_PROBE_BUFFER	1024
 #define MAX_PROBES		 128
 #define MAX_PROBE_ARGS		 128
tools/perf/util/python-ext-sources +0 -1
index 16a475a7d492..24a991a7d9e8 100644
@@ -6,7 +6,6 @@
 #
 
 util/python.c
-util/ctype.c
 util/evlist.c
 util/evsel.c
 util/cpumap.c
tools/perf/util/strfilter.c +2 -0
index 79a757a2a15c..4b40baf0006d 100644
@@ -2,6 +2,8 @@
 #include "string.h"
 #include "strfilter.h"
 
+#include <util/ctype.h>
+
 /* Operators */
 static const char *OP_and	= "&";	/* Logical AND */
 static const char *OP_or	= "|";	/* Logical OR */
tools/perf/util/string.c +2 -0
index 2553e5b55b89..4017e56cc513 100644
@@ -1,6 +1,8 @@
 #include "util.h"
 #include "linux/string.h"
 
+#include <util/ctype.h>
+
 #define K 1024LL
 /*
  * perf_atoll()
tools/perf/util/symbol.c +2 -0
index 7b9096f29cdb..38a370d906b8 100644
@@ -21,6 +21,8 @@
 #include <symbol/kallsyms.h>
 #include <sys/utsname.h>
 
+#include <util/util.h>
+
 static int dso__load_kernel_sym(struct dso *dso, struct map *map,
 				symbol_filter_t filter);
 static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map,
tools/perf/util/util.c +0 -33
index 95aefa78bb07..175e6909ceb3 100644
@@ -206,39 +206,6 @@ size_t hex_width(u64 v)
 	return n;
 }
 
-static int hex(char ch)
-{
-	if ((ch >= '0') && (ch <= '9'))
-		return ch - '0';
-	if ((ch >= 'a') && (ch <= 'f'))
-		return ch - 'a' + 10;
-	if ((ch >= 'A') && (ch <= 'F'))
-		return ch - 'A' + 10;
-	return -1;
-}
-
-/*
- * While we find nice hex chars, build a long_val.
- * Return number of chars processed.
- */
-int hex2u64(const char *ptr, u64 *long_val)
-{
-	const char *p = ptr;
-	*long_val = 0;
-
-	while (*p) {
-		const int hex_val = hex(*p);
-
-		if (hex_val < 0)
-			break;
-
-		*long_val = (*long_val << 4) | hex_val;
-		p++;
-	}
-
-	return p - ptr;
-}
-
 /* Obtain a backtrace and print it to stdout. */
 #ifdef HAVE_BACKTRACE_SUPPORT
 void dump_stack(void)
tools/perf/util/util.h +0 -43

61 lines not on this page · raw message

tools/scripts/Makefile.include +12 -0
index 8abbef164b4e..7439b9de1a4a 100644
@@ -82,3 +82,15 @@ ifneq ($(findstring $(MAKEFLAGS),s),s)
 	QUIET_INSTALL  = @printf '  INSTALL  %s\n' $1;
   endif
 endif
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
+
+ifneq ($(objtree),)
+#$(info Determined 'objtree' to be $(objtree))
+endif
+
+
Signature · 1 line
2.0.0
#11 lore raw
Quoted 44 lines · Borislav Petkov
Quoted 2 lines · Jiri Olsa

yep, tip/perf/core maybe plus merges from acme/perf/core and jolsa/perf/core should do it ;-)

Ok, just did this (jolsa/perf/coreas up-to-date) nd I still can't trigger the build failure:

commit f05523d9b9aaf18fb28acd009dc9142b2da16380
Merge: 80f0ae409ee9 07100877ea8f
Author: Borislav Petkov <[email protected]>
Date: Thu Jun 26 11:59:07 2014 +0200

Merge remote-tracking branch 'acme/perf/core' into ptool-v0.5.2

commit 80f0ae409ee945d598fa982efff53d9f887cc5d5
Merge: d7933ab727ed 2f88993d53c5
Author: Borislav Petkov <[email protected]>
Date: Thu Jun 26 11:58:24 2014 +0200

Merge remote-tracking branch 'tip/master' into rc2+-3

commit d7933ab727ed035bdf420d7381b831ba959cecc5
Merge: 2a80ff867f35 ce36d9ab3bab
Author: Linus Torvalds <[email protected]>
Date: Wed Jun 25 21:47:28 2014 -0700

Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6

Maybe we're having different libraries installed?

Auto-detecting system features:

...                         dwarf: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ on  ]
...                      libaudit: [ on  ]
...                        libbfd: [ OFF ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...                       libperl: [ on  ]
...                     libpython: [ on  ]
...                      libslang: [ on  ]
...                     libunwind: [ on  ]
Quoted 6 lines

... libdw-dwarf-unwind: [ OFF ]
... DWARF post unwind library: libunwind

jirka?

Here's the patch again, attached.

this one compiles ok for me

jirka

#12 lore raw
Quoted 1 line · Jiri Olsa

this one compiles ok for me

Ok, cool. So guys, can we apply this one so that I can continue with the next round?

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#13 lore raw

Em Sat, Jun 28, 2014 at 01:28:19AM +0200, Borislav Petkov escreveu:

Quoted 5 lines · Jiri Olsa
Quoted 1 line

this one compiles ok for me

Ok, cool. So guys, can we apply this one so that I can continue with the next round?

Sorry, but not yet, tried to build it (the version that Jiri said worked for him), after fixing up minor issues with blank lines being added to the end of two of the files and then:

[acme@ssdandy linux]$ date ;time make -C tools/perf O=~/git/build/perf install-bin Seg Jul 7 17:44:20 BRT 2014
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j8' parallel build
config/Makefile:316: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR

Auto-detecting system features:

...                         dwarf: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ on  ]
...                      libaudit: [ on  ]
...                        libbfd: [ on  ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...                       libperl: [ on  ]
...                     libpython: [ on  ]
...                      libslang: [ on  ]
...                     libunwind: [ on  ]

... libdw-dwarf-unwind: [ OFF ]
... DWARF post unwind library: libunwind

make[1]: *** No rule to make target /home/acme/git/linux/tools/lib/symbol/kallsyms.o', needed by /home/acme/git/build/perf/libperf.a'. Stop. make[1]: *** Waiting for unfinished jobs....
make: *** [install-bin] Error 2
make: Leaving directory `/home/acme/git/linux/tools/perf'

real 0m3.407s
user 0m2.434s
sys 0m0.819s
[acme@ssdandy linux]$

It builds ok if you do a build when CWD is tools/perf/, but who does that apart from Jiri? :-)

I'll try to fix this up later today, if you haven't done it by then.

Thanks,

- Arnaldo

#14 lore raw
Quoted 1 line · Arnaldo Carvalho de Melo

I'll try to fix this up later today, if you haven't done it by then.

I won't because it is too late here for me to have a functioning brain still, but don't bother - I'll take care of it tomorrow.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#15 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 10 lines · Arnaldo Carvalho de Melo

Em Sat, Jun 28, 2014 at 01:28:19AM +0200, Borislav Petkov escreveu:

Quoted 5 lines · Jiri Olsa
Quoted 1 line

this one compiles ok for me

Ok, cool. So guys, can we apply this one so that I can continue with the next round?

Sorry, but not yet, tried to build it (the version that Jiri said worked for him), after fixing up minor issues with blank lines being added to the end of two of the files and then:

yea, I meant it compiled for me ;-) I haven't reviewd the patch much, one thing I remember is that it should be separated into smaller changes.. should I wait for new version or review this one?

Quoted 30 lines

[acme@ssdandy linux]$ date ;time make -C tools/perf O=~/git/build/perf install-bin Seg Jul 7 17:44:20 BRT 2014
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j8' parallel build
config/Makefile:316: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR

Auto-detecting system features:

...                         dwarf: [ on  ]
...                         glibc: [ on  ]
...                          gtk2: [ on  ]
...                      libaudit: [ on  ]
...                        libbfd: [ on  ]
...                        libelf: [ on  ]
...                       libnuma: [ on  ]
...                       libperl: [ on  ]
...                     libpython: [ on  ]
...                      libslang: [ on  ]
...                     libunwind: [ on  ]

... libdw-dwarf-unwind: [ OFF ]
... DWARF post unwind library: libunwind

make[1]: *** No rule to make target /home/acme/git/linux/tools/lib/symbol/kallsyms.o', needed by /home/acme/git/build/perf/libperf.a'. Stop. make[1]: *** Waiting for unfinished jobs....
make: *** [install-bin] Error 2
make: Leaving directory `/home/acme/git/linux/tools/perf'

Quoted 7 lines

real 0m3.407s
user 0m2.434s
sys 0m0.819s
[acme@ssdandy linux]$

It builds ok if you do a build when CWD is tools/perf/, but who does that apart from Jiri? :-)

hehe.. so, is there something simpler than just typing 'make' ;-)

jirka

#16 lore raw
Quoted 2 lines · Jiri Olsa

yea, I meant it compiled for me ;-) I haven't reviewd the patch much, one thing I remember is that it should be separated into smaller changes..

This is because I created tools/lib/util/util.[ch] for the stuff which ctype.* needs. I guess I can split it even further if that is easier for you guys but I don't think the patch is too big to be unparseable - it is basically moving code to tools/lib/, adding its own Makefile and making the rest build again... well, almost. :-)

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--