perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerFrom: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit 38f5d8b32f36bcac1f54d4511a81e02ed8771a29:
Merge tag 'perf-core-for-mingo-20160510' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-05-11 16:56:58 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160511
for you to fetch changes up to d65444d2fba98dcd4fa028ffada39c36a46f0038:
perf buildid-cache: Use lsdir() for looking up buildid caches (2016-05-11 13:06:08 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- Fix symbol insertion and callchain behavior in db-export (Chris Phlipot)
Infrastructure:
- Add libunwind build test (feature query), working towards supporting cross-platform DWARF callchains, starting with arm/arm64 (He Kuang)
- Use lsdir() more extensively (Masami Hiramatsu)
- Use SBUILD_ID_SIZE in places where the equivalent expression was being used (Masami Hiramatsu)
- Split some more 'perf trace' syscall arg beautifiers (Arnaldo Carvalho de Melo)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf scripting python: Use Py_FatalError instead of die() perf trace: Move flock op beautifier to tools/perf/trace/beauty/ perf trace: Move seccomp args beautifiers to tools/perf/trace/beauty/
Chris Phlipot (4):
perf symbols: Add dso__insert_symbol function
perf script: Fix symbol insertion behavior in db-export perf script: Fix callchain addresses in db-export
perf script: Fix export of callchains with recursion in db-export
He Kuang (2):
perf build: Add build-test for libunwind cross-platforms support perf build: Add build-test for debug-frame on arm/arm64
Masami Hiramatsu (4):
perf tools: Fix lsdir to set errno correctly
perf tools: Use SBUILD_ID_SIZE where applicable
perf symbols: Use lsdir() for the search in kcore cache directory perf buildid-cache: Use lsdir() for looking up buildid caches
tools/build/Makefile.feature | 8 +- tools/build/feature/Makefile | 23 ++++++ tools/build/feature/test-libunwind-aarch64.c | 26 +++++++ tools/build/feature/test-libunwind-arm.c | 27 +++++++ .../feature/test-libunwind-debug-frame-aarch64.c | 16 ++++ .../build/feature/test-libunwind-debug-frame-arm.c | 16 ++++ tools/build/feature/test-libunwind-x86.c | 27 +++++++ tools/build/feature/test-libunwind-x86_64.c | 27 +++++++ tools/perf/builtin-trace.c | 85 +--------------------- tools/perf/trace/beauty/flock.c | 31 ++++++++ tools/perf/trace/beauty/seccomp.c | 52 +++++++++++++ tools/perf/util/annotate.c | 2 +- tools/perf/util/build-id.c | 30 +------- tools/perf/util/db-export.c | 12 +-- tools/perf/util/dso.c | 4 +- tools/perf/util/header.c | 2 +- tools/perf/util/map.c | 2 +- .../util/scripting-engines/trace-event-python.c | 9 ++- tools/perf/util/symbol.c | 40 ++++++---- tools/perf/util/symbol.h | 3 + tools/perf/util/util.c | 2 +- 21 files changed, 306 insertions(+), 138 deletions(-) create mode 100644 tools/build/feature/test-libunwind-aarch64.c create mode 100644 tools/build/feature/test-libunwind-arm.c create mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c create mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c create mode 100644 tools/build/feature/test-libunwind-x86.c create mode 100644 tools/build/feature/test-libunwind-x86_64.c create mode 100644 tools/perf/trace/beauty/flock.c create mode 100644 tools/perf/trace/beauty/seccomp.c
Arnaldo Carvalho de Melo
maintainerPATCH 1/13 perf scripting python: Use Py_FatalError instead of die()
From: Arnaldo Carvalho de Melo <[email protected]>
It probably is equivalent, but that seems to be the "pythonic" way of dieing? Anyway, one less die() in the tools/perf codebase.
--- tools/perf/util/scripting-engines/trace-event-python.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/scripting-engines/trace-event-python.c +5 -2
@@ -408,8 +408,11 @@ static void python_process_tracepoint(struct perf_sample *sample,if (!t)Py_FatalError ("couldn't create Python tuple" ); -if (!event) -die ("ug! no event found for type %d" , (int )evsel->attr.config); +if (!event) { +snprintf (handler_name,sizeof (handler_name), +"ug! no event found for type %" PRIu64, (u64 )evsel->attr.config); +Py_FatalError (handler_name); + } pid =raw_field_value (event,"common_pid" , data);
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 2/13 perf symbols: Add dso__insert_symbol function
In reply to Arnaldo Carvalho de MeloFrom: Chris Phlipot <[email protected]>
The current method for inserting symbols is to use the symbols__insert() function. However symbols__insert() does not update the dso symbol cache. This causes problems in the following scenario:
1. symbol not found at addr using dso__find_symbol
2. symbol inserted at addr using the existing symbols__insert function
3. symbol still not found at addr using dso__find_symbol() because cache isn't updated. This is undesired behavior.
The undesired behavior in (3) is addressed by creating a new function, dso__insert_symbol() to both insert the symbol and update the symbol cache if necessary.
If dso__insert_symbol() is used in (2) instead of symbols__insert(), then the undesired behavior in (3) is avoided.
--- tools/perf/util/symbol.c | 12 ++++++++++++ tools/perf/util/symbol.h | 3 +++ 2 files changed, 15 insertions(+)
tools/perf/util/symbol.c +12 -0
@@ -413,6 +413,18 @@ void dso__reset_find_symbol_cache(struct dso *dso) } } +void dso__insert_symbol (struct dso *dso,enum map_type type,struct symbol *sym) +{ +symbols__insert (&dso->symbols[type], sym); + +/* update the symbol cache if necessary */ +if (dso->last_find_result[type].addr >= sym->start && + (dso->last_find_result[type].addr < sym->end || + sym->start == sym->end)) { + dso->last_find_result[type].symbol = sym; + } +} +struct symbol *dso__find_symbol (struct dso *dso,enum map_type type,u64 addr) {
tools/perf/util/symbol.h +3 -0
@@ -246,6 +246,9 @@ int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,int dso__load_kallsyms (struct dso *dso,const char *filename,struct map *map,symbol_filter_t filter); +void dso__insert_symbol (struct dso *dso,enum map_type type, +struct symbol *sym); +struct symbol *dso__find_symbol (struct dso *dso,enum map_type type,u64 addr); struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 3/13 perf script: Fix symbol insertion behavior in db-export
In reply to Arnaldo Carvalho de MeloFrom: Chris Phlipot <[email protected]>
Use the dso__insert_symbol function instead of symbols__insert() in order to properly update the dso symbol cache.
If the cache is not updated, then duplicate symbols can be unintentionally created, inserted, and exported.
This change prevents duplicate symbols from being exported due to dso__find_symbol() using a stale symbol cache.
--- tools/perf/util/db-export.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/db-export.c +1 -2
@@ -260,8 +260,7 @@ static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,if (!al->sym) { al->sym =symbol__new (al->addr,0 ,0 ,"unknown" );if (al->sym) -symbols__insert (&dso->symbols[al->map->type], - al->sym); +dso__insert_symbol (dso, al->map->type, al->sym); }if (al->sym) {
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 4/13 perf script: Fix callchain addresses in db-export
In reply to Arnaldo Carvalho de MeloFrom: Chris Phlipot <[email protected]>
Remove the call to map_ip() to adjust al.addr, because it has already been called when assembling the callchain, in:
thread__resolve_callchain_sample(perf_sample)
add_callchain_ip(ip = perf_sample->callchain->ips[j])
thread__find_addr_location(addr = ip)
thread__find_addr_map(addr) {
al->addr = addr
if (al->map)
al->addr = al->map->map_ip(al->map, al->addr);
}Calling it a second time can result in incorrect addresses being used. This can have effects such as duplicate symbols being created and exported.
--- tools/perf/util/db-export.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tools/perf/util/db-export.c +1 -4
@@ -324,10 +324,7 @@ static struct call_path *call_path_from_sample(struct db_export *dbe, al.sym = node->sym; al.map = node->map; al.machine = machine; -if (al.map) - al.addr = al.map->map_ip (al.map, node->ip); -else - al.addr = node->ip; + al.addr = node->ip;db_ids_from_al (dbe, &al, &dso_db_id, &sym_db_id, &offset);
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 5/13 perf script: Fix export of callchains with recursion in db-export
In reply to Arnaldo Carvalho de MeloFrom: Chris Phlipot <[email protected]>
When an IP with an unresolved symbol occurs in the callchain more than once (ie. recursion), then duplicate symbols can be created because the callchain nodes are never updated after they are first created.
To fix this issue we call dso__find_symbol whenever we encounter a NULL symbol, in case we already added a symbol at that IP since we started traversing the callchain.
This change prevents duplicate symbols from being exported when duplicate IPs are present in the callchain.
--- tools/perf/util/db-export.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/db-export.c +4 -0
@@ -326,6 +326,10 @@ static struct call_path *call_path_from_sample(struct db_export *dbe, al.machine = machine; al.addr = node->ip; +if (al.map && !al.sym) + al.sym =dso__find_symbol (al.map->dso,MAP__FUNCTION , + al.addr); +db_ids_from_al (dbe, &al, &dso_db_id, &sym_db_id, &offset);/* add node to the call path tree if it doesn't exist */
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 6/13 perf build: Add build-test for libunwind cross-platforms support
In reply to Arnaldo Carvalho de MeloFrom: He Kuang <[email protected]>
Currently only test for local libunwind. We should check all supported platforms so we can use them to parse perf.data with callchain info on different machines.
--- tools/build/Makefile.feature | 4 ++++ tools/build/feature/Makefile | 16 ++++++++++++++++ tools/build/feature/test-libunwind-aarch64.c | 26 ++++++++++++++++++++++++++ tools/build/feature/test-libunwind-arm.c | 27 +++++++++++++++++++++++++++ tools/build/feature/test-libunwind-x86.c | 27 +++++++++++++++++++++++++++ tools/build/feature/test-libunwind-x86_64.c | 27 +++++++++++++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 tools/build/feature/test-libunwind-aarch64.c create mode 100644 tools/build/feature/test-libunwind-arm.c create mode 100644 tools/build/feature/test-libunwind-x86.c create mode 100644 tools/build/feature/test-libunwind-x86_64.c
tools/build/Makefile.feature +4 -0
@@ -49,6 +49,10 @@ FEATURE_TESTS_BASIC := \ libslang \ libcrypto \ libunwind \ + libunwind-x86 \ + libunwind-x86_64 \ + libunwind-arm \ + libunwind-aarch64 \ pthread-attr-setaffinity-np \ stackprotector-all \ timerfd \
tools/build/feature/Makefile +16 -0
@@ -27,6 +27,10 @@ FILES= \ test-libcrypto.bin \ test-libunwind.bin \ test-libunwind-debug-frame.bin \ + test-libunwind-x86.bin \ + test-libunwind-x86_64.bin \ + test-libunwind-arm.bin \ + test-libunwind-aarch64.bin \ test-pthread-attr-setaffinity-np.bin \ test-stackprotector-all.bin \ test-timerfd.bin \
@@ -103,6 +107,18 @@ $(OUTPUT)test-libunwind.bin: $(OUTPUT)test-libunwind-debug-frame.bin: $(BUILD) -lelf +$(OUTPUT)test-libunwind-x86.bin: + $(BUILD) -lelf -lunwind-x86 + +$(OUTPUT)test-libunwind-x86_64.bin: + $(BUILD) -lelf -lunwind-x86_64 + +$(OUTPUT)test-libunwind-arm.bin: + $(BUILD) -lelf -lunwind-arm + +$(OUTPUT)test-libunwind-aarch64.bin: + $(BUILD) -lelf -lunwind-aarch64 + $(OUTPUT)test-libaudit.bin: $(BUILD) -laudit
tools/build/feature/test-libunwind-aarch64.c new file +26 -0
@@ -0,0 +1,26 @@ +#include <libunwind-aarch64.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-libunwind-arm.c new file +27 -0
@@ -0,0 +1,27 @@ +#include <libunwind-arm.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-libunwind-x86.c new file +27 -0
@@ -0,0 +1,27 @@ +#include <libunwind-x86.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-libunwind-x86_64.c new file +27 -0
@@ -0,0 +1,27 @@ +#include <libunwind-x86_64.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 ; +}
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 7/13 perf build: Add build-test for debug-frame on arm/arm64
In reply to Arnaldo Carvalho de MeloFrom: He Kuang <[email protected]>
Debug-frame for remote platforms is not related to the host platform, so we should test each platform separately.
--- tools/build/Makefile.feature | 4 +++- tools/build/feature/Makefile | 7 +++++++ tools/build/feature/test-libunwind-debug-frame-aarch64.c | 16 ++++++++++++++++ tools/build/feature/test-libunwind-debug-frame-arm.c | 16 ++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c create mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c
tools/build/Makefile.feature +3 -1
@@ -73,7 +73,9 @@ FEATURE_TESTS_EXTRA := \ libbabeltrace \ liberty \ liberty-z \ - libunwind-debug-frame + libunwind-debug-frame \ + libunwind-debug-frame-arm \ + libunwind-debug-frame-aarch64 FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)
tools/build/feature/Makefile +7 -0
@@ -31,6 +31,8 @@ FILES= \ test-libunwind-x86_64.bin \ test-libunwind-arm.bin \ test-libunwind-aarch64.bin \ + test-libunwind-debug-frame-arm.bin \ + test-libunwind-debug-frame-aarch64.bin \ test-pthread-attr-setaffinity-np.bin \ test-stackprotector-all.bin \ test-timerfd.bin \
@@ -119,6 +121,11 @@ $(OUTPUT)test-libunwind-arm.bin: $(OUTPUT)test-libunwind-aarch64.bin: $(BUILD) -lelf -lunwind-aarch64 +$(OUTPUT)test-libunwind-debug-frame-arm.bin: + $(BUILD) -lelf -lunwind-arm + +$(OUTPUT)test-libunwind-debug-frame-aarch64.bin: + $(BUILD) -lelf -lunwind-aarch64 $(OUTPUT)test-libaudit.bin: $(BUILD) -laudit
tools/build/feature/test-libunwind-debug-frame-aarch64.c new file +16 -0
@@ -0,0 +1,16 @@ +#include <libunwind-aarch64.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-debug-frame-arm.c new file +16 -0
@@ -0,0 +1,16 @@ +#include <libunwind-arm.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 ; +}
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 8/13 perf trace: Move flock op beautifier to tools/perf/trace/beauty/
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the size of builtin-trace.c.
--- tools/perf/builtin-trace.c | 32 +------------------------------- tools/perf/trace/beauty/flock.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 tools/perf/trace/beauty/flock.c
tools/perf/builtin-trace.c +1 -31
@@ -369,37 +369,6 @@ static size_t syscall_arg__scnprintf_int(char *bf, size_t size,#define SCA_INT syscall_arg__scnprintf_int -static size_t syscall_arg__scnprintf_flock (char *bf,size_t size, -struct syscall_arg *arg) -{ -int printed =0 , op = arg->val; - -if (op ==0 ) -return scnprintf (bf, size,"NONE" ); -#define P_CMD (cmd) \ - if ((op & LOCK_##cmd) == LOCK_##cmd) { \ - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \ - op &= ~LOCK_##cmd; \ - } - -P_CMD (SH ); -P_CMD (EX ); -P_CMD (NB ); -P_CMD (UN ); -P_CMD (MAND ); -P_CMD (RW ); -P_CMD (READ ); -P_CMD (WRITE ); -#undef P_OP - -if (op) - printed +=scnprintf (bf + printed, size - printed,"%s%#x" , printed ?"|" :"" , op); - -return printed; -} - -#define SCA_FLOCK syscall_arg__scnprintf_flock -static const char *bpf_cmd[] = {"MAP_CREATE" ,"MAP_LOOKUP_ELEM" ,"MAP_UPDATE_ELEM" ,"MAP_DELETE_ELEM" ,"MAP_GET_NEXT_KEY" ,"PROG_LOAD" ,
@@ -634,6 +603,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size, .arg_parm = { [arg] = &strarray__##array, }#include "trace/beauty/eventfd.c" +#include "trace/beauty/flock.c" #include "trace/beauty/futex_op.c" #include "trace/beauty/mmap.c" #include "trace/beauty/mode_t.c"
tools/perf/trace/beauty/flock.c new file +31 -0
@@ -0,0 +1,31 @@ + +static size_t syscall_arg__scnprintf_flock (char *bf,size_t size, +struct syscall_arg *arg) +{ +int printed =0 , op = arg->val; + +if (op ==0 ) +return scnprintf (bf, size,"NONE" ); +#define P_CMD (cmd) \ + if ((op & LOCK_##cmd) == LOCK_##cmd) { \ + printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \ + op &= ~LOCK_##cmd; \ + } + +P_CMD (SH ); +P_CMD (EX ); +P_CMD (NB ); +P_CMD (UN ); +P_CMD (MAND ); +P_CMD (RW ); +P_CMD (READ ); +P_CMD (WRITE ); +#undef P_OP + +if (op) + printed +=scnprintf (bf + printed, size - printed,"%s%#x" , printed ?"|" :"" , op); + +return printed; +} + +#define SCA_FLOCK syscall_arg__scnprintf_flock
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 9/13 perf trace: Move seccomp args beautifiers to tools/perf/trace/beauty/
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the size of builtin-trace.c.
--- tools/perf/builtin-trace.c | 53 +-------------------------------------- tools/perf/trace/beauty/seccomp.c | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 tools/perf/trace/beauty/seccomp.c
tools/perf/builtin-trace.c +1 -52
@@ -41,7 +41,6 @@#include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ #include <stdlib.h> #include <linux/err.h> -#include <linux/seccomp.h> #include <linux/filter.h> #include <linux/audit.h> #include <sys/ptrace.h>
@@ -517,57 +516,6 @@ static const char *tioctls[] = { static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401);#endif /* defined(__i386__) || defined(__x86_64__) */ -#ifndef SECCOMP_SET_MODE_STRICT -#define SECCOMP_SET_MODE_STRICT 0 -#endif -#ifndef SECCOMP_SET_MODE_FILTER -#define SECCOMP_SET_MODE_FILTER 1 -#endif - -static size_t syscall_arg__scnprintf_seccomp_op (char *bf,size_t size,struct syscall_arg *arg) -{ -int op = arg->val; -size_t printed =0 ; - -switch (op) { -#define P_SECCOMP_SET_MODE_OP (n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break -P_SECCOMP_SET_MODE_OP (STRICT ); -P_SECCOMP_SET_MODE_OP (FILTER ); -#undef P_SECCOMP_SET_MODE_OP -default : printed =scnprintf (bf, size,"%#x" , op);break ; - } - -return printed; -} - -#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op - -#ifndef SECCOMP_FILTER_FLAG_TSYNC -#define SECCOMP_FILTER_FLAG_TSYNC 1 -#endif - -static size_t syscall_arg__scnprintf_seccomp_flags (char *bf,size_t size, -struct syscall_arg *arg) -{ -int printed =0 , flags = arg->val; - -#define P_FLAG (n) \ - if (flags & SECCOMP_FILTER_FLAG_##n) { \ - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ - flags &= ~SECCOMP_FILTER_FLAG_##n; \ - } - -P_FLAG (TSYNC ); -#undef P_FLAG - -if (flags) - printed +=scnprintf (bf + printed, size - printed,"%s%#x" , printed ?"|" :"" , flags); - -return printed; -} - -#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags -#ifndef GRND_NONBLOCK #define GRND_NONBLOCK 0x0001#endif
@@ -612,6 +560,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,#include "trace/beauty/perf_event_open.c" #include "trace/beauty/pid.c" #include "trace/beauty/sched_policy.c" +#include "trace/beauty/seccomp.c" #include "trace/beauty/signum.c" #include "trace/beauty/socket_type.c" #include "trace/beauty/waitid_options.c"
tools/perf/trace/beauty/seccomp.c new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 10/13 perf tools: Fix lsdir to set errno correctly
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Fix lsdir() to set correct positive error number (ENOMEM). Since "errno" must have a positive error number instead of negative number, fix lsdir to set it correctly.
--- tools/perf/util/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/util.c +1 -1
@@ -139,7 +139,7 @@ struct strlist *lsdir(const char *name, list =strlist__new (NULL ,NULL );if (!list) { - errno = -ENOMEM ; + errno =ENOMEM ; goto out; }
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 11/13 perf tools: Use SBUILD_ID_SIZE where applicable
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Use the existing SBUILD_ID_SIZE macro instead of the equivalent BUILD_ID_SIZE * 2 + 1 expression for allocating a buffer for build-id strings.
--- tools/perf/util/annotate.c | 2 +- tools/perf/util/dso.c | 4 ++-- tools/perf/util/header.c | 2 +- tools/perf/util/map.c | 2 +- tools/perf/util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/symbol.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/util/annotate.c +1 -1
@@ -1138,7 +1138,7 @@ fallback:if (dso->symtab_type ==DSO_BINARY_TYPE__KALLSYMS && !dso__is_kcore (dso)) { -char bf[BUILD_ID_SIZE *2 +16 ] =" with build id " ; +char bf[SBUILD_ID_SIZE +15 ] =" with build id " ;char *build_id_msg =NULL ;if (dso->annotate_warned)
tools/perf/util/dso.c +2 -2
@@ -38,7 +38,7 @@ int dso__read_binary_type_filename(const struct dso *dso,enum dso_binary_type type, char *root_dir, char *filename, size_t size) { - char build_id_hex[BUILD_ID_SIZE * 2 + 1]; + char build_id_hex[SBUILD_ID_SIZE];int ret =0 ;size_t len;
@@ -1301,7 +1301,7 @@ size_t __dsos__fprintf(struct list_head *head, FILE *fp)size_t dso__fprintf_buildid (struct dso *dso,FILE *fp) { -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; +char sbuild_id[SBUILD_ID_SIZE ];build_id__sprintf (dso->build_id,sizeof (dso->build_id), sbuild_id);return fprintf (fp,"%s" , sbuild_id);
tools/perf/util/header.c +1 -1
@@ -1474,7 +1474,7 @@ static int __event_process_build_id(struct build_id_event *bev, dso =machine__findnew_dso (machine, filename);if (dso !=NULL ) { -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; +char sbuild_id[SBUILD_ID_SIZE ];dso__set_build_id (dso, &bev->build_id);
tools/perf/util/map.c +1 -1
@@ -289,7 +289,7 @@ int map__load(struct map *map, symbol_filter_t filter) nr =dso__load (map->dso, map, filter);if (nr <0 ) {if (map->dso->has_build_id) { -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; +char sbuild_id[SBUILD_ID_SIZE ]; build_id__sprintf(map->dso->build_id, sizeof(map->dso->build_id),
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -618,7 +618,7 @@ static int python_export_dso(struct db_export *dbe, struct dso *dso, struct machine *machine) { struct tables *tables = container_of(dbe, struct tables, dbe); -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; +char sbuild_id[SBUILD_ID_SIZE ];PyObject *t;build_id__sprintf (dso->build_id,sizeof (dso->build_id), sbuild_id);
tools/perf/util/symbol.c +1 -1
@@ -1642,7 +1642,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)static char *dso__find_kallsyms (struct dso *dso,struct map *map) {u8 host_build_id[BUILD_ID_SIZE ]; -char sbuild_id[BUILD_ID_SIZE *2 +1 ]; +char sbuild_id[SBUILD_ID_SIZE ];bool is_host = false;char path[PATH_MAX ];
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 12/13 perf symbols: Use lsdir() for the search in kcore cache directory
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Use lsdir() to search in kcore cache directory. This also avoids checking hidden dot directory entries, because kcore cache directories must always have the name from timestamps when taking the kcore snapshots, and it never start with dot.
--- tools/perf/util/symbol.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
tools/perf/util/symbol.c +14 -12
@@ -1608,25 +1608,27 @@ out:return err; } +static bool visible_dir_filter (const char *name,struct dirent *d) +{ +if (d->d_type !=DT_DIR ) +return false; +return lsdir_no_dot_filter (name, d); +} +static int find_matching_kcore (struct map *map,char *dir,size_t dir_sz) {char kallsyms_filename[PATH_MAX ]; -struct dirent *dent;int ret =-1 ; -DIR *d; +struct strlist *dirs; +struct str_node *nd; - d =opendir (dir); -if (!d) + dirs =lsdir (dir, visible_dir_filter); +if (!dirs)return -1 ; -while (1 ) { - dent =readdir (d); -if (!dent) -break ; -if (dent->d_type !=DT_DIR ) -continue ; +strlist__for_each (nd, dirs) {scnprintf (kallsyms_filename,sizeof (kallsyms_filename), -"%s/%s/kallsyms" , dir, dent->d_name); +"%s/%s/kallsyms" , dir, nd->s);if (!validate_kcore_addresses (kallsyms_filename, map)) {strlcpy (dir, kallsyms_filename, dir_sz); ret =0 ;
@@ -1634,7 +1636,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz) } } -closedir (d); +strlist__delete (dirs);return ret; }
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 13/13 perf buildid-cache: Use lsdir() for looking up buildid caches
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Use new lsdir() for looking up buildid caches. This changes logic a bit to ignore all dot files, since the build-id cache must not start with dot.
--- tools/perf/util/build-id.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-)
tools/perf/util/build-id.c +4 -26
@@ -365,39 +365,17 @@ static char *build_id_cache__dirname_from_path(const char *name,int build_id_cache__list_build_ids (const char *pathname,struct strlist **result) { -struct strlist *list;char *dir_name; -DIR *dir; -struct dirent *d;int ret =0 ; - list =strlist__new (NULL ,NULL ); dir_name =build_id_cache__dirname_from_path (pathname, false, false); -if (!list || !dir_name) { - ret = -ENOMEM ; - goto out; - } +if (!dir_name) +return -ENOMEM ; -/* List up all dirents */ - dir =opendir (dir_name); -if (!dir) { + *result =lsdir (dir_name, lsdir_no_dot_filter); +if (!*result) ret = -errno; - goto out; - } - -while ((d =readdir (dir)) !=NULL ) { -if (!strcmp (d->d_name,"." ) || !strcmp (d->d_name,".." )) -continue ; -strlist__add (list, d->d_name); - } -closedir (dir); - -out:free (dir_name); -if (ret) -strlist__delete (list); -else - *result = list;return ret; }
Signature · 1 line
2.5.5
Quoted 85 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit
38f5d8b32f36bcac1f54d4511a81e02ed8771a29:Merge tag 'perf-core-for-mingo-20160510' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2016-05-11 16:56:58 +0200)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-20160511for you to fetch changes up to
d65444d2fba98dcd4fa028ffada39c36a46f0038:perf buildid-cache: Use
lsdir()for looking up buildid caches (2016-05-11 13:06:08 -0300)----------------------------------------------------------------
perf/core improvements and fixes:User visible:
- Fix symbol insertion and callchain behavior in db-export (Chris Phlipot)
Infrastructure:
- Add libunwind build test (feature query), working towards supporting cross-platform DWARF callchains, starting with arm/arm64 (He Kuang)
- Use
lsdir()more extensively (Masami Hiramatsu)- Use
SBUILD_ID_SIZEin places where the equivalent expression was being used (Masami Hiramatsu)- Split some more 'perf trace' syscall arg beautifiers (Arnaldo Carvalho de Melo)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (3):
perf scripting python: UsePy_FatalErrorinstead ofdie()perf trace: Move flock op beautifier totools/perf/trace/beauty/perf trace: Move seccomp args beautifiers totools/perf/trace/beauty/Chris Phlipot (4):
perf symbols: Adddso__insert_symbolfunction
perf script: Fix symbol insertion behavior in db-export perf script: Fix callchain addresses in db-export
perf script: Fix export of callchains with recursion in db-exportHe Kuang (2):
perf build: Add build-test for libunwind cross-platforms support perf build: Add build-test for debug-frame on arm/arm64Masami Hiramatsu (4):
perf tools: Fix lsdir to set errno correctly
perf tools: UseSBUILD_ID_SIZEwhere applicable
perf symbols: Uselsdir()for the search in kcore cache directory perf buildid-cache: Uselsdir()for looking up buildid cachestools/build/Makefile.feature | 8 +- tools/build/feature/Makefile | 23 ++++++ tools/build/feature/test-libunwind-aarch64.c | 26 +++++++ tools/build/feature/test-libunwind-arm.c | 27 +++++++ .../feature/test-libunwind-debug-frame-aarch64.c | 16 ++++ .../build/feature/test-libunwind-debug-frame-arm.c | 16 ++++ tools/build/feature/test-libunwind-x86.c | 27 +++++++ tools/build/feature/test-libunwind-x86_64.c | 27 +++++++ tools/perf/builtin-trace.c | 85 +--------------------- tools/perf/trace/beauty/flock.c | 31 ++++++++ tools/perf/trace/beauty/seccomp.c | 52 +++++++++++++ tools/perf/util/annotate.c | 2 +- tools/perf/util/build-id.c | 30 +------- tools/perf/util/db-export.c | 12 +-- tools/perf/util/dso.c | 4 +- tools/perf/util/header.c | 2 +- tools/perf/util/map.c | 2 +- .../util/scripting-engines/trace-event-python.c | 9 ++- tools/perf/util/symbol.c | 40 ++++++---- tools/perf/util/symbol.h | 3 + tools/perf/util/util.c | 2 +- 21 files changed, 306 insertions(+), 138 deletions(-)
Quoted 8 lines
create mode 100644 tools/build/feature/test-libunwind-aarch64.c create mode 100644 tools/build/feature/test-libunwind-arm.c create mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c create mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c create mode 100644 tools/build/feature/test-libunwind-x86.c create mode 100644 tools/build/feature/test-libunwind-x86_64.c create mode 100644 tools/perf/trace/beauty/flock.c create mode 100644 tools/perf/trace/beauty/seccomp.c
Pulled, thanks a lot Arnaldo!
Ingo