Skip to contentSkip to conversation

perf tool: Carve out fs.* stuff

PATCH In review Borislav Petkov 4 participants 11 messages Dec 5, 2013 – Dec 9, 2013 perf events

lore
Share & tools
lore
#0 lore raw

cover perf tool: Carve out fs.* stuff

From: Borislav Petkov <[email protected]>

Ok,

step one: carve out fs-related stuff into a libapikfs.a library.

Borislav Petkov (2):
tools/: Convert to new topic libraries
perf: Move fs.* to lib/api/fs/

 tools/Makefile                                     | 12 ++++----
 tools/lib/{lk => api}/Makefile                     |  8 ++++--
 tools/lib/{lk => api/fs}/debugfs.c                 |  0
 tools/lib/{lk => api/fs}/debugfs.h                 |  6 ++--
 tools/{perf/util => lib/api/fs}/fs.c               | 11 ++++++--
 .../util/include/linux/magic.h => lib/api/fs/fs.h} | 12 ++++----
 tools/perf/Makefile.perf                           | 33 ++++++++++------------
 tools/perf/builtin-kvm.c                           |  2 +-
 tools/perf/builtin-probe.c                         |  2 +-
 tools/perf/perf.c                                  |  2 +-
 tools/perf/tests/parse-events.c                    |  4 +--
 tools/perf/util/cpumap.c                           |  2 +-
 tools/perf/util/evlist.c                           |  2 +-
 tools/perf/util/evsel.c                            |  2 +-
 tools/perf/util/fs.h                               |  7 -----
 tools/perf/util/parse-events.c                     |  2 +-
 tools/perf/util/pmu.c                              |  2 +-
 tools/perf/util/probe-event.c                      |  2 +-
 tools/perf/util/python-ext-sources                 |  2 +-
 tools/perf/util/record.c                           |  2 +-
 tools/perf/util/setup.py                           |  4 +--
 tools/perf/util/trace-event-info.c                 |  2 +-
 tools/perf/util/util.h                             |  2 +-
 tools/vm/Makefile                                  | 14 ++++-----
 tools/vm/page-types.c                              |  2 +-
 25 files changed, 67 insertions(+), 72 deletions(-)
 rename tools/lib/{lk => api}/Makefile (85%)
 rename tools/lib/{lk => api/fs}/debugfs.c (100%)
 rename tools/lib/{lk => api/fs}/debugfs.h (86%)
 rename tools/{perf/util => lib/api/fs}/fs.c (91%)
 rename tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} (50%)
 delete mode 100644 tools/perf/util/fs.h
Signature · 1 line
1.8.4
#1 lore raw

PATCH 1/2 tools/: Convert to new topic libraries

From: Borislav Petkov <[email protected]>

Move debugfs.* to api/fs/. We have a common tools/lib/api/ place where the Makefile lives and then we place the headers in subdirs. For example, all the fs-related stuff goes to tools/lib/api/fs/ from which we get libapikfs.a (acme got almost the naming he wanted :-)) and we link it into the tools which need it - in this case perf and tools/vm/page-types.

acme:

"Looking at the implementation, I think some tools can even link directly to the .o files, avoiding the .a file altogether.

But that is just an optimization/finer granularity tools/lib/ cherrypicking that toolers can make use of."

Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/Makefile                     | 12 ++++++------
 tools/lib/{lk => api}/Makefile     |  6 +++---
 tools/lib/{lk => api/fs}/debugfs.c |  0
 tools/lib/{lk => api/fs}/debugfs.h |  6 +++---
 tools/perf/Makefile.perf           | 30 +++++++++++++++---------------
 tools/perf/builtin-kvm.c           |  2 +-
 tools/perf/builtin-probe.c         |  2 +-
 tools/perf/perf.c                  |  2 +-
 tools/perf/tests/parse-events.c    |  2 +-
 tools/perf/util/evlist.c           |  2 +-
 tools/perf/util/evsel.c            |  2 +-
 tools/perf/util/parse-events.c     |  2 +-
 tools/perf/util/probe-event.c      |  2 +-
 tools/perf/util/setup.py           |  4 ++--
 tools/perf/util/trace-event-info.c |  2 +-
 tools/perf/util/util.h             |  2 +-
 tools/vm/Makefile                  | 14 +++++++-------
 tools/vm/page-types.c              |  2 +-
 18 files changed, 47 insertions(+), 47 deletions(-)
 rename tools/lib/{lk => api}/Makefile (90%)
 rename tools/lib/{lk => api/fs}/debugfs.c (100%)
 rename tools/lib/{lk => api/fs}/debugfs.h (86%)
