Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 21 messages Mar 21, 2015 – Mar 22, 2015 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling, this is on top of my previous pull request,

Thanks,

- Arnaldo

The following changes since commit 0c8c20779c5d56b93b8cb4cd30ba129a927ab437:

perf report: Don't allow empty argument for '-t'. (2015-03-19 13:53:28 -0300)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-2

for you to fetch changes up to ca33380adf74afb985bf7aab09ec46707a5d2d57:

perf tools: Use kmod_path__parse for machine__new_dso (2015-03-21 14:58:07 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

- Handle legacy syscalls tracepoints (David Ahern, Arnaldo Carvalho de Melo)

- Indicate which callchain entries are annotated in the TUI hists browser (report/top) (Arnaldo Carvalho de Melo)

- Fix failure to add multiple probes without debuginfo (He Kuang)

- Fix 'trace' summary_only option (David Ahern)

- Fix race in build_id_cache__add_s() in 'buildid-cache' (Milos Vyletel)

- Don't allow empty argument for field-separator, fixing segfault (Wang Nan)

Infrastructure:

- Add destructor for format_field in libtraceevent (David Ahern)

- Prep work for support lzma compressed kernel modules (Jiri Olsa)

- Update .gitignore with recently added/renamed feature detection files (Yunlong Song)

----------------------------------------------------------------
Arnaldo Carvalho de Melo (2):
perf trace: Handle legacy syscalls tracepoints
perf hists browser: Indicate which callchain entries are annotated

David Ahern (2):
perf trace: Fix summary_only option
tools lib traceevent: Add destructor for format_field

He Kuang (1):
perf probe: Fix failure to add multiple probes without debuginfo

Jiri Olsa (10):
perf build: Fix feature_check name clash
perf build: Separate feature make support into config/Makefile.feature perf build: Make features checks directory configurable perf build: Move feature checks code under tools/build tools build: Add feature check for lzma library
perf tools: Add lzma decompression support for kernel module perf tools: Add kmod_path__parse function
perf tools: Add dsos__addnew function
perf tools: Add machine__module_dso function
perf tools: Use kmod_path__parse for machine__new_dso

Milos Vyletel (1):
perf tools: Fix race in build_id_cache__add_s()

Wang Nan (1):
perf tools: Don't allow empty argument for field-separator

Yunlong Song (2):
perf build: Use FEATURE-DUMP instead of PERF-FEATURES in the .gitignore file perf build: Add config/feature-checks/*.output to the .gitignore file

 tools/build/Makefile.feature                       | 171 ++++++++++++++++++++
 .../feature-checks => build/feature}/.gitignore    |   1 +
 .../feature-checks => build/feature}/Makefile      |   8 +-
 .../feature-checks => build/feature}/test-all.c    |   5 +
 .../feature}/test-backtrace.c                      |   0
 .../feature-checks => build/feature}/test-bionic.c |   0
 .../feature}/test-compile.c                        |   0
 .../feature}/test-cplus-demangle.c                 |   0
 .../feature-checks => build/feature}/test-dwarf.c  |   0
 .../feature}/test-fortify-source.c                 |   0
 .../feature-checks => build/feature}/test-glibc.c  |   0
 .../feature}/test-gtk2-infobar.c                   |   0
 .../feature-checks => build/feature}/test-gtk2.c   |   0
 .../feature-checks => build/feature}/test-hello.c  |   0
 .../feature}/test-libaudit.c                       |   0
 .../feature}/test-libbabeltrace.c                  |   0
 .../feature-checks => build/feature}/test-libbfd.c |   0
 .../feature}/test-libdw-dwarf-unwind.c             |   0
 .../feature}/test-libelf-getphdrnum.c              |   0
 .../feature}/test-libelf-mmap.c                    |   0
 .../feature-checks => build/feature}/test-libelf.c |   0
 .../feature}/test-libnuma.c                        |   0
 .../feature}/test-libperl.c                        |   0
 .../feature}/test-libpython-version.c              |   0
 .../feature}/test-libpython.c                      |   0
 .../feature}/test-libslang.c                       |   0
 .../feature}/test-libunwind-debug-frame.c          |   0
 .../feature}/test-libunwind.c                      |   0
 tools/build/feature/test-lzma.c                    |  10 ++
 .../feature}/test-pthread-attr-setaffinity-np.c    |   0
 .../feature}/test-stackprotector-all.c             |   0
 .../feature}/test-sync-compare-and-swap.c          |   0
 .../feature}/test-timerfd.c                        |   0
 .../feature-checks => build/feature}/test-zlib.c   |   0
 tools/lib/traceevent/event-parse.c                 |  11 +-
 tools/lib/traceevent/event-parse.h                 |   1 +
 tools/perf/.gitignore                              |   2 +-
 tools/perf/Makefile.perf                           |   4 +-
 tools/perf/builtin-diff.c                          |   2 +-
 tools/perf/builtin-mem.c                           |   2 +-
 tools/perf/builtin-trace.c                         |  21 ++-
 tools/perf/config/Makefile                         | 176 ++-------------------
 tools/perf/tests/Build                             |   1 +
 tools/perf/tests/builtin-test.c                    |   4 +
 tools/perf/tests/kmod-path.c                       |  73 +++++++++
 tools/perf/tests/tests.h                           |   1 +
 tools/perf/ui/browsers/hists.c                     |   4 +-
 tools/perf/util/Build                              |   1 +
 tools/perf/util/build-id.c                         |   3 +-
 tools/perf/util/dso.c                              |  90 +++++++++--
 tools/perf/util/dso.h                              |  15 ++
 tools/perf/util/lzma.c                             |  95 +++++++++++
 tools/perf/util/machine.c                          |  83 +++++-----
 tools/perf/util/probe-event.c                      |   4 +-
 tools/perf/util/util.h                             |   4 +
 55 files changed, 557 insertions(+), 235 deletions(-)
 create mode 100644 tools/build/Makefile.feature
 rename tools/{perf/config/feature-checks => build/feature}/.gitignore (52%)
 rename tools/{perf/config/feature-checks => build/feature}/Makefile (96%)
 rename tools/{perf/config/feature-checks => build/feature}/test-all.c (97%)
 rename tools/{perf/config/feature-checks => build/feature}/test-backtrace.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-bionic.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-compile.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-cplus-demangle.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-dwarf.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-fortify-source.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-glibc.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-gtk2-infobar.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-gtk2.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-hello.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libaudit.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libbabeltrace.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libbfd.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libdw-dwarf-unwind.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf-getphdrnum.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf-mmap.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libnuma.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libperl.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libpython-version.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libpython.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libslang.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libunwind-debug-frame.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libunwind.c (100%)
 create mode 100644 tools/build/feature/test-lzma.c
 rename tools/{perf/config/feature-checks => build/feature}/test-pthread-attr-setaffinity-np.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-stackprotector-all.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-sync-compare-and-swap.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-timerfd.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-zlib.c (100%)
 create mode 100644 tools/perf/tests/kmod-path.c
 create mode 100644 tools/perf/util/lzma.c
author maintainer
#1 lore raw

PATCH 1/19 perf tools: Fix race in build_id_cache__add_s()

From: Milos Vyletel <[email protected]>

int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms, bool is_vdso)
{
...

        if (access(filename, F_OK)) {
               ^--------------------------------------------------------- [1]
                if (is_kallsyms) {
                         if (copyfile("/proc/kallsyms", filename))
                                goto out_free;
                } else if (link(realname, filename) && copyfile(name, filename))
                             ^-----------------------------^------------- [2]
                                                            \------------ [3]
                        goto out_free;
        }

...

When multiple instances of perf record get to [1] at more or less same time and run access() one or more may get failure because the file does not exist yet (since the first instance did not have chance to link it yet).

At this point the race moves to link() at [2] where first thread to get there links file and goes on but second one gets -EEXIST so it runs copyfile [3] which truncates the file.

reproducer:

rm -rf /root/.debug
for cpu in $(awk '/processor/ {print $3}' /proc/cpuinfo); do

	perf record -a -v -T -F 1000 -C $cpu \
		-o perf-${cpu}.data sleep 5 2> /dev/null &

done
wait

and simply search for empty files by:

find /lib/modules/uname -r/kernel/* -size 0

---
 tools/perf/util/build-id.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/build-id.c +2 -1
index a19674666b4e..f7fb2587df69 100644
@@ -374,7 +374,8 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name,
 		if (is_kallsyms) {
 			 if (copyfile("/proc/kallsyms", filename))
 				goto out_free;
-		} else if (link(realname, filename) && copyfile(name, filename))
+		} else if (link(realname, filename) && errno != EEXIST &&
+				copyfile(name, filename))
 			goto out_free;
 	}
 
Signature · 1 line
1.9.3
author maintainer
#2 lore raw

PATCH 2/19 perf tools: Don't allow empty argument for field-separator

In reply to Arnaldo Carvalho de Melo

From: Wang Nan <[email protected]>

Both 'perf diff' and 'perf mem' have 'field-separator' option, which causes segfault if passed with empty string. This patch uses previously introduced 'OPT_STRING_NOEMPTY' option macro to prevent fault.

---
 tools/perf/builtin-diff.c | 2 +-
 tools/perf/builtin-mem.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-diff.c +1 -1
index f800fc95f5d7..473887d1d61a 100644
@@ -802,7 +802,7 @@ static const struct option options[] = {
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
 		   " Please refer the man page for the complete list."),
-	OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
+	OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator",
 		   "separator for columns, no spaces will be added between "
 		   "columns '.' is reserved."),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
tools/perf/builtin-mem.c +1 -1
index 46c69318de84..b4dcf0bfc029 100644
@@ -286,7 +286,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "input file name"),
 	OPT_STRING('C', "cpu", &mem.cpu_list, "cpu",
 		   "list of cpus to profile"),
-	OPT_STRING('x', "field-separator", &symbol_conf.field_sep,
+	OPT_STRING_NOEMPTY('x', "field-separator", &symbol_conf.field_sep,
 		   "separator",
 		   "separator for columns, no spaces will be added"
 		   " between columns '.' is reserved."),
Signature · 1 line
1.9.3
author maintainer
#3 lore raw

PATCH 3/19 perf build: Use FEATURE-DUMP instead of PERF-FEATURES in the .gitignore file

In reply to Arnaldo Carvalho de Melo

From: Yunlong Song <[email protected]>

Since commit 4ae61202b31c ("perf build: Rename PERF-FEATURES into FEATURE-DUMP") renames PERF-FEATURES into FEATURE-DUMP, the .gitignore file should also do this thing for consistency.

---
 tools/perf/.gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/.gitignore +1 -1
index 68328f517a2e..812f904193e8 100644
@@ -1,7 +1,7 @@
 PERF-CFLAGS
 PERF-GUI-VARS
 PERF-VERSION-FILE
-PERF-FEATURES
+FEATURE-DUMP
 perf
 perf-read-vdso32
 perf-read-vdsox32
Signature · 1 line
1.9.3
author maintainer
#4 lore raw

PATCH 4/19 perf build: Add config/feature-checks/*.output to the .gitignore file

In reply to Arnaldo Carvalho de Melo

From: Yunlong Song <[email protected]>

They are all auto-generated files during the perf building.

Before this patch:

 $ git status
 Untracked files:
   (use "git add <file>..." to include in what will be committed)

config/feature-checks/test-all.make.output config/feature-checks/test-backtrace.make.output config/feature-checks/test-bionic.make.output config/feature-checks/test-dwarf.make.output config/feature-checks/test-fortify-source.make.output config/feature-checks/test-glibc.make.output config/feature-checks/test-gtk2-infobar.make.output config/feature-checks/test-gtk2.make.output config/feature-checks/test-libaudit.make.output config/feature-checks/test-libbabeltrace.make.output config/feature-checks/test-libbfd.make.output config/feature-checks/test-libdw-dwarf-unwind.make.output config/feature-checks/test-libelf-getphdrnum.make.output config/feature-checks/test-libelf-mmap.make.output config/feature-checks/test-libelf.make.output config/feature-checks/test-libnuma.make.output config/feature-checks/test-libperl.make.output config/feature-checks/test-libpython-version.make.output config/feature-checks/test-libpython.make.output config/feature-checks/test-libslang.make.output config/feature-checks/test-libunwind.make.output config/feature-checks/test-pthread-attr-setaffinity-np.make.output config/feature-checks/test-stackprotector-all.make.output config/feature-checks/test-sync-compare-and-swap.make.output config/feature-checks/test-timerfd.make.output config/feature-checks/test-zlib.make.output

After this patch:

 $ git status
 nothing to commit, working directory clean
---
 tools/perf/config/feature-checks/.gitignore | 1 +
 1 file changed, 1 insertion(+)
tools/perf/config/feature-checks/.gitignore +1 -0
index 80f3da0c3515..09b335b98842 100644
@@ -1,2 +1,3 @@
 *.d
 *.bin
+*.output
Signature · 1 line
1.9.3
author maintainer
#5 lore raw

PATCH 5/19 perf probe: Fix failure to add multiple probes without debuginfo

In reply to Arnaldo Carvalho de Melo

From: He Kuang <[email protected]>

Perf tries to find probe function addresses from map when debuginfo could not be found.

To the first added function, the value of ref_reloc_sym was set in maps__set_kallsyms_ref_reloc_sym() and can be obtained from host_machine->kmaps->maps. After that, new maps are added to host_machine->kmaps->maps in dso__load_kcore(), all these new added maps do not have a valid ref_reloc_sym.

When adding a second function, get_target_map() may get a map without valid ref_reloc_sym, and raise the error "Relocated base symbol is not found".

Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.

This problem can be reproduced as following:

  $ perf probe --add='sys_write' --add='sys_open'
  Relocated base symbol is not found!
    Error: Failed to add events.

After this patch:

  $ perf probe --add='sys_write' --add='sys_open'
  Added new event:
    probe:sys_write      (on sys_write)

You can now use it in all perf tools, such as:

perf record -e probe:sys_write -aR sleep 1

Added new event:
probe:sys_open (on sys_open)

You can now use it in all perf tools, such as:

perf record -e probe:sys_open -aR sleep 1

---
 tools/perf/util/probe-event.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/perf/util/probe-event.c +1 -3
index f272a711ad15..6b95985db5b0 100644
@@ -2507,7 +2507,6 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 					    int max_tevs, const char *target)
 {
 	struct map *map = NULL;
-	struct kmap *kmap = NULL;
 	struct ref_reloc_sym *reloc_sym = NULL;
 	struct symbol *sym;
 	struct probe_trace_event *tev;
@@ -2540,8 +2539,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
 	}
 
 	if (!pev->uprobes && !pp->retprobe) {
-		kmap = map__kmap(map);
-		reloc_sym = kmap->ref_reloc_sym;
+		reloc_sym = kernel_get_ref_reloc_sym();
 		if (!reloc_sym) {
 			pr_warning("Relocated base symbol is not found!\n");
 			ret = -EINVAL;
Signature · 1 line
1.9.3
author maintainer
#6 lore raw

PATCH 6/19 perf trace: Fix summary_only option

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

The intent of the -s/--summary-only option is to just show a summary of the system calls and statistics without any of the individual events. Commit e596663ebb2 broke that by showing the interrupted lines:

perf trace -i perf.data -s
...

     0.741 ( 0.000 ms): sleep/31316 fstat(fd: 4, statbuf: 0x7ffc75ceb830                                  ) ...
     0.744 ( 0.000 ms): sleep/31316 mmap(len: 100244, prot: READ, flags: PRIVATE, fd: 4                   ) ...
     0.747 ( 0.000 ms): perf/31315 write(fd: 3, buf: 0x7d4bb0, count: 8                                  ) ...

...

Fix by checking for the summary only option.

---
 tools/perf/builtin-trace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +2 -1
index 0b3b4e4984b9..6af6bcec930e 100644
@@ -1724,7 +1724,8 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
 			return -1;
 	}
 
-	printed += trace__printf_interrupted_entry(trace, sample);
+	if (!trace->summary_only)
+		printed += trace__printf_interrupted_entry(trace, sample);
 
 	ttrace->entry_time = sample->time;
 	msg = ttrace->entry_str;
Signature · 1 line
1.9.3
author maintainer
#7 lore raw

PATCH 7/19 perf build: Fix feature_check name clash

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

We have 2 feature_check functions, which conflict with each other. Fixing it by renaming the latter to feature_display_check.

---
 tools/perf/config/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/config/Makefile +3 -3
index e7f83b15fcbf..81d8c2bbc4df 100644
@@ -805,14 +805,14 @@ ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
   feature_display := 1
 endif
 
-feature_check = $(eval $(feature_check_code))
-define feature_check_code
+feature_display_check = $(eval $(feature_check_code))
+define feature_display_check_code
   ifneq ($(feature-$(1)), 1)
     feature_display := 1
   endif
 endef
 
-$(foreach feat,$(FEATURE_DISPLAY),$(call feature_check,$(feat)))
+$(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat)))
 
 ifeq ($(VF),1)
   feature_display := 1
Signature · 1 line
1.9.3
author maintainer
#8 lore raw

PATCH 8/19 perf build: Separate feature make support into config/Makefile.feature

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Move feature related code into separate makefile. The new Makefile.feature is included from config/Makefile. It will be moved later into tools/build.

---
 tools/perf/config/Makefile         | 165 +-----------------------------------
 tools/perf/config/Makefile.feature | 167 +++++++++++++++++++++++++++++++++++++
 2 files changed, 168 insertions(+), 164 deletions(-)
 create mode 100644 tools/perf/config/Makefile.feature
tools/perf/config/Makefile +1 -164
index 81d8c2bbc4df..01278429965a 100644
@@ -176,102 +176,7 @@ LDFLAGS += -Wl,-z,noexecstack
 
 EXTLIBS = -lpthread -lrt -lm -ldl
 
-ifneq ($(OUTPUT),)
-  OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
-  $(shell mkdir -p $(OUTPUT_FEATURES))
-endif
-
-feature_check = $(eval $(feature_check_code))
-define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
-endef
-
-feature_set = $(eval $(feature_set_code))
-define feature_set_code
-  feature-$(1) := 1
-endef
-
-#
-# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
-#
-
-#
-# Note that this is not a complete list of all feature tests, just
-# those that are typically built on a fully configured system.
-#
-# [ Feature tests not mentioned here have to be built explicitly in
-#   the rule that uses them - an example for that is the 'bionic'
-#   feature check. ]
-#
-FEATURE_TESTS =			\
-	backtrace			\
-	dwarf				\
-	fortify-source			\
-	sync-compare-and-swap		\
-	glibc				\
-	gtk2				\
-	gtk2-infobar			\
-	libaudit			\
-	libbfd				\
-	libelf				\
-	libelf-getphdrnum		\
-	libelf-mmap			\
-	libnuma				\
-	libperl				\
-	libpython			\
-	libpython-version		\
-	libslang			\
-	libunwind			\
-	pthread-attr-setaffinity-np	\
-	stackprotector-all		\
-	timerfd				\
-	libdw-dwarf-unwind		\
-	zlib
-
-FEATURE_DISPLAY =			\
-	dwarf				\
-	glibc				\
-	gtk2				\
-	libaudit			\
-	libbfd				\
-	libelf				\
-	libnuma				\
-	libperl				\
-	libpython			\
-	libslang			\
-	libunwind			\
-	libdw-dwarf-unwind		\
-	zlib
-
-# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
-# If in the future we need per-feature checks/flags for features not
-# mentioned in this list we need to refactor this ;-).
-set_test_all_flags = $(eval $(set_test_all_flags_code))
-define set_test_all_flags_code
-  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
-  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
-endef
-
-$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
-
-#
-# Special fast-path for the 'all features are available' case:
-#
-$(call feature_check,all,$(MSG))
-
-#
-# Just in case the build freshly failed, make sure we print the
-# feature matrix:
-#
-ifeq ($(feature-all), 1)
-  #
-  # test-all.c passed - just set all the core feature flags to 1:
-  #
-  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
-else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
-  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
-endif
+include $(src-perf)/config/Makefile.feature
 
 ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
@@ -763,80 +668,12 @@ plugindir=$(libdir)/traceevent/plugins
 plugindir_SQ= $(subst ','\'',$(plugindir))
 endif
 
-#
-# Print the result of the feature test:
-#
-feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
-
-define feature_print_status_code
-  ifeq ($(feature-$(1)), 1)
-    MSG = $(shell printf '...%30s: [ \033[32mon\033[m  ]' $(1))
-  else
-    MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
-  endif
-endef
-
 print_var = $(eval $(print_var_code)) $(info $(MSG))
 define print_var_code
     MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
 endef
 
-feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
-define feature_print_text_code
-    MSG = $(shell printf '...%30s: %s' $(1) $(2))
-endef
-
-FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
-FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
-
-ifeq ($(dwarf-post-unwind),1)
-  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
-endif
-
-# The $(feature_display) controls the default detection message
-# output. It's set if:
-# - detected features differes from stored features from
-#   last build (in FEATURE-DUMP file)
-# - one of the $(FEATURE_DISPLAY) is not detected
-# - VF is enabled
-
-ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
-  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
-  feature_display := 1
-endif
-
-feature_display_check = $(eval $(feature_check_code))
-define feature_display_check_code
-  ifneq ($(feature-$(1)), 1)
-    feature_display := 1
-  endif
-endef
-
-$(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat)))
-
 ifeq ($(VF),1)
-  feature_display := 1
-  feature_verbose := 1
-endif
-
-ifeq ($(feature_display),1)
-  $(info )
-  $(info Auto-detecting system features:)
-  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
-
-  ifeq ($(dwarf-post-unwind),1)
-    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
-  endif
-
-  ifneq ($(feature_verbose),1)
-    $(info )
-  endif
-endif
-
-ifeq ($(feature_verbose),1)
-  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
-  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
-  $(info )
   $(call print_var,prefix)
   $(call print_var,bindir)
   $(call print_var,libdir)
tools/perf/config/Makefile.feature new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
1.9.3
author maintainer
#9 lore raw

PATCH 9/19 perf build: Make features checks directory configurable

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Putting feature checks directory into $feature_dir, so it's easy to configure when we move it to bools/build later.

---
 tools/perf/config/Makefile.feature | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/config/Makefile.feature +4 -2
index 8c98bbce6031..ea83a92630c0 100644
@@ -1,3 +1,5 @@
+feature_dir := $(srctree)/tools/perf/config/feature-checks
+
 ifneq ($(OUTPUT),)
   OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
   $(shell mkdir -p $(OUTPUT_FEATURES))
@@ -5,7 +7,7 @@ endif
 
 feature_check = $(eval $(feature_check_code))
 define feature_check_code
-  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C config/feature-checks test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
 endef
 
 feature_set = $(eval $(feature_set_code))
@@ -91,7 +93,7 @@ ifeq ($(feature-all), 1)
   #
   $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
 else
-  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
   $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
 endif
 
Signature · 1 line
1.9.3
author maintainer
#10 lore raw

PATCH 10/19 perf build: Move feature checks code under tools/build

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Moving feature checks code under tools/build directory.

Changing also $feature_dir to point to new feature directory location and perf Makefiles to include Makefile.feature from new location.

---
 tools/build/Makefile.feature                       | 169 +++++++++++++++++++++
 tools/build/feature/.gitignore                     |   3 +
 tools/build/feature/Makefile                       | 160 +++++++++++++++++++
 tools/build/feature/test-all.c                     | 143 +++++++++++++++++
 tools/build/feature/test-backtrace.c               |  13 ++
 tools/build/feature/test-bionic.c                  |   6 +
 tools/build/feature/test-compile.c                 |   4 +
 tools/build/feature/test-cplus-demangle.c          |  14 ++
 tools/build/feature/test-dwarf.c                   |  10 ++
 tools/build/feature/test-fortify-source.c          |   6 +
 tools/build/feature/test-glibc.c                   |   8 +
 tools/build/feature/test-gtk2-infobar.c            |  11 ++
 tools/build/feature/test-gtk2.c                    |  10 ++
 tools/build/feature/test-hello.c                   |   6 +
 tools/build/feature/test-libaudit.c                |  10 ++
 tools/build/feature/test-libbabeltrace.c           |   9 ++
 tools/build/feature/test-libbfd.c                  |  15 ++
 tools/build/feature/test-libdw-dwarf-unwind.c      |  13 ++
 tools/build/feature/test-libelf-getphdrnum.c       |   8 +
 tools/build/feature/test-libelf-mmap.c             |   8 +
 tools/build/feature/test-libelf.c                  |   8 +
 tools/build/feature/test-libnuma.c                 |   9 ++
 tools/build/feature/test-libperl.c                 |   9 ++
 tools/build/feature/test-libpython-version.c       |  10 ++
 tools/build/feature/test-libpython.c               |   8 +
 tools/build/feature/test-libslang.c                |   6 +
 tools/build/feature/test-libunwind-debug-frame.c   |  16 ++
 tools/build/feature/test-libunwind.c               |  27 ++++
 .../feature/test-pthread-attr-setaffinity-np.c     |  17 +++
 tools/build/feature/test-stackprotector-all.c      |   6 +
 tools/build/feature/test-sync-compare-and-swap.c   |  14 ++
 tools/build/feature/test-timerfd.c                 |  18 +++
 tools/build/feature/test-zlib.c                    |   9 ++
 tools/perf/Makefile.perf                           |   2 +-
 tools/perf/config/Makefile                         |   2 +-
 tools/perf/config/Makefile.feature                 | 169 ---------------------
 tools/perf/config/feature-checks/.gitignore        |   3 -
 tools/perf/config/feature-checks/Makefile          | 160 -------------------
 tools/perf/config/feature-checks/test-all.c        | 143 -----------------
 tools/perf/config/feature-checks/test-backtrace.c  |  13 --
 tools/perf/config/feature-checks/test-bionic.c     |   6 -
 tools/perf/config/feature-checks/test-compile.c    |   4 -
 .../config/feature-checks/test-cplus-demangle.c    |  14 --
 tools/perf/config/feature-checks/test-dwarf.c      |  10 --
 .../config/feature-checks/test-fortify-source.c    |   6 -
 tools/perf/config/feature-checks/test-glibc.c      |   8 -
 .../perf/config/feature-checks/test-gtk2-infobar.c |  11 --
 tools/perf/config/feature-checks/test-gtk2.c       |  10 --
 tools/perf/config/feature-checks/test-hello.c      |   6 -
 tools/perf/config/feature-checks/test-libaudit.c   |  10 --
 .../config/feature-checks/test-libbabeltrace.c     |   9 --
 tools/perf/config/feature-checks/test-libbfd.c     |  15 --
 .../feature-checks/test-libdw-dwarf-unwind.c       |  13 --
 .../config/feature-checks/test-libelf-getphdrnum.c |   8 -
 .../perf/config/feature-checks/test-libelf-mmap.c  |   8 -
 tools/perf/config/feature-checks/test-libelf.c     |   8 -
 tools/perf/config/feature-checks/test-libnuma.c    |   9 --
 tools/perf/config/feature-checks/test-libperl.c    |   9 --
 .../config/feature-checks/test-libpython-version.c |  10 --
 tools/perf/config/feature-checks/test-libpython.c  |   8 -
 tools/perf/config/feature-checks/test-libslang.c   |   6 -
 .../feature-checks/test-libunwind-debug-frame.c    |  16 --
 tools/perf/config/feature-checks/test-libunwind.c  |  27 ----
 .../test-pthread-attr-setaffinity-np.c             |  17 ---
 .../feature-checks/test-stackprotector-all.c       |   6 -
 .../feature-checks/test-sync-compare-and-swap.c    |  14 --
 tools/perf/config/feature-checks/test-timerfd.c    |  18 ---
 tools/perf/config/feature-checks/test-zlib.c       |   9 --
 68 files changed, 785 insertions(+), 785 deletions(-)
 create mode 100644 tools/build/Makefile.feature
 create mode 100644 tools/build/feature/.gitignore
 create mode 100644 tools/build/feature/Makefile
 create mode 100644 tools/build/feature/test-all.c
 create mode 100644 tools/build/feature/test-backtrace.c
 create mode 100644 tools/build/feature/test-bionic.c
 create mode 100644 tools/build/feature/test-compile.c
 create mode 100644 tools/build/feature/test-cplus-demangle.c
 create mode 100644 tools/build/feature/test-dwarf.c
 create mode 100644 tools/build/feature/test-fortify-source.c
 create mode 100644 tools/build/feature/test-glibc.c
 create mode 100644 tools/build/feature/test-gtk2-infobar.c
 create mode 100644 tools/build/feature/test-gtk2.c
 create mode 100644 tools/build/feature/test-hello.c
 create mode 100644 tools/build/feature/test-libaudit.c
 create mode 100644 tools/build/feature/test-libbabeltrace.c
 create mode 100644 tools/build/feature/test-libbfd.c
 create mode 100644 tools/build/feature/test-libdw-dwarf-unwind.c
 create mode 100644 tools/build/feature/test-libelf-getphdrnum.c
 create mode 100644 tools/build/feature/test-libelf-mmap.c
 create mode 100644 tools/build/feature/test-libelf.c
 create mode 100644 tools/build/feature/test-libnuma.c
 create mode 100644 tools/build/feature/test-libperl.c
 create mode 100644 tools/build/feature/test-libpython-version.c
 create mode 100644 tools/build/feature/test-libpython.c
 create mode 100644 tools/build/feature/test-libslang.c
 create mode 100644 tools/build/feature/test-libunwind-debug-frame.c
 create mode 100644 tools/build/feature/test-libunwind.c
 create mode 100644 tools/build/feature/test-pthread-attr-setaffinity-np.c
 create mode 100644 tools/build/feature/test-stackprotector-all.c
 create mode 100644 tools/build/feature/test-sync-compare-and-swap.c
 create mode 100644 tools/build/feature/test-timerfd.c
 create mode 100644 tools/build/feature/test-zlib.c
 delete mode 100644 tools/perf/config/Makefile.feature
 delete mode 100644 tools/perf/config/feature-checks/.gitignore
 delete mode 100644 tools/perf/config/feature-checks/Makefile
 delete mode 100644 tools/perf/config/feature-checks/test-all.c
 delete mode 100644 tools/perf/config/feature-checks/test-backtrace.c
 delete mode 100644 tools/perf/config/feature-checks/test-bionic.c
 delete mode 100644 tools/perf/config/feature-checks/test-compile.c
 delete mode 100644 tools/perf/config/feature-checks/test-cplus-demangle.c
 delete mode 100644 tools/perf/config/feature-checks/test-dwarf.c
 delete mode 100644 tools/perf/config/feature-checks/test-fortify-source.c
 delete mode 100644 tools/perf/config/feature-checks/test-glibc.c
 delete mode 100644 tools/perf/config/feature-checks/test-gtk2-infobar.c
 delete mode 100644 tools/perf/config/feature-checks/test-gtk2.c
 delete mode 100644 tools/perf/config/feature-checks/test-hello.c
 delete mode 100644 tools/perf/config/feature-checks/test-libaudit.c
 delete mode 100644 tools/perf/config/feature-checks/test-libbabeltrace.c
 delete mode 100644 tools/perf/config/feature-checks/test-libbfd.c
 delete mode 100644 tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c
 delete mode 100644 tools/perf/config/feature-checks/test-libelf-getphdrnum.c
 delete mode 100644 tools/perf/config/feature-checks/test-libelf-mmap.c
 delete mode 100644 tools/perf/config/feature-checks/test-libelf.c
 delete mode 100644 tools/perf/config/feature-checks/test-libnuma.c
 delete mode 100644 tools/perf/config/feature-checks/test-libperl.c
 delete mode 100644 tools/perf/config/feature-checks/test-libpython-version.c
 delete mode 100644 tools/perf/config/feature-checks/test-libpython.c
 delete mode 100644 tools/perf/config/feature-checks/test-libslang.c
 delete mode 100644 tools/perf/config/feature-checks/test-libunwind-debug-frame.c
 delete mode 100644 tools/perf/config/feature-checks/test-libunwind.c
 delete mode 100644 tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
 delete mode 100644 tools/perf/config/feature-checks/test-stackprotector-all.c
 delete mode 100644 tools/perf/config/feature-checks/test-sync-compare-and-swap.c
 delete mode 100644 tools/perf/config/feature-checks/test-timerfd.c
 delete mode 100644 tools/perf/config/feature-checks/test-zlib.c
tools/build/Makefile.feature new file +169 -0
new file mode 100644
index 000000000000..c6f44894d4a1
@@ -0,0 +1,169 @@
+feature_dir := $(srctree)/tools/build/feature
+
+ifneq ($(OUTPUT),)
+  OUTPUT_FEATURES = $(OUTPUT)feature/
+  $(shell mkdir -p $(OUTPUT_FEATURES))
+endif
+
+feature_check = $(eval $(feature_check_code))
+define feature_check_code
+  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
+endef
+
+feature_set = $(eval $(feature_set_code))
+define feature_set_code
+  feature-$(1) := 1
+endef
+
+#
+# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
+#
+
+#
+# Note that this is not a complete list of all feature tests, just
+# those that are typically built on a fully configured system.
+#
+# [ Feature tests not mentioned here have to be built explicitly in
+#   the rule that uses them - an example for that is the 'bionic'
+#   feature check. ]
+#
+FEATURE_TESTS =			\
+	backtrace			\
+	dwarf				\
+	fortify-source			\
+	sync-compare-and-swap		\
+	glibc				\
+	gtk2				\
+	gtk2-infobar			\
+	libaudit			\
+	libbfd				\
+	libelf				\
+	libelf-getphdrnum		\
+	libelf-mmap			\
+	libnuma				\
+	libperl				\
+	libpython			\
+	libpython-version		\
+	libslang			\
+	libunwind			\
+	pthread-attr-setaffinity-np	\
+	stackprotector-all		\
+	timerfd				\
+	libdw-dwarf-unwind		\
+	zlib
+
+FEATURE_DISPLAY =			\
+	dwarf				\
+	glibc				\
+	gtk2				\
+	libaudit			\
+	libbfd				\
+	libelf				\
+	libnuma				\
+	libperl				\
+	libpython			\
+	libslang			\
+	libunwind			\
+	libdw-dwarf-unwind		\
+	zlib
+
+# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
+# If in the future we need per-feature checks/flags for features not
+# mentioned in this list we need to refactor this ;-).
+set_test_all_flags = $(eval $(set_test_all_flags_code))
+define set_test_all_flags_code
+  FEATURE_CHECK_CFLAGS-all  += $(FEATURE_CHECK_CFLAGS-$(1))
+  FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
+endef
+
+$(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat)))
+
+#
+# Special fast-path for the 'all features are available' case:
+#
+$(call feature_check,all,$(MSG))
+
+#
+# Just in case the build freshly failed, make sure we print the
+# feature matrix:
+#
+ifeq ($(feature-all), 1)
+  #
+  # test-all.c passed - just set all the core feature flags to 1:
+  #
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
+else
+  $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1)
+  $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
+endif
+
+#
+# Print the result of the feature test:
+#
+feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
+
+define feature_print_status_code
+  ifeq ($(feature-$(1)), 1)
+    MSG = $(shell printf '...%30s: [ \033[32mon\033[m  ]' $(1))
+  else
+    MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
+  endif
+endef
+
+feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
+define feature_print_text_code
+    MSG = $(shell printf '...%30s: %s' $(1) $(2))
+endef
+
+FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
+FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
+
+ifeq ($(dwarf-post-unwind),1)
+  FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
+endif
+
+# The $(feature_display) controls the default detection message
+# output. It's set if:
+# - detected features differes from stored features from
+#   last build (in FEATURE-DUMP file)
+# - one of the $(FEATURE_DISPLAY) is not detected
+# - VF is enabled
+
+ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
+  $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
+  feature_display := 1
+endif
+
+feature_display_check = $(eval $(feature_check_code))
+define feature_display_check_code
+  ifneq ($(feature-$(1)), 1)
+    feature_display := 1
+  endif
+endef
+
+$(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat)))
+
+ifeq ($(VF),1)
+  feature_display := 1
+  feature_verbose := 1
+endif
+
+ifeq ($(feature_display),1)
+  $(info )
+  $(info Auto-detecting system features:)
+  $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),))
+
+  ifeq ($(dwarf-post-unwind),1)
+    $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
+  endif
+
+  ifneq ($(feature_verbose),1)
+    $(info )
+  endif
+endif
+
+ifeq ($(feature_verbose),1)
+  TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
+  $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
+  $(info )
+endif
tools/build/feature/.gitignore new file +3 -0
new file mode 100644
index 000000000000..09b335b98842
@@ -0,0 +1,3 @@
+*.d
+*.bin
+*.output
tools/build/feature/Makefile new file +160 -0

160 lines not on this page · raw message

tools/build/feature/test-all.c new file +143 -0

143 lines not on this page · raw message

tools/build/feature/test-backtrace.c new file +13 -0
new file mode 100644
index 000000000000..7124aa1dc8fb
@@ -0,0 +1,13 @@
+#include <execinfo.h>
+#include <stdio.h>
+
+int main(void)
+{
+	void *backtrace_fns[10];
+	size_t entries;
+
+	entries = backtrace(backtrace_fns, 10);
+	backtrace_symbols_fd(backtrace_fns, entries, 1);
+
+	return 0;
+}
tools/build/feature/test-bionic.c new file +6 -0
new file mode 100644
index 000000000000..eac24e9513eb
@@ -0,0 +1,6 @@
+#include <android/api-level.h>
+
+int main(void)
+{
+	return __ANDROID_API__;
+}
tools/build/feature/test-compile.c new file +4 -0
new file mode 100644
index 000000000000..31dbf45bf99c
@@ -0,0 +1,4 @@
+int main(void)
+{
+	return 0;
+}
tools/build/feature/test-cplus-demangle.c new file +14 -0
new file mode 100644
index 000000000000..610c686e0009
@@ -0,0 +1,14 @@
+extern int printf(const char *format, ...);
+extern char *cplus_demangle(const char *, int);
+
+int main(void)
+{
+	char symbol[4096] = "FieldName__9ClassNameFd";
+	char *tmp;
+
+	tmp = cplus_demangle(symbol, 0);
+
+	printf("demangled symbol: {%s}\n", tmp);
+
+	return 0;
+}
tools/build/feature/test-dwarf.c new file +10 -0
new file mode 100644
index 000000000000..3fc1801ce4a9
@@ -0,0 +1,10 @@
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+#include <elfutils/version.h>
+
+int main(void)
+{
+	Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
+
+	return (long)dbg;
+}
tools/build/feature/test-fortify-source.c new file +6 -0
new file mode 100644
index 000000000000..c9f398d87868
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
tools/build/feature/test-glibc.c new file +8 -0
new file mode 100644
index 000000000000..b0820345cd98
@@ -0,0 +1,8 @@
+#include <gnu/libc-version.h>
+
+int main(void)
+{
+	const char *version = gnu_get_libc_version();
+
+	return (long)version;
+}
tools/build/feature/test-gtk2-infobar.c new file +11 -0
new file mode 100644
index 000000000000..397b4646d066
@@ -0,0 +1,11 @@
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+#include <gtk/gtk.h>
+#pragma GCC diagnostic error "-Wstrict-prototypes"
+
+int main(int argc, char *argv[])
+{
+	gtk_init(&argc, &argv);
+	gtk_info_bar_new();
+
+	return 0;
+}
tools/build/feature/test-gtk2.c new file +10 -0
new file mode 100644
index 000000000000..6bd80e509439
@@ -0,0 +1,10 @@
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+#include <gtk/gtk.h>
+#pragma GCC diagnostic error "-Wstrict-prototypes"
+
+int main(int argc, char *argv[])
+{
+	gtk_init(&argc, &argv);
+
+        return 0;
+}
tools/build/feature/test-hello.c new file +6 -0
new file mode 100644
index 000000000000..c9f398d87868
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
tools/build/feature/test-libaudit.c new file +10 -0
new file mode 100644
index 000000000000..afc019f08641
@@ -0,0 +1,10 @@
+#include <libaudit.h>
+
+extern int printf(const char *format, ...);
+
+int main(void)
+{
+	printf("error message: %s\n", audit_errno_to_name(0));
+
+	return audit_open();
+}
tools/build/feature/test-libbabeltrace.c new file +9 -0
new file mode 100644
index 000000000000..9cf802a04885
@@ -0,0 +1,9 @@
+
+#include <babeltrace/ctf-writer/writer.h>
+#include <babeltrace/ctf-ir/stream-class.h>
+
+int main(void)
+{
+	bt_ctf_stream_class_get_packet_context_type((void *) 0);
+	return 0;
+}
tools/build/feature/test-libbfd.c new file +15 -0
new file mode 100644
index 000000000000..24059907e990
@@ -0,0 +1,15 @@
+#include <bfd.h>
+
+extern int printf(const char *format, ...);
+
+int main(void)
+{
+	char symbol[4096] = "FieldName__9ClassNameFd";
+	char *tmp;
+
+	tmp = bfd_demangle(0, symbol, 0);
+
+	printf("demangled symbol: {%s}\n", tmp);
+
+	return 0;
+}
tools/build/feature/test-libdw-dwarf-unwind.c new file +13 -0
new file mode 100644
index 000000000000..f676a3ff442a
@@ -0,0 +1,13 @@
+
+#include <elfutils/libdwfl.h>
+
+int main(void)
+{
+	/*
+	 * This function is guarded via: __nonnull_attribute__ (1, 2).
+	 * Passing '1' as arguments value. This code is never executed,
+	 * only compiled.
+	 */
+	dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
+	return 0;
+}
tools/build/feature/test-libelf-getphdrnum.c new file +8 -0
new file mode 100644
index 000000000000..d710459306c3
@@ -0,0 +1,8 @@
+#include <libelf.h>
+
+int main(void)
+{
+	size_t dst;
+
+	return elf_getphdrnum(0, &dst);
+}
tools/build/feature/test-libelf-mmap.c new file +8 -0
new file mode 100644
index 000000000000..564427d7ef18
@@ -0,0 +1,8 @@
+#include <libelf.h>
+
+int main(void)
+{
+	Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
+
+	return (long)elf;
+}
tools/build/feature/test-libelf.c new file +8 -0
new file mode 100644
index 000000000000..08db322d8957
@@ -0,0 +1,8 @@
+#include <libelf.h>
+
+int main(void)
+{
+	Elf *elf = elf_begin(0, ELF_C_READ, 0);
+
+	return (long)elf;
+}
tools/build/feature/test-libnuma.c new file +9 -0
new file mode 100644
index 000000000000..4763d9cd587d
@@ -0,0 +1,9 @@
+#include <numa.h>
+#include <numaif.h>
+
+int main(void)
+{
+	numa_available();
+
+	return 0;
+}
tools/build/feature/test-libperl.c new file +9 -0
new file mode 100644
index 000000000000..8871f6a0fdb4
@@ -0,0 +1,9 @@
+#include <EXTERN.h>
+#include <perl.h>
+
+int main(void)
+{
+	perl_alloc();
+
+	return 0;
+}
tools/build/feature/test-libpython-version.c new file +10 -0
new file mode 100644
index 000000000000..facea122d812
@@ -0,0 +1,10 @@
+#include <Python.h>
+
+#if PY_VERSION_HEX >= 0x03000000
+	#error
+#endif
+
+int main(void)
+{
+	return 0;
+}
tools/build/feature/test-libpython.c new file +8 -0
new file mode 100644
index 000000000000..b24b28ad6324
@@ -0,0 +1,8 @@
+#include <Python.h>
+
+int main(void)
+{
+	Py_Initialize();
+
+	return 0;
+}
tools/build/feature/test-libslang.c new file +6 -0
new file mode 100644
index 000000000000..22ff22ed94d1
@@ -0,0 +1,6 @@
+#include <slang.h>
+
+int main(void)
+{
+	return SLsmg_init_smg();
+}
tools/build/feature/test-libunwind-debug-frame.c new file +16 -0
new file mode 100644
index 000000000000..0ef8087a104a
@@ -0,0 +1,16 @@
+#include <libunwind.h>
+#include <stdlib.h>
+
+extern int
+UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
+				 unw_word_t ip, unw_word_t segbase,
+				 const char *obj_name, unw_word_t start,
+				 unw_word_t end);
+
+#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
+
+int main(void)
+{
+	dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
+	return 0;
+}
tools/build/feature/test-libunwind.c new file +27 -0
new file mode 100644
index 000000000000..43b9369bcab7
@@ -0,0 +1,27 @@
+#include <libunwind.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+                                      unw_word_t ip,
+                                      unw_dyn_info_t *di,
+                                      unw_proc_info_t *pi,
+                                      int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+	unw_addr_space_t addr_space;
+
+	addr_space = unw_create_addr_space(&accessors, 0);
+	if (addr_space)
+		return 0;
+
+	unw_init_remote(NULL, addr_space, NULL);
+	dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+	return 0;
+}
tools/build/feature/test-pthread-attr-setaffinity-np.c new file +17 -0
new file mode 100644
index 000000000000..fdada5e8d454
@@ -0,0 +1,17 @@
+#include <stdint.h>
+#include <pthread.h>
+#include <sched.h>
+
+int main(void)
+{
+	int ret = 0;
+	pthread_attr_t thread_attr;
+	cpu_set_t cs;
+
+	pthread_attr_init(&thread_attr);
+	CPU_ZERO(&cs);
+
+	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
+
+	return ret;
+}
tools/build/feature/test-stackprotector-all.c new file +6 -0
new file mode 100644
index 000000000000..c9f398d87868
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(void)
+{
+	return puts("hi");
+}
tools/build/feature/test-sync-compare-and-swap.c new file +14 -0
new file mode 100644
index 000000000000..c34d4ca4af56
@@ -0,0 +1,14 @@
+#include <stdint.h>
+
+volatile uint64_t x;
+
+int main(int argc, char *argv[])
+{
+	uint64_t old, new = argc;
+
+	argv = argv;
+	do {
+		old = __sync_val_compare_and_swap(&x, 0, 0);
+	} while (!__sync_bool_compare_and_swap(&x, old, new));
+	return old == new;
+}
tools/build/feature/test-timerfd.c new file +18 -0
new file mode 100644
index 000000000000..8c5c083b4d3c
@@ -0,0 +1,18 @@
+/*
+ * test for timerfd functions used by perf-kvm-stat-live
+ */
+#include <sys/timerfd.h>
+
+int main(void)
+{
+	struct itimerspec new_value;
+
+	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
+	if (fd < 0)
+		return 1;
+
+	if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
+		return 1;
+
+	return 0;
+}
tools/build/feature/test-zlib.c new file +9 -0
new file mode 100644
index 000000000000..e111fff6240e
@@ -0,0 +1,9 @@
+#include <zlib.h>
+
+int main(void)
+{
+	z_stream zs;
+
+	inflateInit(&zs);
+	return 0;
+}
tools/perf/Makefile.perf +1 -1
index e323eab10694..d5b9e0dae334 100644
@@ -521,7 +521,7 @@ $(INSTALL_DOC_TARGETS):
 #
 config-clean:
 	$(call QUIET_CLEAN, config)