tools/Makefile +6 -6
index a9b02008443c..927cd46d36dc 100644
@@ -39,10 +39,10 @@ cpupower: FORCE
 cgroup firewire guest usb virtio vm net: FORCE
 	$(call descend,$@)
 
-liblk: FORCE
-	$(call descend,lib/lk)
+libapikfs: FORCE
+	$(call descend,lib/api)
 
-perf: liblk FORCE
+perf: libapikfs FORCE
 	$(call descend,$@)
 
 selftests: FORCE
@@ -80,10 +80,10 @@ cpupower_clean:
 cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean:
 	$(call descend,$(@:_clean=),clean)
 
-liblk_clean:
-	$(call descend,lib/lk,clean)
+libapikfs_clean:
+	$(call descend,lib/api,clean)
 
-perf_clean: liblk_clean
+perf_clean: libapikfs_clean
 	$(call descend,$(@:_clean=),clean)
 
 selftests_clean:
tools/lib/api/Makefile renamed from tools/lib/lk/Makefile +3 -3
similarity index 90%
rename from tools/lib/lk/Makefile
rename to tools/lib/api/Makefile
index 3dba0a4aebbf..d749cdc8e1d4 100644
@@ -7,11 +7,11 @@ AR = $(CROSS_COMPILE)ar
 LIB_H=
 LIB_OBJS=
 
-LIB_H += debugfs.h
+LIB_H += fs/debugfs.h
 
-LIB_OBJS += $(OUTPUT)debugfs.o
+LIB_OBJS += $(OUTPUT)fs/debugfs.o
 
-LIBFILE = liblk.a
+LIBFILE = libapikfs.a
 
 CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
 EXTLIBS = -lelf -lpthread -lrt -lm
tools/lib/api/fs/debugfs.c renamed from tools/lib/lk/debugfs.c +0 -0
similarity index 100%
rename from tools/lib/lk/debugfs.c
rename to tools/lib/api/fs/debugfs.c
tools/lib/api/fs/debugfs.h renamed from tools/lib/lk/debugfs.h +3 -3
similarity index 86%
rename from tools/lib/lk/debugfs.h
rename to tools/lib/api/fs/debugfs.h
index 935c59bdb442..f19d3df9609d 100644
@@ -1,5 +1,5 @@
-#ifndef __LK_DEBUGFS_H__
-#define __LK_DEBUGFS_H__
+#ifndef __API_DEBUGFS_H__
+#define __API_DEBUGFS_H__
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
@@ -26,4 +26,4 @@ char *debugfs_mount(const char *mountpoint);
 
 extern char debugfs_mountpoint[];
 
-#endif /* __LK_DEBUGFS_H__ */
+#endif /* __API_DEBUGFS_H__ */
tools/perf/Makefile.perf +15 -15
index ca3b87d5389a..71d84811132c 100644
@@ -86,7 +86,7 @@ FLEX    = flex
 BISON   = bison
 STRIP   = strip
 
-LK_DIR          = $(srctree)/tools/lib/lk/
+LIB_DIR          = $(srctree)/tools/lib/api/
 TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
 
 # include config/Makefile by default and rule out
@@ -127,20 +127,20 @@ strip-libs = $(filter-out -l%,$(1))
 ifneq ($(OUTPUT),)
   TE_PATH=$(OUTPUT)
 ifneq ($(subdir),)
-  LK_PATH=$(OUTPUT)/../lib/lk/
+  LIB_PATH=$(OUTPUT)/../lib/api/
 else
-  LK_PATH=$(OUTPUT)
+  LIB_PATH=$(OUTPUT)
 endif
 else
   TE_PATH=$(TRACE_EVENT_DIR)
-  LK_PATH=$(LK_DIR)
+  LIB_PATH=$(LIB_DIR)
 endif
 
 LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
 export LIBTRACEEVENT
 
-LIBLK = $(LK_PATH)liblk.a
-export LIBLK
+LIBAPIKFS = $(LIB_PATH)libapikfs.a
+export LIBAPIKFS
 
 # python extension build directories
 PYTHON_EXTBUILD     := $(OUTPUT)python_ext_build/