-	$(Q)$(MAKE) -C config/feature-checks clean >/dev/null
+	$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
 
 clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean config-clean
 	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
tools/perf/config/Makefile +1 -1
index 01278429965a..6d1918a6b83b 100644
@@ -176,7 +176,7 @@ LDFLAGS += -Wl,-z,noexecstack
 
 EXTLIBS = -lpthread -lrt -lm -ldl
 
-include $(src-perf)/config/Makefile.feature
+include $(srctree)/tools/build/Makefile.feature
 
 ifeq ($(feature-stackprotector-all), 1)
   CFLAGS += -fstack-protector-all
tools/perf/config/Makefile.feature deleted +0 -169

169 lines not on this page · raw message

tools/perf/config/feature-checks/.gitignore deleted +0 -3
deleted file mode 100644
index 09b335b98842..000000000000
@@ -1,3 +0,0 @@
-*.d
-*.bin
-*.output
tools/perf/config/feature-checks/Makefile deleted +0 -160

160 lines not on this page · raw message

tools/perf/config/feature-checks/test-all.c deleted +0 -143

143 lines not on this page · raw message

tools/perf/config/feature-checks/test-backtrace.c deleted +0 -13
deleted file mode 100644
index 7124aa1dc8fb..000000000000
@@ -1,13 +0,0 @@
-#include <execinfo.h>
-#include <stdio.h>
-
-int main(void)
-{
-	void *backtrace_fns[10];
-	size_t entries;
-
-	entries = backtrace(backtrace_fns, 10);
-	backtrace_symbols_fd(backtrace_fns, entries, 1);
-
-	return 0;
-}
tools/perf/config/feature-checks/test-bionic.c deleted +0 -6
deleted file mode 100644
index eac24e9513eb..000000000000
@@ -1,6 +0,0 @@
-#include <android/api-level.h>
-
-int main(void)
-{
-	return __ANDROID_API__;
-}
tools/perf/config/feature-checks/test-compile.c deleted +0 -4
deleted file mode 100644
index 31dbf45bf99c..000000000000
@@ -1,4 +0,0 @@
-int main(void)
-{
-	return 0;
-}
tools/perf/config/feature-checks/test-cplus-demangle.c deleted +0 -14
deleted file mode 100644
index 610c686e0009..000000000000
@@ -1,14 +0,0 @@
-extern int printf(const char *format, ...);
-extern char *cplus_demangle(const char *, int);
-
-int main(void)
-{
-	char symbol[4096] = "FieldName__9ClassNameFd";
-	char *tmp;
-
-	tmp = cplus_demangle(symbol, 0);
-
-	printf("demangled symbol: {%s}\n", tmp);
-
-	return 0;
-}
tools/perf/config/feature-checks/test-dwarf.c deleted +0 -10
deleted file mode 100644
index 3fc1801ce4a9..000000000000
@@ -1,10 +0,0 @@
-#include <dwarf.h>
-#include <elfutils/libdw.h>
-#include <elfutils/version.h>
-
-int main(void)
-{
-	Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
-
-	return (long)dbg;
-}
tools/perf/config/feature-checks/test-fortify-source.c deleted +0 -6
deleted file mode 100644
index c9f398d87868..000000000000
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	return puts("hi");
-}
tools/perf/config/feature-checks/test-glibc.c deleted +0 -8
deleted file mode 100644
index b0820345cd98..000000000000
@@ -1,8 +0,0 @@
-#include <gnu/libc-version.h>
-
-int main(void)
-{
-	const char *version = gnu_get_libc_version();
-
-	return (long)version;
-}
tools/perf/config/feature-checks/test-gtk2-infobar.c deleted +0 -11
deleted file mode 100644
index 397b4646d066..000000000000
@@ -1,11 +0,0 @@
-#pragma GCC diagnostic ignored "-Wstrict-prototypes"
-#include <gtk/gtk.h>
-#pragma GCC diagnostic error "-Wstrict-prototypes"
-
-int main(int argc, char *argv[])
-{
-	gtk_init(&argc, &argv);
-	gtk_info_bar_new();
-
-	return 0;
-}
tools/perf/config/feature-checks/test-gtk2.c deleted +0 -10
deleted file mode 100644
index 6bd80e509439..000000000000
@@ -1,10 +0,0 @@
-#pragma GCC diagnostic ignored "-Wstrict-prototypes"
-#include <gtk/gtk.h>
-#pragma GCC diagnostic error "-Wstrict-prototypes"
-
-int main(int argc, char *argv[])
-{
-	gtk_init(&argc, &argv);
-
-        return 0;
-}
tools/perf/config/feature-checks/test-hello.c deleted +0 -6
deleted file mode 100644
index c9f398d87868..000000000000
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	return puts("hi");
-}
tools/perf/config/feature-checks/test-libaudit.c deleted +0 -10
deleted file mode 100644
index afc019f08641..000000000000
@@ -1,10 +0,0 @@
-#include <libaudit.h>
-
-extern int printf(const char *format, ...);
-
-int main(void)
-{
-	printf("error message: %s\n", audit_errno_to_name(0));
-
-	return audit_open();
-}
tools/perf/config/feature-checks/test-libbabeltrace.c deleted +0 -9
deleted file mode 100644
index 9cf802a04885..000000000000
@@ -1,9 +0,0 @@
-
-#include <babeltrace/ctf-writer/writer.h>
-#include <babeltrace/ctf-ir/stream-class.h>
-
-int main(void)
-{
-	bt_ctf_stream_class_get_packet_context_type((void *) 0);
-	return 0;
-}
tools/perf/config/feature-checks/test-libbfd.c deleted +0 -15
deleted file mode 100644
index 24059907e990..000000000000
@@ -1,15 +0,0 @@
-#include <bfd.h>
-
-extern int printf(const char *format, ...);
-
-int main(void)
-{
-	char symbol[4096] = "FieldName__9ClassNameFd";
-	char *tmp;
-
-	tmp = bfd_demangle(0, symbol, 0);
-
-	printf("demangled symbol: {%s}\n", tmp);
-
-	return 0;
-}
tools/perf/config/feature-checks/test-libdw-dwarf-unwind.c deleted +0 -13
deleted file mode 100644
index f676a3ff442a..000000000000
@@ -1,13 +0,0 @@
-
-#include <elfutils/libdwfl.h>
-
-int main(void)
-{
-	/*
-	 * This function is guarded via: __nonnull_attribute__ (1, 2).
-	 * Passing '1' as arguments value. This code is never executed,
-	 * only compiled.
-	 */
-	dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
-	return 0;
-}
tools/perf/config/feature-checks/test-libelf-getphdrnum.c deleted +0 -8
deleted file mode 100644
index d710459306c3..000000000000
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-int main(void)
-{
-	size_t dst;
-
-	return elf_getphdrnum(0, &dst);
-}
tools/perf/config/feature-checks/test-libelf-mmap.c deleted +0 -8
deleted file mode 100644
index 564427d7ef18..000000000000
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-int main(void)
-{
-	Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
-
-	return (long)elf;
-}
tools/perf/config/feature-checks/test-libelf.c deleted +0 -8
deleted file mode 100644
index 08db322d8957..000000000000
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-int main(void)
-{
-	Elf *elf = elf_begin(0, ELF_C_READ, 0);
-
-	return (long)elf;
-}
tools/perf/config/feature-checks/test-libnuma.c deleted +0 -9
deleted file mode 100644
index 4763d9cd587d..000000000000
@@ -1,9 +0,0 @@
-#include <numa.h>
-#include <numaif.h>
-
-int main(void)
-{
-	numa_available();
-
-	return 0;
-}
tools/perf/config/feature-checks/test-libperl.c deleted +0 -9
deleted file mode 100644
index 8871f6a0fdb4..000000000000
@@ -1,9 +0,0 @@
-#include <EXTERN.h>
-#include <perl.h>
-
-int main(void)
-{
-	perl_alloc();
-
-	return 0;
-}
tools/perf/config/feature-checks/test-libpython-version.c deleted +0 -10
deleted file mode 100644
index facea122d812..000000000000
@@ -1,10 +0,0 @@
-#include <Python.h>
-
-#if PY_VERSION_HEX >= 0x03000000
-	#error
-#endif
-
-int main(void)
-{
-	return 0;
-}
tools/perf/config/feature-checks/test-libpython.c deleted +0 -8
deleted file mode 100644
index b24b28ad6324..000000000000
@@ -1,8 +0,0 @@
-#include <Python.h>
-
-int main(void)
-{
-	Py_Initialize();
-
-	return 0;
-}
tools/perf/config/feature-checks/test-libslang.c deleted +0 -6
deleted file mode 100644
index 22ff22ed94d1..000000000000
@@ -1,6 +0,0 @@
-#include <slang.h>
-
-int main(void)
-{
-	return SLsmg_init_smg();
-}
tools/perf/config/feature-checks/test-libunwind-debug-frame.c deleted +0 -16
deleted file mode 100644
index 0ef8087a104a..000000000000
@@ -1,16 +0,0 @@
-#include <libunwind.h>
-#include <stdlib.h>
-
-extern int
-UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
-				 unw_word_t ip, unw_word_t segbase,
-				 const char *obj_name, unw_word_t start,
-				 unw_word_t end);
-
-#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
-
-int main(void)
-{
-	dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
-	return 0;
-}
tools/perf/config/feature-checks/test-libunwind.c deleted +0 -27
deleted file mode 100644
index 43b9369bcab7..000000000000
@@ -1,27 +0,0 @@
-#include <libunwind.h>
-#include <stdlib.h>
-
-extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
-                                      unw_word_t ip,
-                                      unw_dyn_info_t *di,
-                                      unw_proc_info_t *pi,
-                                      int need_unwind_info, void *arg);
-
-
-#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
-
-static unw_accessors_t accessors;
-
-int main(void)
-{
-	unw_addr_space_t addr_space;
-
-	addr_space = unw_create_addr_space(&accessors, 0);
-	if (addr_space)
-		return 0;
-
-	unw_init_remote(NULL, addr_space, NULL);
-	dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
-
-	return 0;
-}
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c deleted +0 -17
deleted file mode 100644
index fdada5e8d454..000000000000
@@ -1,17 +0,0 @@
-#include <stdint.h>
-#include <pthread.h>
-#include <sched.h>
-
-int main(void)
-{
-	int ret = 0;
-	pthread_attr_t thread_attr;
-	cpu_set_t cs;
-
-	pthread_attr_init(&thread_attr);
-	CPU_ZERO(&cs);
-
-	ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
-
-	return ret;
-}
tools/perf/config/feature-checks/test-stackprotector-all.c deleted +0 -6
deleted file mode 100644
index c9f398d87868..000000000000
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	return puts("hi");
-}
tools/perf/config/feature-checks/test-sync-compare-and-swap.c deleted +0 -14
deleted file mode 100644
index c34d4ca4af56..000000000000
@@ -1,14 +0,0 @@
-#include <stdint.h>
-
-volatile uint64_t x;
-
-int main(int argc, char *argv[])
-{
-	uint64_t old, new = argc;
-
-	argv = argv;
-	do {
-		old = __sync_val_compare_and_swap(&x, 0, 0);
-	} while (!__sync_bool_compare_and_swap(&x, old, new));
-	return old == new;
-}
tools/perf/config/feature-checks/test-timerfd.c deleted +0 -18
deleted file mode 100644
index 8c5c083b4d3c..000000000000
@@ -1,18 +0,0 @@
-/*
- * test for timerfd functions used by perf-kvm-stat-live
- */
-#include <sys/timerfd.h>
-
-int main(void)
-{
-	struct itimerspec new_value;
-
-	int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
-	if (fd < 0)
-		return 1;
-
-	if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
-		return 1;
-
-	return 0;
-}
tools/perf/config/feature-checks/test-zlib.c deleted +0 -9
deleted file mode 100644
index e111fff6240e..000000000000
@@ -1,9 +0,0 @@
-#include <zlib.h>
-
-int main(void)
-{
-	z_stream zs;
-
-	inflateInit(&zs);
-	return 0;
-}
Signature · 1 line
1.9.3
author maintainer
#11 lore raw