@@ -151,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) $(LIBLK)
+PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPIKFS)
 
 $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
 	$(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
@@ -439,7 +439,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
 BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o
 BUILTIN_OBJS += $(OUTPUT)builtin-mem.o
 
-PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT)
+PERFLIBS = $(LIB_FILE) $(LIBAPIKFS) $(LIBTRACEEVENT)
 
 # We choose to avoid "if .. else if .. else .. endif endif"
 # because maintaining the nesting to match is a pain.  If
@@ -725,19 +725,19 @@ $(LIBTRACEEVENT)-clean:
 install-traceevent-plugins:
 	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) install_plugins
 
-LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
+LIBAPIKFS_SOURCES = $(wildcard $(LIB_PATH)fs/*.[ch])
 
 # if subdir is set, we've been called from above so target has been built
 # already
-$(LIBLK): $(LIBLK_SOURCES)
+$(LIBAPIKFS): $(LIBAPIKFS_SOURCES)
 ifeq ($(subdir),)
-	$(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a
+	$(QUIET_SUBDIR0)$(LIB_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libapikfs.a
 endif
 
-$(LIBLK)-clean:
+$(LIBAPIKFS)-clean:
 ifeq ($(subdir),)
-	$(call QUIET_CLEAN, liblk)
-	@$(MAKE) -C $(LK_DIR) O=$(OUTPUT) clean >/dev/null
+	$(call QUIET_CLEAN, LIBAPIKFS)
+	@$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
 endif
 
 help:
@@ -876,7 +876,7 @@ config-clean:
 	$(call QUIET_CLEAN, config)
 	@$(MAKE) -C config/feature-checks clean >/dev/null
 
-clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean config-clean
+clean: $(LIBTRACEEVENT)-clean $(LIBAPIKFS)-clean config-clean
 	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) $(GTK_OBJS)
 	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf
 	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
tools/perf/builtin-kvm.c +1 -1
index f8bf5f244d77..252b6ed507b7 100644
@@ -13,7 +13,7 @@
 #include "util/parse-options.h"
 #include "util/trace-event.h"
 #include "util/debug.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include "util/tool.h"
 #include "util/stat.h"
 #include "util/top.h"
tools/perf/builtin-probe.c +1 -1
index 6ea9e85bdc00..c98ccb570509 100644
@@ -37,7 +37,7 @@
 #include "util/strfilter.h"
 #include "util/symbol.h"
 #include "util/debug.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include "util/parse-options.h"
 #include "util/probe-finder.h"
 #include "util/probe-event.h"
tools/perf/perf.c +1 -1
index 8b38b4e80ec2..431798a4110d 100644
@@ -13,7 +13,7 @@
 #include "util/quote.h"
 #include "util/run-command.h"
 #include "util/parse-events.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include <pthread.h>
 
 const char perf_usage_string[] =
tools/perf/tests/parse-events.c +1 -1
index 3cbd10496087..e4ce8aed29d3 100644
@@ -3,7 +3,7 @@
 #include "evsel.h"
 #include "evlist.h"
 #include "fs.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include "tests.h"
 #include <linux/hw_breakpoint.h>
 
tools/perf/util/evlist.c +1 -1
index 7bb6ee1ca19f..8bb4eabca118 100644
@@ -7,7 +7,7 @@
  * Released under the GPL v2. (and only v2, not any later version)
  */
 #include "util.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include <poll.h>
 #include "cpumap.h"
 #include "thread_map.h"
tools/perf/util/evsel.c +1 -1
index 7b510fd1f08d..01ff4cfde1f5 100644
@@ -9,7 +9,7 @@
 
 #include <byteswap.h>
 #include <linux/bitops.h>
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include <traceevent/event-parse.h>
 #include <linux/hw_breakpoint.h>
 #include <linux/perf_event.h>
tools/perf/util/parse-events.c +1 -1
index 969cb8f0d88d..094c28ba2fae 100644
@@ -10,7 +10,7 @@
 #include "symbol.h"
 #include "cache.h"
 #include "header.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include "parse-events-bison.h"
 #define YY_EXTRA_TYPE int
 #include "parse-events-flex.h"
tools/perf/util/probe-event.c +1 -1
index 9c6989ca2bea..8cd98ef628be 100644
@@ -40,7 +40,7 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include "trace-event.h"	/* For __maybe_unused */
 #include "probe-event.h"
 #include "probe-finder.h"
tools/perf/util/setup.py +2 -2
index 58ea5ca6c255..d0aee4b9dfd4 100644
@@ -25,7 +25,7 @@ cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter'
 build_lib = getenv('PYTHON_EXTBUILD_LIB')
 build_tmp = getenv('PYTHON_EXTBUILD_TMP')
 libtraceevent = getenv('LIBTRACEEVENT')
-liblk = getenv('LIBLK')
+libapikfs = getenv('LIBAPIKFS')
 
 ext_sources = [f.strip() for f in file('util/python-ext-sources')
 				if len(f.strip()) > 0 and f[0] != '#']
@@ -34,7 +34,7 @@ perf = Extension('perf',
 		  sources = ext_sources,
 		  include_dirs = ['util/include'],
 		  extra_compile_args = cflags,
-		  extra_objects = [libtraceevent, liblk],
+		  extra_objects = [libtraceevent, libapikfs],
                  )
 
 setup(name='perf',
tools/perf/util/trace-event-info.c +1 -1
index f3c9e551bd35..c354b95a2348 100644
@@ -38,7 +38,7 @@
 
 #include "../perf.h"
 #include "trace-event.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include "evsel.h"
 
 #define VERSION "0.5"
tools/perf/util/util.h +1 -1
index adb39f251f90..4dc21c8e87b0 100644
@@ -71,7 +71,7 @@
 #include <linux/magic.h>
 #include "types.h"
 #include <sys/ttydefaults.h>
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 #include <termios.h>
 
 extern const char *graph_line;
tools/vm/Makefile +7 -7
index 24e9ddd93fa4..3d907dacf2ac 100644
@@ -2,21 +2,21 @@
 #
 TARGETS=page-types slabinfo
 
-LK_DIR = ../lib/lk
-LIBLK = $(LK_DIR)/liblk.a
+LIB_DIR = ../lib/api
+LIBS = $(LIB_DIR)/libapikfs.a
 
 CC = $(CROSS_COMPILE)gcc
 CFLAGS = -Wall -Wextra -I../lib/
-LDFLAGS = $(LIBLK)
+LDFLAGS = $(LIBS)
 
-$(TARGETS): liblk
+$(TARGETS): $(LIBS)
 
-liblk:
-	make -C $(LK_DIR)
+$(LIBS):
+	make -C $(LIB_DIR)
 
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
 
 clean:
 	$(RM) page-types slabinfo
-	make -C ../lib/lk clean
+	make -C $(LIB_DIR) clean
tools/vm/page-types.c +1 -1
index d5e9d6d185c8..f9be24d9efac 100644
@@ -36,7 +36,7 @@
 #include <sys/statfs.h>
 #include "../../include/uapi/linux/magic.h"
 #include "../../include/uapi/linux/kernel-page-flags.h"
-#include <lk/debugfs.h>
+#include <api/fs/debugfs.h>
 
 #ifndef MAX_PATH
 # define MAX_PATH 256
Signature · 1 line
1.8.4
#2 lore raw

Re: [PATCH 1/2] tools/: Convert to new topic libraries

Quoted 1 line · Borislav Petkov

From: Borislav Petkov <[email protected]>

SNIP

Quoted 10 lines
tools/perf/Makefile.perf +2 -2
 	$(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) install_plugins
 
-LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
+LIBAPIKFS_SOURCES = $(wildcard $(LIB_PATH)fs/*.[ch])
 
 # if subdir is set, we've been called from above so target has been built
 # already
-$(LIBLK): $(LIBLK_SOURCES)
+$(LIBAPIKFS): $(LIBAPIKFS_SOURCES)
 ifeq ($(subdir),)

tools/perf/Makefile.perf $(LIBTRACEEVENT)-clean: · line 739

Quoted 10 lines
tools/perf/Makefile.perf +3 -4
-	$(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a
+	$(QUIET_SUBDIR0)$(LIB_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libapikfs.a
 endif
 
-$(LIBLK)-clean:
+$(LIBAPIKFS)-clean:
 ifeq ($(subdir),)
-	$(call QUIET_CLEAN, liblk)
-	@$(MAKE) -C $(LK_DIR) O=$(OUTPUT) clean >/dev/null
+	$(call QUIET_CLEAN, LIBAPIKFS)

do we want 'LIBAPIKFS' in lowercase here?

jirka

#3 lore raw

Re: [PATCH 1/2] tools/: Convert to new topic libraries

Quoted 8 lines · Jiri Olsa

tools/perf/Makefile.perf $(LIBTRACEEVENT)-clean: · line 739

Quoted 6 lines

-$(LIBLK)-clean:
+$(LIBAPIKFS)-clean:
ifeq ($(subdir),)

tools/perf/Makefile.perf +1 -2
-	$(call QUIET_CLEAN, liblk)
-	@$(MAKE) -C $(LK_DIR) O=$(OUTPUT) clean >/dev/null
+	$(call QUIET_CLEAN, LIBAPIKFS)

do we want 'LIBAPIKFS' in lowercase here?

We do!

... aaand

[what was the vim shortcut... /me looks, finds it, executes it]

done.

:-)

Signature · 5 lines
Regards/Gruss,
    Boris.

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

PATCH 2/2 tools/: Move fs.* to lib/api/fs/

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Move to generic library and kill magic.h as it is needed only in fs.h.

---
 tools/lib/api/Makefile                                     |  2 ++
 tools/{perf/util => lib/api/fs}/fs.c                       | 11 ++++++++---
 tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} | 12 +++++-------
 tools/perf/Makefile.perf                                   |  3 ---
 tools/perf/tests/parse-events.c                            |  2 +-
 tools/perf/util/cpumap.c                                   |  2 +-
 tools/perf/util/fs.h                                       |  7 -------
 tools/perf/util/pmu.c                                      |  2 +-
 tools/perf/util/python-ext-sources                         |  2 +-
 tools/perf/util/record.c                                   |  2 +-
 10 files changed, 20 insertions(+), 25 deletions(-)
 rename tools/{perf/util => lib/api/fs}/fs.c (91%)
 rename tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} (50%)
 delete mode 100644 tools/perf/util/fs.h
tools/lib/api/Makefile +2 -0
index d749cdc8e1d4..2a354292d781 100644
@@ -8,8 +8,10 @@ LIB_H=
 LIB_OBJS=
 
 LIB_H += fs/debugfs.h
+LIB_H += fs/fs.h
 
 LIB_OBJS += $(OUTPUT)fs/debugfs.o
+LIB_OBJS += $(OUTPUT)fs/fs.o
 
 LIBFILE = libapikfs.a
 
tools/lib/api/fs/fs.c renamed from tools/perf/util/fs.c +8 -3
similarity index 91%
rename from tools/perf/util/fs.c
rename to tools/lib/api/fs/fs.c
index f5be1f26e724..ff8907275cfb 100644
@@ -1,8 +1,13 @@
+/* TODO merge/factor into debugfs.c */
 
-/* TODO merge/factor into tools/lib/lk/debugfs.c */
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/vfs.h>
 
-#include "util.h"
-#include "util/fs.h"
+#include "debugfs.h"
+#include "fs.h"
 
 static const char * const sysfs__fs_known_mountpoints[] = {
 	"/sys",
tools/lib/api/fs/fs.h renamed from tools/perf/util/include/linux/magic.h +5 -7
similarity index 50%
rename from tools/perf/util/include/linux/magic.h
rename to tools/lib/api/fs/fs.h
index 07d63cf3e0f6..cb7049551f33 100644
@@ -1,9 +1,5 @@
-#ifndef _PERF_LINUX_MAGIC_H_
-#define _PERF_LINUX_MAGIC_H_
-
-#ifndef DEBUGFS_MAGIC
-#define DEBUGFS_MAGIC          0x64626720
-#endif
+#ifndef __API_FS__
+#define __API_FS__
 
 #ifndef SYSFS_MAGIC
 #define SYSFS_MAGIC            0x62656572
@@ -13,4 +9,6 @@
 #define PROC_SUPER_MAGIC       0x9fa0
 #endif
 
-#endif
+const char *sysfs__mountpoint(void);
+const char *procfs__mountpoint(void);
+#endif /* __API_FS__ */
tools/perf/Makefile.perf +0 -3
index 71d84811132c..77c353a32677 100644
@@ -216,7 +216,6 @@ 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/export.h
-LIB_H += util/include/linux/magic.h
 LIB_H += util/include/linux/poison.h
 LIB_H += util/include/linux/prefetch.h
 LIB_H += util/include/linux/rbtree.h
@@ -242,7 +241,6 @@ LIB_H += util/cache.h
 LIB_H += util/callchain.h
 LIB_H += util/build-id.h
 LIB_H += util/debug.h
-LIB_H += util/fs.h
 LIB_H += util/pmu.h
 LIB_H += util/event.h
 LIB_H += util/evsel.h
@@ -304,7 +302,6 @@ 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/fs.o
 LIB_OBJS += $(OUTPUT)util/pmu.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
tools/perf/tests/parse-events.c +1 -1
index e4ce8aed29d3..6109150d36cc 100644
@@ -2,7 +2,7 @@
 #include "parse-events.h"
 #include "evsel.h"
 #include "evlist.h"
-#include "fs.h"
+#include <api/fs/fs.h>
 #include <api/fs/debugfs.h>
 #include "tests.h"
 #include <linux/hw_breakpoint.h>
tools/perf/util/cpumap.c +1 -1
index a9b48c42e81e..7fe4994eeb63 100644
@@ -1,5 +1,5 @@
 #include "util.h"
-#include "fs.h"
+#include <api/fs/fs.h>
 #include "../perf.h"
 #include "cpumap.h"
 #include <assert.h>
tools/perf/util/fs.h deleted +0 -7
deleted file mode 100644
index 5e09ce1bab0e..000000000000
@@ -1,7 +0,0 @@
-#ifndef __PERF_FS
-#define __PERF_FS
-
-const char *sysfs__mountpoint(void);
-const char *procfs__mountpoint(void);
-
-#endif /* __PERF_FS */
tools/perf/util/pmu.c +1 -1
index 56fc10a5e288..b22d2447550f 100644
@@ -3,7 +3,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <dirent.h>
-#include "fs.h"
+#include <api/fs/fs.h>
 #include <locale.h>
 #include "util.h"
 #include "pmu.h"
tools/perf/util/python-ext-sources +1 -1
index 595bfc73d2ed..16a475a7d492 100644
@@ -17,6 +17,6 @@ util/xyarray.c
 util/cgroup.c
 util/rblist.c
 util/strlist.c
-util/fs.c
+../lib/api/fs/fs.c
 util/trace-event.c
 ../../lib/rbtree.c
tools/perf/util/record.c +1 -1
index c8845b107f60..da4113679ae5 100644
@@ -2,7 +2,7 @@
 #include "evsel.h"
 #include "cpumap.h"
 #include "parse-events.h"
-#include "fs.h"
+#include <api/fs/fs.h>
 #include "util.h"
 
 typedef void (*setup_probe_fn_t)(struct perf_evsel *evsel);
Signature · 1 line
1.8.4
#5 lore raw

Re: [PATCH 2/2] tools/: Move fs.* to lib/api/fs/

Quoted 44 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Move to generic library and kill magic.h as it is needed only in fs.h.

---
 tools/lib/api/Makefile                                     |  2 ++
 tools/{perf/util => lib/api/fs}/fs.c                       | 11 ++++++++---
 tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} | 12 +++++-------
 tools/perf/Makefile.perf                                   |  3 ---
 tools/perf/tests/parse-events.c                            |  2 +-
 tools/perf/util/cpumap.c                                   |  2 +-
 tools/perf/util/fs.h                                       |  7 -------
 tools/perf/util/pmu.c                                      |  2 +-
 tools/perf/util/python-ext-sources                         |  2 +-
 tools/perf/util/record.c                                   |  2 +-
 10 files changed, 20 insertions(+), 25 deletions(-)
 rename tools/{perf/util => lib/api/fs}/fs.c (91%)
 rename tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} (50%)
 delete mode 100644 tools/perf/util/fs.h
tools/lib/api/Makefile +2 -0
index d749cdc8e1d4..2a354292d781 100644
@@ -8,8 +8,10 @@ LIB_H=
 LIB_OBJS=
 
 LIB_H += fs/debugfs.h
+LIB_H += fs/fs.h
 
 LIB_OBJS += $(OUTPUT)fs/debugfs.o
+LIB_OBJS += $(OUTPUT)fs/fs.o
 
 LIBFILE = libapikfs.a
 
tools/lib/api/fs/fs.c renamed from tools/perf/util/fs.c +0 -0
similarity index 91%
rename from tools/perf/util/fs.c
rename to tools/lib/api/fs/fs.c
index f5be1f26e724..ff8907275cfb 100644

tools/lib/api/fs/fs.c line 1

Quoted 1 line
tools/lib/api/fs/fs.c renamed from tools/perf/util/fs.c +1 -0
@@ -1,8 +1,13 @@
+/* TODO merge/factor into debugfs.c */

I guess now above one should be:

TODO merge/factor debugfs object in here

;-)

jirka

#6 lore raw

Re: [PATCH 2/2] tools/: Move fs.* to lib/api/fs/

Quoted 8 lines · Jiri Olsa

tools/lib/api/fs/fs.c line 1

Quoted 2 lines
tools/lib/api/fs/fs.c renamed from tools/perf/util/fs.c +1 -0
@@ -1,8 +1,13 @@
+/* TODO merge/factor into debugfs.c */

I guess now above one should be:

TODO merge/factor debugfs object in here

;-)

Right, done!

Thanks guys, I'll resend soonish.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#7 lore raw
In reply to Borislav Petkov

Sorry, some editing problem happened here... Now with proper subject line.

- Arnaldo

Em Thu, Dec 05, 2013 at 05:25:50PM +0100, Borislav Petkov escreveu:

Quoted 5 lines

From: Borislav Petkov <[email protected]>

Ok,

step one: carve out fs-related stuff into a libapikfs.a library.

Adding some more people to the CC list, but from a quick look, this is in line with what we discussed so far, so I'm ok with it.

For those people in the CC list, Acked-by would be really, really appreciated.

- Arnaldo

Quoted 39 lines

Borislav Petkov (2):
tools/: Convert to new topic libraries
perf: Move fs.* to lib/api/fs/

 tools/Makefile                                     | 12 ++++----
 tools/lib/{lk => api}/Makefile                     |  8 ++++--
 tools/lib/{lk => api/fs}/debugfs.c                 |  0
 tools/lib/{lk => api/fs}/debugfs.h                 |  6 ++--
 tools/{perf/util => lib/api/fs}/fs.c               | 11 ++++++--
 .../util/include/linux/magic.h => lib/api/fs/fs.h} | 12 ++++----
 tools/perf/Makefile.perf                           | 33 ++++++++++------------
 tools/perf/builtin-kvm.c                           |  2 +-
 tools/perf/builtin-probe.c                         |  2 +-
 tools/perf/perf.c                                  |  2 +-
 tools/perf/tests/parse-events.c                    |  4 +--
 tools/perf/util/cpumap.c                           |  2 +-
 tools/perf/util/evlist.c                           |  2 +-
 tools/perf/util/evsel.c                            |  2 +-
 tools/perf/util/fs.h                               |  7 -----
 tools/perf/util/parse-events.c                     |  2 +-
 tools/perf/util/pmu.c                              |  2 +-
 tools/perf/util/probe-event.c                      |  2 +-
 tools/perf/util/python-ext-sources                 |  2 +-
 tools/perf/util/record.c                           |  2 +-
 tools/perf/util/setup.py                           |  4 +--
 tools/perf/util/trace-event-info.c                 |  2 +-
 tools/perf/util/util.h                             |  2 +-
 tools/vm/Makefile                                  | 14 ++++-----
 tools/vm/page-types.c                              |  2 +-
 25 files changed, 67 insertions(+), 72 deletions(-)
 rename tools/lib/{lk => api}/Makefile (85%)
 rename tools/lib/{lk => api/fs}/debugfs.c (100%)
 rename tools/lib/{lk => api/fs}/debugfs.h (86%)
 rename tools/{perf/util => lib/api/fs}/fs.c (91%)
 rename tools/{perf/util/include/linux/magic.h => lib/api/fs/fs.h} (50%)
 delete mode 100644 tools/perf/util/fs.h