PATCH 11/19 perf trace: Handle legacy syscalls tracepoints

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Currently the code skips the first field with the expectation that it is 'nr'. But older kernels do not have the 'nr' field:

    field:int nr;   offset:8;   size:4; signed:1;

Change perf-trace to drop the field if it exists after parsing the format file.

This fixes the off-by-one problem with older kernels (e.g., RHEL6). e.g, perf-trace shows this for write:

1.515 ( 0.006 ms): dd/4245 write(buf: 2</dev/pts/0>, count: 140733837536224 ) = 26

where 2 is really the fd, the huge number is really the buf address, etc. With this patch you get the more appropriate:

1.813 ( 0.003 ms): dd/6330 write(fd: 2</dev/pts/0>, buf: 0x7fff22fc81f0, count: 25) = 25

---
 tools/perf/builtin-trace.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
tools/perf/builtin-trace.c +14 -4
index 6af6bcec930e..001c6ae9a1b1 100644
@@ -1135,6 +1135,8 @@ static struct syscall_fmt *syscall_fmt__find(const char *name)
 
 struct syscall {
 	struct event_format *tp_format;
+	int		    nr_args;
+	struct format_field *args;
 	const char	    *name;
 	bool		    filtered;
 	bool		    is_exit;
@@ -1442,14 +1444,14 @@ static int syscall__set_arg_fmts(struct syscall *sc)
 	struct format_field *field;
 	int idx = 0;
 
-	sc->arg_scnprintf = calloc(sc->tp_format->format.nr_fields - 1, sizeof(void *));
+	sc->arg_scnprintf = calloc(sc->nr_args, sizeof(void *));
 	if (sc->arg_scnprintf == NULL)
 		return -1;
 
 	if (sc->fmt)
 		sc->arg_parm = sc->fmt->arg_parm;
 
-	for (field = sc->tp_format->format.fields->next; field; field = field->next) {
+	for (field = sc->args; field; field = field->next) {
 		if (sc->fmt && sc->fmt->arg_scnprintf[idx])
 			sc->arg_scnprintf[idx] = sc->fmt->arg_scnprintf[idx];
 		else if (field->flags & FIELD_IS_POINTER)
@@ -1515,6 +1517,14 @@ static int trace__read_syscall_info(struct trace *trace, int id)
 	if (sc->tp_format == NULL)
 		return -1;
 
+	sc->args = sc->tp_format->format.fields;
+	sc->nr_args = sc->tp_format->format.nr_fields;
+	/* drop nr field - not relevant here; does not exist on older kernels */
+	if (sc->args && strcmp(sc->args->name, "nr") == 0) {
+		sc->args = sc->args->next;
+		--sc->nr_args;
+	}
+
 	sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit");
 
 	return syscall__set_arg_fmts(sc);
@@ -1537,7 +1547,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
 	unsigned char *p;
 	unsigned long val;
 
-	if (sc->tp_format != NULL) {
+	if (sc->args != NULL) {
 		struct format_field *field;
 		u8 bit = 1;
 		struct syscall_arg arg = {
@@ -1547,7 +1557,7 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
 			.thread = thread,
 		};
 
-		for (field = sc->tp_format->format.fields->next; field;
+		for (field = sc->args; field;
 		     field = field->next, ++arg.idx, bit <<= 1) {
 			if (arg.mask & bit)
 				continue;
Signature · 1 line
1.9.3
author maintainer
#12 lore raw

PATCH 12/19 perf hists browser: Indicate which callchain entries are annotated

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Now that we can annotate entries in a callchain, show which ones have an associated symbol and samples, by adding a right arrow just before the symbol name when in verbose mode.

To toggle verbose mode press 'V'.

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/ui/browsers/hists.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/ui/browsers/hists.c +3 -1
index cd7350aeb8e7..995b7a8596b1 100644
@@ -511,6 +511,7 @@ static void hist_browser__show_callchain_entry(struct hist_browser *browser,
 {
 	int color, width;
 	char folded_sign = callchain_list__folded(chain);
+	bool show_annotated = browser->show_dso && chain->ms.sym && symbol__annotation(chain->ms.sym)->src;
 
 	color = HE_COLORSET_NORMAL;
 	width = browser->b.width - (offset + 2);
@@ -523,7 +524,8 @@ static void hist_browser__show_callchain_entry(struct hist_browser *browser,
 	ui_browser__set_color(&browser->b, color);
 	hist_browser__gotorc(browser, row, 0);
 	slsmg_write_nstring(" ", offset);
-	slsmg_printf("%c ", folded_sign);
+	slsmg_printf("%c", folded_sign);
+	ui_browser__write_graph(&browser->b, show_annotated ? SLSMG_RARROW_CHAR : ' ');
 	slsmg_write_nstring(str, width);
 }
 
Signature · 1 line
1.9.3
author maintainer
#13 lore raw

PATCH 13/19 tools lib traceevent: Add destructor for format_field

In reply to Arnaldo Carvalho de Melo

From: David Ahern <[email protected]>

Move the calls that frees the resources allocated for a struct format_field to a separate routine.

[ Split this part from a larger patch, added pevent_ prefix as requested by Steven ]
---
 tools/lib/traceevent/event-parse.c | 11 ++++++++---
 tools/lib/traceevent/event-parse.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)
tools/lib/traceevent/event-parse.c +8 -3
index afe20ed9fac8..d7c37a7d9255 100644
@@ -6228,15 +6228,20 @@ void pevent_ref(struct pevent *pevent)
 	pevent->ref_count++;
 }
 
+void pevent_free_format_field(struct format_field *field)
+{
+	free(field->type);
+	free(field->name);
+	free(field);
+}
+
 static void free_format_fields(struct format_field *field)
 {
 	struct format_field *next;
 
 	while (field) {
 		next = field->next;
-		free(field->type);
-		free(field->name);
-		free(field);
+		pevent_free_format_field(field);
 		field = next;
 	}
 }
tools/lib/traceevent/event-parse.h +1 -0
index 5b4efc062320..6abda54d76f2 100644
@@ -619,6 +619,7 @@ enum pevent_errno pevent_parse_format(struct pevent *pevent,
 				      const char *buf,
 				      unsigned long size, const char *sys);
 void pevent_free_format(struct event_format *event);
+void pevent_free_format_field(struct format_field *field);
 
 void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
 			   const char *name, struct pevent_record *record,
Signature · 1 line
1.9.3
author maintainer
#14 lore raw

PATCH 14/19 tools build: Add feature check for lzma library

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Will be used to decompress 'xz' objects. The check detects the liblzma.so devel library normally delivered by xz package.

Cc Adrian Hunter <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Corey Ashford <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/build/Makefile.feature    |  6 ++++--
 tools/build/feature/Makefile    |  8 ++++++--
 tools/build/feature/test-all.c  |  5 +++++
 tools/build/feature/test-lzma.c | 10 ++++++++++
 4 files changed, 25 insertions(+), 4 deletions(-)
 create mode 100644 tools/build/feature/test-lzma.c
tools/build/Makefile.feature +4 -2
index c6f44894d4a1..3a0b0ca2a28c 100644
@@ -50,7 +50,8 @@ FEATURE_TESTS =			\
 	stackprotector-all		\
 	timerfd				\
 	libdw-dwarf-unwind		\
-	zlib
+	zlib				\
+	lzma
 
 FEATURE_DISPLAY =			\
 	dwarf				\
@@ -65,7 +66,8 @@ FEATURE_DISPLAY =			\
 	libslang			\
 	libunwind			\
 	libdw-dwarf-unwind		\
-	zlib
+	zlib				\
+	lzma
 
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
 # If in the future we need per-feature checks/flags for features not
tools/build/feature/Makefile +6 -2
index 0d694a94cda2..463ed8f2a267 100644
@@ -32,7 +32,8 @@ FILES=					\
 	test-libbabeltrace.bin		\
 	test-compile-32.bin		\
 	test-compile-x32.bin		\
-	test-zlib.bin
+	test-zlib.bin			\
+	test-lzma.bin
 
 CC := $(CROSS_COMPILE)gcc -MD
 PKG_CONFIG := $(CROSS_COMPILE)pkg-config
@@ -45,7 +46,7 @@ __BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@)
 ###############################
 
 test-all.bin:
-	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz
+	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
 
 test-hello.bin:
 	$(BUILD)
@@ -152,6 +153,9 @@ test-compile-x32.bin:
 test-zlib.bin:
 	$(BUILD) -lz
 
+test-lzma.bin:
+	$(BUILD) -llzma
+
 -include *.d
 
 ###############################
tools/build/feature/test-all.c +5 -0
index a61c20456705..84689a67814a 100644
@@ -113,6 +113,10 @@
 #undef main
 #endif
 
+#define main main_test_lzma
+# include "test-lzma.c"
+#undef main
+
 int main(int argc, char *argv[])
 {
 	main_test_libpython();
@@ -138,6 +142,7 @@ int main(int argc, char *argv[])
 	main_test_sync_compare_and_swap(argc, argv);
 	main_test_zlib();
 	main_test_pthread_attr_setaffinity_np();
+	main_test_lzma();
 
 	return 0;
 }
tools/build/feature/test-lzma.c new file +10 -0
new file mode 100644
index 000000000000..95adc8ced3dd
@@ -0,0 +1,10 @@
+#include <lzma.h>
+
+int main(void)
+{
+	lzma_stream strm = LZMA_STREAM_INIT;
+	int ret;
+
+	ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
+	return ret ? -1 : 0;
+}
Signature · 1 line
1.9.3
author maintainer
#15 lore raw

PATCH 15/19 perf tools: Add lzma decompression support for kernel module

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

In short, Fedora compresses kernel modules now (since version 21) with lzma compression.

Adding lzma decompress support into the dso.c:compressions array introduced by Namhyung earlier.

---
 tools/perf/Makefile.perf   |  2 +
 tools/perf/config/Makefile | 11 ++++++
 tools/perf/util/Build      |  1 +
 tools/perf/util/dso.c      |  3 ++
 tools/perf/util/lzma.c     | 95 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/util.h     |  4 ++
 6 files changed, 116 insertions(+)
 create mode 100644 tools/perf/util/lzma.c
tools/perf/Makefile.perf +2 -0
index d5b9e0dae334..e9925e6ad1d0 100644
@@ -71,6 +71,8 @@ include config/utilities.mak
 #
 # Define NO_LIBBABELTRACE if you do not want libbabeltrace support
 # for CTF data format.
+#
+# Define NO_LZMA if you do not want to support compressed (xz) kernel modules
 
 ifeq ($(srctree),)
 srctree := $(patsubst %/,%,$(dir $(shell pwd)))
tools/perf/config/Makefile +11 -0
index 6d1918a6b83b..cd121dfc4de9 100644
@@ -541,6 +541,17 @@ ifndef NO_ZLIB
   endif
 endif
 
+ifndef NO_LZMA
+  ifeq ($(feature-lzma), 1)
+    CFLAGS += -DHAVE_LZMA_SUPPORT
+    EXTLIBS += -llzma
+    $(call detected,CONFIG_LZMA)
+  else
+    msg := $(warning No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev);
+    NO_LZMA := 1
+  endif
+endif
+
 ifndef NO_BACKTRACE
   ifeq ($(feature-backtrace), 1)
     CFLAGS += -DHAVE_BACKTRACE_SUPPORT
tools/perf/util/Build +1 -0
index 972a6e0da7ad..797490a40075 100644
@@ -94,6 +94,7 @@ libperf-y += scripting-engines/
 
 libperf-$(CONFIG_PERF_REGS) += perf_regs.o
 libperf-$(CONFIG_ZLIB) += zlib.o
+libperf-$(CONFIG_LZMA) += lzma.o
 
 CFLAGS_config.o   += -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_exec_cmd.o += -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))" -DPREFIX="BUILD_STR($(prefix_SQ))"
tools/perf/util/dso.c +3 -0
index 814554d1b857..be368414036c 100644
@@ -148,6 +148,9 @@ static const struct {
 #ifdef HAVE_ZLIB_SUPPORT
 	{ "gz", gzip_decompress_to_file },
 #endif
+#ifdef HAVE_LZMA_SUPPORT
+	{ "xz", lzma_decompress_to_file },
+#endif
 	{ NULL, NULL },
 };
 
tools/perf/util/lzma.c new file +95 -0

95 lines not on this page · raw message

tools/perf/util/util.h +4 -0
index fbd598afc606..1ff23e04ad27 100644
@@ -329,4 +329,8 @@ bool find_process(const char *name);
 int gzip_decompress_to_file(const char *input, int output_fd);
 #endif
 
+#ifdef HAVE_LZMA_SUPPORT
+int lzma_decompress_to_file(const char *input, int output_fd);
+#endif
+
 #endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
1.9.3
author maintainer
#16 lore raw

PATCH 16/19 perf tools: Add kmod_path__parse function

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Provides united way of parsing kernel module path
into several components.

The new kmod_path__parse function and few defines:

int __kmod_path__parse(struct kmod_path *m, const char *path,

                         bool alloc_name, bool alloc_ext);
  #define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false, false)
  #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
  #define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)

parse kernel module @path and updates @m argument like:

@comp - true if @path contains supported compression suffix,
false otherwise
@kmod - true if @path contains '.ko' suffix in right position,
false otherwise
@name - if (@alloc_name && @kmod) is true, it contains strdup-ed base name
of the kernel module without suffixes, otherwise strudup-ed base name of @path
@ext - if (@alloc_ext && @comp) is true, it contains strdup-ed string
the compression suffix

It returns 0 if there's no strdup error, -ENOMEM otherwise.

---
 tools/perf/tests/Build          |  1 +
 tools/perf/tests/builtin-test.c |  4 +++
 tools/perf/tests/kmod-path.c    | 73 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/tests/tests.h        |  1 +
 tools/perf/util/dso.c           | 66 +++++++++++++++++++++++++++++++++++++
 tools/perf/util/dso.h           | 14 ++++++++
 6 files changed, 159 insertions(+)
 create mode 100644 tools/perf/tests/kmod-path.c
tools/perf/tests/Build +1 -0
index 2de01a4b4084..6a8801b32017 100644
@@ -30,6 +30,7 @@ perf-y += keep-tracking.o
 perf-y += code-reading.o
 perf-y += sample-parsing.o
 perf-y += parse-no-sample-id-all.o
+perf-y += kmod-path.o
 
 perf-$(CONFIG_X86) += perf-time-to-tsc.o
 
tools/perf/tests/builtin-test.c +4 -0
index ed8e05c6839a..4f4098167112 100644
@@ -167,6 +167,10 @@ static struct test {
 		.func = test__fdarray__add,
 	},
 	{
+		.desc = "Test kmod_path__parse function",
+		.func = test__kmod_path__parse,
+	},
+	{
 		.func = NULL,
 	},
 };
tools/perf/tests/kmod-path.c new file +73 -0

73 lines not on this page · raw message

tools/perf/tests/tests.h +1 -0
index 00e776a87a9c..52758a33f64c 100644
@@ -51,6 +51,7 @@ int test__hists_cumulate(void);
 int test__switch_tracking(void);
 int test__fdarray__filter(void);
 int test__fdarray__add(void);
+int test__kmod_path__parse(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/dso.c +66 -0

72 lines not on this page · raw message

tools/perf/util/dso.h +14 -0
index 408c65f1a757..384cd2918e8f 100644
@@ -195,6 +195,20 @@ bool is_kernel_module(const char *pathname, bool *compressed);
 bool decompress_to_file(const char *ext, const char *filename, int output_fd);
 bool dso__needs_decompress(struct dso *dso);
 
+struct kmod_path {
+	char *name;
+	char *ext;
+	bool  comp;
+	bool  kmod;
+};
+
+int __kmod_path__parse(struct kmod_path *m, const char *path,
+		     bool alloc_name, bool alloc_ext);
+
+#define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false, false)
+#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
+#define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)
+
 /*
  * The dso__data_* external interface provides following functions:
  *   dso__data_fd
Signature · 1 line
1.9.3
author maintainer
#17 lore raw

PATCH 17/19 perf tools: Add dsos__addnew function

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Separate the creation of new dso object and its addition to the dsos list. It will be used in following patch.

---
 tools/perf/util/dso.c | 21 ++++++++++++---------
 tools/perf/util/dso.h |  1 +
 2 files changed, 13 insertions(+), 9 deletions(-)
tools/perf/util/dso.c +12 -9
index 3e6863feb066..7a7c54b42b41 100644
@@ -1071,21 +1071,24 @@ struct dso *dsos__find(const struct dsos *dsos, const char *name,
 	return dso__find_by_longname(&dsos->root, name);
 }
 
-struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
+struct dso *dsos__addnew(struct dsos *dsos, const char *name)
 {
-	struct dso *dso = dsos__find(dsos, name, false);
+	struct dso *dso = dso__new(name);
 
-	if (!dso) {
-		dso = dso__new(name);
-		if (dso != NULL) {
-			dsos__add(dsos, dso);
-			dso__set_basename(dso);
-		}
+	if (dso != NULL) {
+		dsos__add(dsos, dso);
+		dso__set_basename(dso);
 	}
-
 	return dso;
 }
 
+struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
+{
+	struct dso *dso = dsos__find(dsos, name, false);
+
+	return dso ? dso : dsos__addnew(dsos, name);
+}
+
 size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
 			       bool (skip)(struct dso *dso, int parm), int parm)
 {
tools/perf/util/dso.h +1 -0
index 384cd2918e8f..3c81d8378bc7 100644
@@ -264,6 +264,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
 				const char *short_name, int dso_type);
 
 void dsos__add(struct dsos *dsos, struct dso *dso);
+struct dso *dsos__addnew(struct dsos *dsos, const char *name);
 struct dso *dsos__find(const struct dsos *dsos, const char *name,
 		       bool cmp_short);
 struct dso *__dsos__findnew(struct dsos *dsos, const char *name);
Signature · 1 line
1.9.3
author maintainer
#18 lore raw

PATCH 18/19 perf tools: Add machine__module_dso function

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Separate the dso object addition and update when adding new kernel module.

Currently we update dso's symtab_type any time we find it in the list, because we can't distinguish between new and found dso from __dsos__findnew function.

Adding machine__module_dso that separates finding and adding new dso objects, so there's no superfluous update of dso.

---
 tools/perf/util/machine.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)
tools/perf/util/machine.c +25 -11
index 24f8c978cfd4..dbb5f0367005 100644
@@ -460,12 +460,35 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
 	return 0;
 }
 
+static struct dso *machine__module_dso(struct machine *machine, const char *filename)
+{
+	struct dso *dso;
+	bool compressed;
+
+	dso = dsos__find(&machine->kernel_dsos, filename, false);
+	if (!dso) {
+		dso = dsos__addnew(&machine->kernel_dsos, filename);
+		if (dso == NULL)
+			return NULL;
+
+		if (machine__is_host(machine))
+			dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
+		else
+			dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
+
+		/* _KMODULE_COMP should be next to _KMODULE */
+		if (is_kernel_module(filename, &compressed) && compressed)
+			dso->symtab_type++;
+	}
+
+	return dso;
+}
+
 struct map *machine__new_module(struct machine *machine, u64 start,
 				const char *filename)
 {
 	struct map *map;
-	struct dso *dso = __dsos__findnew(&machine->kernel_dsos, filename);
-	bool compressed;
+	struct dso *dso = machine__module_dso(machine, filename);
 
 	if (dso == NULL)
 		return NULL;
@@ -474,15 +497,6 @@ struct map *machine__new_module(struct machine *machine, u64 start,
 	if (map == NULL)
 		return NULL;
 
-	if (machine__is_host(machine))
-		dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
-	else
-		dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
-
-	/* _KMODULE_COMP should be next to _KMODULE */
-	if (is_kernel_module(filename, &compressed) && compressed)
-		dso->symtab_type++;
-
 	map_groups__insert(&machine->kmaps, map);
 	return map;
 }
Signature · 1 line
1.9.3
author maintainer
#19 lore raw

PATCH 19/19 perf tools: Use kmod_path__parse for machine__new_dso

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Using kmod_path__parse to get the module name and update the dso short name within machine__new_dso function.

This way it's done only first time when dso is created, unlike the current way when we update it all the time we process memory map of the kernel module.

---
 tools/perf/util/machine.c | 59 +++++++++++++++++------------------------------
 1 file changed, 21 insertions(+), 38 deletions(-)
tools/perf/util/machine.c +21 -38
index dbb5f0367005..eb95b883fb44 100644
@@ -460,14 +460,15 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
 	return 0;
 }
 
-static struct dso *machine__module_dso(struct machine *machine, const char *filename)
+static struct dso*
+machine__module_dso(struct machine *machine, struct kmod_path *m,
+		    const char *filename)
 {
 	struct dso *dso;
-	bool compressed;
 
-	dso = dsos__find(&machine->kernel_dsos, filename, false);
+	dso = dsos__find(&machine->kernel_dsos, m->name, true);
 	if (!dso) {
-		dso = dsos__addnew(&machine->kernel_dsos, filename);
+		dso = dsos__addnew(&machine->kernel_dsos, m->name);
 		if (dso == NULL)
 			return NULL;
 
@@ -477,8 +478,11 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
 			dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
 
 		/* _KMODULE_COMP should be next to _KMODULE */
-		if (is_kernel_module(filename, &compressed) && compressed)
+		if (m->kmod && m->comp)
 			dso->symtab_type++;
+
+		dso__set_short_name(dso, strdup(m->name), true);
+		dso__set_long_name(dso, strdup(filename), true);
 	}
 
 	return dso;
@@ -487,17 +491,25 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
 struct map *machine__new_module(struct machine *machine, u64 start,
 				const char *filename)
 {
-	struct map *map;
-	struct dso *dso = machine__module_dso(machine, filename);
+	struct map *map = NULL;
+	struct dso *dso;
+	struct kmod_path m;
 
-	if (dso == NULL)
+	if (kmod_path__parse_name(&m, filename))
 		return NULL;
 
+	dso = machine__module_dso(machine, &m, filename);
+	if (dso == NULL)
+		goto out;
+
 	map = map__new2(start, dso, MAP__FUNCTION);
 	if (map == NULL)
-		return NULL;
+		goto out;
 
 	map_groups__insert(&machine->kmaps, map);
+
+out:
+	free(m.name);
 	return map;
 }
 
@@ -1058,40 +1070,11 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 				strlen(kmmap_prefix) - 1) == 0;
 	if (event->mmap.filename[0] == '/' ||
 	    (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
-
-		char short_module_name[1024];
-		char *name, *dot;
-
-		if (event->mmap.filename[0] == '/') {
-			name = strrchr(event->mmap.filename, '/');
-			if (name == NULL)
-				goto out_problem;
-
-			++name; /* skip / */
-			dot = strrchr(name, '.');
-			if (dot == NULL)
-				goto out_problem;
-			/* On some system, modules are compressed like .ko.gz */
-			if (is_supported_compression(dot + 1))
-				dot -= 3;
-			if (!is_kmodule_extension(dot + 1))
-				goto out_problem;
-			snprintf(short_module_name, sizeof(short_module_name),
-					"[%.*s]", (int)(dot - name), name);
-			strxfrchar(short_module_name, '-', '_');
-		} else
-			strcpy(short_module_name, event->mmap.filename);
-
 		map = machine__new_module(machine, event->mmap.start,
 					  event->mmap.filename);
 		if (map == NULL)
 			goto out_problem;
 
-		name = strdup(short_module_name);
-		if (name == NULL)
-			goto out_problem;
-
-		dso__set_short_name(map->dso, name, true);
 		map->end = map->start + event->mmap.len;
 	} else if (is_kernel_mmap) {
 		const char *symbol_name = (event->mmap.filename +
Signature · 1 line
1.9.3
#20 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 164 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling, this is on top of my previous pull request,

Thanks,

- Arnaldo

The following changes since commit 0c8c20779c5d56b93b8cb4cd30ba129a927ab437:

perf report: Don't allow empty argument for '-t'. (2015-03-19 13:53:28 -0300)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-2

for you to fetch changes up to ca33380adf74afb985bf7aab09ec46707a5d2d57:

perf tools: Use kmod_path__parse for machine__new_dso (2015-03-21 14:58:07 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

- Handle legacy syscalls tracepoints (David Ahern, Arnaldo Carvalho de Melo)

- Indicate which callchain entries are annotated in the TUI hists browser (report/top) (Arnaldo Carvalho de Melo)

- Fix failure to add multiple probes without debuginfo (He Kuang)

- Fix 'trace' summary_only option (David Ahern)

- Fix race in build_id_cache__add_s() in 'buildid-cache' (Milos Vyletel)

- Don't allow empty argument for field-separator, fixing segfault (Wang Nan)

Infrastructure:

- Add destructor for format_field in libtraceevent (David Ahern)

- Prep work for support lzma compressed kernel modules (Jiri Olsa)

- Update .gitignore with recently added/renamed feature detection files (Yunlong Song)

----------------------------------------------------------------
Arnaldo Carvalho de Melo (2):
perf trace: Handle legacy syscalls tracepoints
perf hists browser: Indicate which callchain entries are annotated

David Ahern (2):
perf trace: Fix summary_only option
tools lib traceevent: Add destructor for format_field

He Kuang (1):
perf probe: Fix failure to add multiple probes without debuginfo

Jiri Olsa (10):
perf build: Fix feature_check name clash
perf build: Separate feature make support into config/Makefile.feature perf build: Make features checks directory configurable perf build: Move feature checks code under tools/build tools build: Add feature check for lzma library
perf tools: Add lzma decompression support for kernel module perf tools: Add kmod_path__parse function
perf tools: Add dsos__addnew function
perf tools: Add machine__module_dso function
perf tools: Use kmod_path__parse for machine__new_dso

Milos Vyletel (1):
perf tools: Fix race in build_id_cache__add_s()

Wang Nan (1):
perf tools: Don't allow empty argument for field-separator

Yunlong Song (2):
perf build: Use FEATURE-DUMP instead of PERF-FEATURES in the .gitignore file perf build: Add config/feature-checks/*.output to the .gitignore file

 tools/build/Makefile.feature                       | 171 ++++++++++++++++++++
 .../feature-checks => build/feature}/.gitignore    |   1 +
 .../feature-checks => build/feature}/Makefile      |   8 +-
 .../feature-checks => build/feature}/test-all.c    |   5 +
 .../feature}/test-backtrace.c                      |   0
 .../feature-checks => build/feature}/test-bionic.c |   0
 .../feature}/test-compile.c                        |   0
 .../feature}/test-cplus-demangle.c                 |   0
 .../feature-checks => build/feature}/test-dwarf.c  |   0
 .../feature}/test-fortify-source.c                 |   0
 .../feature-checks => build/feature}/test-glibc.c  |   0
 .../feature}/test-gtk2-infobar.c                   |   0
 .../feature-checks => build/feature}/test-gtk2.c   |   0
 .../feature-checks => build/feature}/test-hello.c  |   0
 .../feature}/test-libaudit.c                       |   0
 .../feature}/test-libbabeltrace.c                  |   0
 .../feature-checks => build/feature}/test-libbfd.c |   0
 .../feature}/test-libdw-dwarf-unwind.c             |   0
 .../feature}/test-libelf-getphdrnum.c              |   0
 .../feature}/test-libelf-mmap.c                    |   0
 .../feature-checks => build/feature}/test-libelf.c |   0
 .../feature}/test-libnuma.c                        |   0
 .../feature}/test-libperl.c                        |   0
 .../feature}/test-libpython-version.c              |   0
 .../feature}/test-libpython.c                      |   0
 .../feature}/test-libslang.c                       |   0
 .../feature}/test-libunwind-debug-frame.c          |   0
 .../feature}/test-libunwind.c                      |   0
 tools/build/feature/test-lzma.c                    |  10 ++
 .../feature}/test-pthread-attr-setaffinity-np.c    |   0
 .../feature}/test-stackprotector-all.c             |   0
 .../feature}/test-sync-compare-and-swap.c          |   0
 .../feature}/test-timerfd.c                        |   0
 .../feature-checks => build/feature}/test-zlib.c   |   0
 tools/lib/traceevent/event-parse.c                 |  11 +-
 tools/lib/traceevent/event-parse.h                 |   1 +
 tools/perf/.gitignore                              |   2 +-
 tools/perf/Makefile.perf                           |   4 +-
 tools/perf/builtin-diff.c                          |   2 +-
 tools/perf/builtin-mem.c                           |   2 +-
 tools/perf/builtin-trace.c                         |  21 ++-
 tools/perf/config/Makefile                         | 176 ++-------------------
 tools/perf/tests/Build                             |   1 +
 tools/perf/tests/builtin-test.c                    |   4 +
 tools/perf/tests/kmod-path.c                       |  73 +++++++++
 tools/perf/tests/tests.h                           |   1 +
 tools/perf/ui/browsers/hists.c                     |   4 +-
 tools/perf/util/Build                              |   1 +
 tools/perf/util/build-id.c                         |   3 +-
 tools/perf/util/dso.c                              |  90 +++++++++--
 tools/perf/util/dso.h                              |  15 ++
 tools/perf/util/lzma.c                             |  95 +++++++++++
 tools/perf/util/machine.c                          |  83 +++++-----
 tools/perf/util/probe-event.c                      |   4 +-
 tools/perf/util/util.h                             |   4 +
 55 files changed, 557 insertions(+), 235 deletions(-)
 create mode 100644 tools/build/Makefile.feature
 rename tools/{perf/config/feature-checks => build/feature}/.gitignore (52%)
 rename tools/{perf/config/feature-checks => build/feature}/Makefile (96%)
 rename tools/{perf/config/feature-checks => build/feature}/test-all.c (97%)
 rename tools/{perf/config/feature-checks => build/feature}/test-backtrace.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-bionic.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-compile.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-cplus-demangle.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-dwarf.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-fortify-source.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-glibc.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-gtk2-infobar.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-gtk2.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-hello.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libaudit.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libbabeltrace.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libbfd.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libdw-dwarf-unwind.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf-getphdrnum.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf-mmap.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libelf.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libnuma.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libperl.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libpython-version.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libpython.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libslang.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libunwind-debug-frame.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-libunwind.c (100%)
Quoted 8 lines
 create mode 100644 tools/build/feature/test-lzma.c
 rename tools/{perf/config/feature-checks => build/feature}/test-pthread-attr-setaffinity-np.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-stackprotector-all.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-sync-compare-and-swap.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-timerfd.c (100%)
 rename tools/{perf/config/feature-checks => build/feature}/test-zlib.c (100%)
 create mode 100644 tools/perf/tests/kmod-path.c
 create mode 100644 tools/perf/util/lzma.c

Pulled, thanks a lot Arnaldo!

Ingo