Signature · 1 line
1.8.4
#8 lore raw
Quoted 10 lines · Arnaldo Carvalho de Melo

Sorry, some editing problem happened here... Now with proper subject line.

- Arnaldo

Em Thu, Dec 05, 2013 at 05:25:50PM +0100, Borislav Petkov escreveu:

Quoted 4 lines

From: Borislav Petkov <[email protected]>

Ok,

Quoted 7 lines
Quoted 1 line

step one: carve out fs-related stuff into a libapikfs.a library.

Adding some more people to the CC list, but from a quick look, this is in line with what we discussed so far, so I'm ok with it.

For those people in the CC list, Acked-by would be really, really appreciated.

Something is missing. From tools/perf:

$ make O=/tmp/perf

Assembler messages:
Fatal error: can't create /tmp/perf/fs/fs.o: No such file or directory make[2]: *** [/tmp/perf/fs/fs.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CC /tmp/perf/bench/mem-memcpy.o
Assembler messages:
Fatal error: can't create /tmp/perf/fs/debugfs.o: No such file or directory make[2]: *** [/tmp/perf/fs/debugfs.o] Error 1
make[1]: *** [/tmp/perf/libapikfs.a] Error 2
make[1]: *** Waiting for unfinished jobs....

David

#9 lore raw
Quoted 6 lines · David Ahern

Something is missing. From tools/perf:

$ make O=/tmp/perf

Assembler messages:
Fatal error: can't create /tmp/perf/fs/fs.o: No such file or directory

That's because we have the sublibs in subdirs now :-\. That should take care of it:

--

tools/lib/api/Makefile +8 -4
index 2a354292d781..ce00f7ee6455 100644
@@ -1,4 +1,5 @@
 include ../../scripts/Makefile.include
+include ../../perf/config/utilities.mak		# QUIET_CLEAN
 
 CC = $(CROSS_COMPILE)gcc
 AR = $(CROSS_COMPILE)ar
@@ -27,14 +28,17 @@ $(LIBFILE): $(LIB_OBJS)
 
 $(LIB_OBJS): $(LIB_H)
 
-$(OUTPUT)%.o: %.c
+libapi_dirs:
+	$(QUIET_MKDIR)mkdir -p $(OUTPUT)fs/
+
+$(OUTPUT)%.o: %.c libapi_dirs
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
-$(OUTPUT)%.s: %.c
+$(OUTPUT)%.s: %.c libapi_dirs
 	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
-$(OUTPUT)%.o: %.S
+$(OUTPUT)%.o: %.S libapi_dirs
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
 
 clean:
-	$(RM) $(LIB_OBJS) $(LIBFILE)
+	$(call QUIET_CLEAN, libapi) $(RM) $(LIB_OBJS) $(LIBFILE)
 
 .PHONY: clean
Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#10 lore raw
In reply to Borislav Petkov
Quoted 6 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Ok,

step one: carve out fs-related stuff into a libapikfs.a library.

got similar failure as David by runnning 'make -f tests/make'

[jolsa@krava perf]$ make -f tests/make
- make_pure: cd . && make -f Makefile DESTDIR=/tmp/tmp.nIVqbIKxHQ

SNIP

- make_pure_O: cd . && make -f Makefile O=/tmp/tmp.CoL1PmqBBQ DESTDIR=/tmp/tmp.tpMfXhJGov
make: *** [make_pure_O] Error 1

[jolsa@krava perf]$ cat make_pure_O
cd . && make -f Makefile O=/tmp/tmp.CoL1PmqBBQ DESTDIR=/tmp/tmp.tpMfXhJGov
BUILD: Doing 'make -j4' parallel build

Auto-detecting system features:
... backtrace: [ on ]
... dwarf: [ on ]

SNIP

  CC       /tmp/tmp.CoL1PmqBBQ/scripts/python/Perf-Trace-Util/Context.o
  SUBDIR   /home/jolsa/kernel.org/linux-test/tools/lib/api/
  CC       /tmp/tmp.CoL1PmqBBQ/fs/debugfs.o
  SUBDIR   /home/jolsa/kernel.org/linux-test/tools/lib/traceevent/
  FLAGS:   * new build flags or cross compiler

Assembler messages:
Fatal error: can't create /tmp/tmp.CoL1PmqBBQ/fs/debugfs.o: No such file or directory make[3]: *** [/tmp/tmp.CoL1PmqBBQ/fs/debugfs.o] Error 1
make[2]: *** [/tmp/tmp.CoL1PmqBBQ/libapikfs.a] Error 2
make[2]: *** Waiting for unfinished jobs....

  CC FPIC  event-parse.o
  CC FPIC  event-plugin.o
  CC FPIC  trace-seq.o
  CC FPIC  parse-filter.o

SNIP

BUILD PLUGIN plugin_cfg80211.so
BUILD STATIC LIB libtraceevent.a
make[3]: Nothing to be done for `plugins'.
make[1]: *** [all] Error 2

jirka