perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit 2fde4f94e0a9531251e706fa57131b51b0df042e:
perf: Decouple unthrottling and rotating (2015-02-04 08:07:16 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo
for you to fetch changes up to 39f5704399042fff5f0d5f6af32bbbc3e787a897:
perf tools: Define _GNU_SOURCE on pthread_attr_setaffinity_np feature check (2015-02-11 17:38:55 -0300)
----------------------------------------------------------------
perf/core improvement and fixes:
User visible:
- No need to explicitely enable evsels for workload started from perf, let it be enabled via perf_event_attr.enable_on_exec, removing some events that take place in the 'perf trace' before a workload is really started by it. (Arnaldo Carvalho de Melo)
- Fix to handle optimized not-inlined functions in 'perf probe' (Masami Hiramatsu)
- Update 'perf probe' man page (Masami Hiramatsu)
Infrastructure:
Arnaldo Carvalho de Melo (4):
- Introduce {trace_seq_do,event_format_}_fprintf functions to allow a default tracepoint field list printer to be used in tools that allows redirecting output to a file. (Arnaldo Carvalho de Melo)
- The man page for pthread_attr_set_affinity_np states that _GNU_SOURCE must be defined before pthread.h, do it to fix the build in some systems (Josh Boyer)
- Cleanups in 'perf buildid-cache' (Masami Hiramatsu)
- Fix dso cache test case (Namhyung Kim)
- Do Not rely on dso__data_read_offset() to open DSO (Namhyung Kim)
- Make perf aware of tracefs (Steven Rostedt).
- Fix build by defining STT_GNU_IFUNC for glibc 2.9 and older (Vinson Lee)
- AArch64 symbol resolution fixes (Victor Kamensky)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (4):
tools lib traceevent: Introduce trace_seq_do_fprintf function perf tools: Introduce event_format__fprintf method
perf trace: No need to enable evsels for workload started from perf perf evlist: Fix typo in comment
Josh Boyer (1):
perf tools: Define _GNU_SOURCE on pthread_attr_setaffinity_np feature check
Masami Hiramatsu (4):
perf probe: Fix to handle optimized not-inlined functions perf probe: Update man page
perf buildid-cache: Remove unneeded debugdir parameters perf buildid-cache: Consolidate .build-id cache path generators
Namhyung Kim (3):
perf test: Fix dso cache testcase
perf tests: Do not rely on dso__data_read_offset() to open dso perf tools: Fix a dso open fail message
Steven Rostedt (Red Hat) (6):
perf tools: Do not check debugfs MAGIC for tracing files tools lib fs: Add helper to find mounted file systems tools lib api fs: Add tracefs mount helper functions tools lib api debugfs: Add DEBUGFS_DEFAULT_PATH macro tools lib api fs: Add {tracefs,debugfs}_configured() functions perf tools: Make perf aware of tracefs
Victor Kamensky (2):
perf symbols: Ignore mapping symbols on aarch64 perf symbols: debuglink should take symfs option into account
Vinson Lee (1):
perf symbols: Define STT_GNU_IFUNC for glibc 2.9 and older.
tools/lib/api/Makefile | 4 ++ tools/lib/api/fs/debugfs.c | 69 +++++++--------------- tools/lib/api/fs/debugfs.h | 13 +---- tools/lib/api/fs/findfs.c | 63 ++++++++++++++++++++ tools/lib/api/fs/findfs.h | 23 ++++++++ tools/lib/api/fs/tracefs.c | 78 +++++++++++++++++++++++++ tools/lib/api/fs/tracefs.h | 21 +++++++ tools/lib/traceevent/event-parse.h | 2 + tools/lib/traceevent/trace-seq.c | 13 +++-- tools/perf/Documentation/perf-probe.txt | 16 +++++- tools/perf/builtin-buildid-cache.c | 37 ++++++------ tools/perf/builtin-trace.c | 4 +- tools/perf/config/feature-checks/Makefile | 2 +- tools/perf/tests/dso-data.c | 22 ++++--- tools/perf/tests/open-syscall-all-cpus.c | 7 ++- tools/perf/tests/open-syscall.c | 7 ++- tools/perf/tests/parse-events.c | 13 ++++- tools/perf/util/build-id.c | 96 +++++++++++++++++++------------ tools/perf/util/build-id.h | 4 +- tools/perf/util/cache.h | 1 + tools/perf/util/dso.c | 8 +-- tools/perf/util/dwarf-aux.c | 15 +++++ tools/perf/util/dwarf-aux.h | 3 + tools/perf/util/evlist.c | 3 +- tools/perf/util/parse-events.c | 19 ------ tools/perf/util/parse-events.h | 2 +- tools/perf/util/probe-event.c | 24 +++++--- tools/perf/util/probe-finder.c | 12 ++-- tools/perf/util/symbol-elf.c | 11 ++-- tools/perf/util/trace-event-parse.c | 12 +++- tools/perf/util/trace-event.h | 3 + tools/perf/util/util.c | 60 +++++++++++++++---- tools/perf/util/util.h | 1 + 33 files changed, 468 insertions(+), 200 deletions(-) create mode 100644 tools/lib/api/fs/findfs.c create mode 100644 tools/lib/api/fs/findfs.h create mode 100644 tools/lib/api/fs/tracefs.c create mode 100644 tools/lib/api/fs/tracefs.h
Arnaldo Carvalho de Melo
maintainerPATCH 6/21 perf symbols: Ignore mapping symbols on aarch64
From: Victor Kamensky <[email protected]>
Aarch64 ELF files use mapping symbols with special names $x, $d to identify regions of Aarch64 code (see Aarch64 ELF ABI - "ARM IHI 0056B", section "4.5.4 Mapping symbols").
The patch filters out these symbols at load time, similar to "696b97a perf symbols: Ignore mapping symbols on ARM" changes done for ARM before V8.
Also added handling of mapping symbols that has format "$d.<any>" and similar for both cases.
Note we are not making difference between EM_ARM and EM_AARCH64 mapping symbols instead code handles superset of both.
--- tools/perf/util/symbol-elf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/perf/util/symbol-elf.c +3 -4
@@ -859,10 +859,9 @@ int dso__load_sym(struct dso *dso, struct map *map,/* Reject ARM ELF "mapping symbols": these aren't unique and * don't identify functions, so will confuse the profile * output: */ -if (ehdr.e_machine ==EM_ARM ) { -if (!strcmp (elf_name,"$a" ) || - !strcmp (elf_name,"$d" ) || - !strcmp (elf_name,"$t" )) +if (ehdr.e_machine ==EM_ARM || ehdr.e_machine ==EM_AARCH64 ) { +if (elf_name[0 ] =='$' &&strchr ("adtx" , elf_name[1 ]) + && (elf_name[2 ] =='\0' || elf_name[2 ] =='.' ))continue ; }
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 7/21 perf symbols: debuglink should take symfs option into account
In reply to Arnaldo Carvalho de MeloFrom: Victor Kamensky <[email protected]>
Currently code that tries to read corresponding debug symbol file from .gnu_debuglink section (DSO_BINARY_TYPE__DEBUGLINK) does not take in account symfs option, so filename__read_debuglink function cannot open ELF file, if symfs option is used.
Fix is to add proper handling of symfs as it is done in other places:
use __symbol__join_symfs function to get real file name of target ELF file.
--- tools/perf/util/dso.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/dso.c +3 -3
@@ -45,13 +45,13 @@ int dso__read_binary_type_filename(const struct dso *dso,case DSO_BINARY_TYPE__DEBUGLINK : {char *debuglink; -strncpy (filename, dso->long_name, size); - debuglink = filename + dso->long_name_len; + len =__symbol__join_symfs (filename, size, dso->long_name); + debuglink = filename + len;while (debuglink != filename && *debuglink !='/' ) debuglink--;if (*debuglink =='/' ) debuglink++; - ret =filename__read_debuglink (dso->long_name, debuglink, + ret =filename__read_debuglink (filename, debuglink, size - (debuglink - filename)); }break ;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 2/21 perf tests: Do not rely on dso__data_read_offset() to open dso
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
Do not rely on dso__data_read_offset() will always call dso__data_fd() internally. With multi-thread support, accessing a fd will be protected by a lock and it'll cause a huge contention. It can be avoided since we can skip reading from file if there's a data in the dso cache.
If one needs to call the dso__data_read_offset(), [s]he also needs to call dso__data_fd() (or set dso->binary_type at least) first like the dwarf unwind code does.
--- tools/perf/tests/dso-data.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/perf/tests/dso-data.c +8 -5
@@ -112,6 +112,9 @@ int test__dso_data(void) dso =dso__new ((const char *)file); +TEST_ASSERT_VAL ("Failed to access to dso" , +dso__data_fd (dso, &machine) >=0 ); +/* Basic 10 bytes tests. */ for (i =0 ; i <ARRAY_SIZE (offsets); i++) {struct test_data_offset *data = &offsets[i];
@@ -252,13 +255,13 @@ int test__dso_data_cache(void)struct dso *dso = dsos[i];/* -* Open dsos via dso__data_fd or dso__data_read_offset. -* Both opens the data file and keep it open. +* Open dsos via dso__data_fd(), it opens the data +* file and keep it open (unless open file limit). */ + fd =dso__data_fd (dso, &machine); +TEST_ASSERT_VAL ("failed to get fd" , fd >0 ); +if (i %2 ) { - fd =dso__data_fd (dso, &machine); -TEST_ASSERT_VAL ("failed to get fd" , fd >0 ); - }else {#define BUFSIZE 10u8 buf[BUFSIZE ];ssize_t n;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 3/21 perf tools: Fix a dso open fail message
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
It's not related to mmap, remove it from the message.
--- tools/perf/util/dso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dso.c +1 -1
@@ -240,7 +240,7 @@ static int do_open(char *name)if (fd >=0 )return fd; -pr_debug ("dso open failed, mmap: %s\n" , +pr_debug ("dso open failed: %s\n" ,strerror_r (errno, sbuf,sizeof (sbuf)));if (!dso__data_open_cnt || errno !=EMFILE )break ;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 4/21 perf probe: Fix to handle optimized not-inlined functions
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Fix to handle optimized no-inline functions which have only function definition but no actual instance at that point.
To fix this problem, we need to find actual instance of the function.
Without this patch:
----
# perf probe -a __up
Failed to get entry address of __up.
Error: Failed to add events.
# perf probe -L __up
Specified source line is not found.
Error: Failed to show lines.
----With this patch:
----
# perf probe -a __up
Added new event:
probe:__up (on __up)You can now use it in all perf tools, such as:
perf record -e probe:__up -aR sleep 1
# perf probe -L __up
<__up@/home/fedora/ksrc/linux-3/kernel/locking/semaphore.c:0>
0 static noinline void __sched __up(struct semaphore *sem)
{
struct semaphore_waiter *waiter = list_first_entry(&sem->wait_
struct semaphore_waite
4 list_del(&waiter->list);
5 waiter->up = true;
6 wake_up_process(waiter->task);
7 }
------- tools/perf/util/dwarf-aux.c | 15 +++++++++++++++ tools/perf/util/dwarf-aux.h | 3 +++ tools/perf/util/probe-finder.c | 12 ++++-------- 3 files changed, 22 insertions(+), 8 deletions(-)
tools/perf/util/dwarf-aux.c +15 -0
@@ -278,6 +278,21 @@ bool die_is_func_def(Dwarf_Die *dw_die) }/** +* die_is_func_instance - Ensure that this DIE is an instance of a subprogram +* @dw_die: a DIE +* +* Ensure that this DIE is an instance (which has an entry address). +* This returns true if @dw_die is a function instance. If not, you need to +* call die_walk_instances() to find actual instances. +**/ +bool die_is_func_instance (Dwarf_Die *dw_die) +{ +Dwarf_Addr tmp; + +/* Actually gcc optimizes non-inline as like as inlined */ +return !dwarf_func_inline (dw_die) &&dwarf_entrypc (dw_die, &tmp) ==0 ; +} +/** * die_get_data_member_location - Get the data-member offset * @mb_die: a DIE of a member of a data structure * @offs: The offset of the member in the data structure
tools/perf/util/dwarf-aux.h +3 -0
@@ -41,6 +41,9 @@ extern int cu_walk_functions_at(Dwarf_Die *cu_die, Dwarf_Addr addr,/* Ensure that this DIE is a subprogram and definition (not declaration) */ extern bool die_is_func_def (Dwarf_Die *dw_die); +/* Ensure that this DIE is an instance of a subprogram */ +extern bool die_is_func_instance (Dwarf_Die *dw_die); +/* Compare diename and tname */ extern bool die_compare_name (Dwarf_Die *dw_die,const char *tname);
tools/perf/util/probe-finder.c +4 -8
@@ -915,17 +915,13 @@ static int probe_point_search_cb(Dwarf_Die *sp_die, void *data)dwarf_decl_line (sp_die, &pf->lno); pf->lno += pp->line; param->retval =find_probe_point_by_line (pf); - }else if (!dwarf_func_inline (sp_die)) { + }else if (die_is_func_instance (sp_die)) { +/* Instances always have the entry address */ +dwarf_entrypc (sp_die, &pf->addr);/* Real function */ if (pp->lazy_line) param->retval =find_probe_point_lazy (sp_die, pf);else { -if (dwarf_entrypc (sp_die, &pf->addr) !=0 ) { -pr_warning ("Failed to get entry address of " -"%s.\n" ,dwarf_diename (sp_die)); - param->retval = -ENOENT ; -return DWARF_CB_ABORT ; - } pf->addr += pp->offset;/* TODO: Check the address in this function */ param->retval =call_probe_finder (sp_die, pf);
@@ -1536,7 +1532,7 @@ static int line_range_search_cb(Dwarf_Die *sp_die, void *data)pr_debug ("New line range: %d to %d\n" , lf->lno_s, lf->lno_e); lr->start = lf->lno_s; lr->end = lf->lno_e; -if (dwarf_func_inline (sp_die)) +if (!die_is_func_instance (sp_die)) param->retval =die_walk_instances (sp_die, line_range_inline_cb, lf);else
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 5/21 perf probe: Update man page
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Update Documentation/perf-probe.txt to add descriptions of some newer options.
--- tools/perf/Documentation/perf-probe.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-probe.txt +14 -2
@@ -47,6 +47,12 @@ OPTIONS -v:: --verbose:: Be more verbose (show parsed arguments, etc). + Can not use with -q. + +-q:: +--quiet:: + Be quiet (do not show any messages including errors). + Can not use with -v. -a:: --add=::
@@ -96,7 +102,7 @@ OPTIONS Dry run. With this option, --add and --del doesn't execute actual adding and removal operations. ---max-probes:: +--max-probes=NUM:: Set the maximum number of probe points for an event. Default is 128. -x::
@@ -104,8 +110,13 @@ OPTIONS Specify path to the executable or shared library file for user space tracing. Can also be used with --funcs option. +--demangle:: + Demangle application symbols. --no-demangle is also available + for disabling demangling. + --demangle-kernel:: - Demangle kernel symbols. + Demangle kernel symbols. --no-demangle-kernel is also available + for disabling kernel demangling. In absence of -m/-x options, perf probe checks if the first argument after the options is an absolute path name. If its an absolute path, perf probe
@@ -137,6 +148,7 @@ Each probe argument follows below syntax. [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] 'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) +'$vars' special argument is also available for NAME, it is expanded to the local variables which can access at given probe point. 'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type. On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid.
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 8/21 tools lib traceevent: Introduce trace_seq_do_fprintf function
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
So that we can specify a FILE object where to direct the formatted output.
--- tools/lib/traceevent/event-parse.h | 2 ++ tools/lib/traceevent/trace-seq.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-)
tools/lib/traceevent/event-parse.h +2 -0
@@ -22,6 +22,7 @@#include <stdbool.h> #include <stdarg.h> +#include <stdio.h> #include <regex.h> #include <string.h>
@@ -91,6 +92,7 @@ extern int trace_seq_putc(struct trace_seq *s, unsigned char c);extern void trace_seq_terminate (struct trace_seq *s); +extern int trace_seq_do_fprintf (struct trace_seq *s,FILE *fp);extern int trace_seq_do_printf (struct trace_seq *s);
tools/lib/traceevent/trace-seq.c +9 -4
@@ -231,19 +231,24 @@ void trace_seq_terminate(struct trace_seq *s) s->buffer[s->len] =0 ; } -int trace_seq_do_printf (struct trace_seq *s) +int trace_seq_do_fprintf (struct trace_seq *s,FILE *fp) {TRACE_SEQ_CHECK (s);switch (s->state) {case TRACE_SEQ__GOOD : -return printf ("%.*s" , s->len, s->buffer); +return fprintf (fp,"%.*s" , s->len, s->buffer);case TRACE_SEQ__BUFFER_POISONED : -puts ("Usage of trace_seq after it was destroyed" ); +fprintf (fp,"%s\n" ,"Usage of trace_seq after it was destroyed" );break ;case TRACE_SEQ__MEM_ALLOC_FAILED : -puts ("Can't allocate trace_seq buffer memory" ); +fprintf (fp,"%s\n" ,"Can't allocate trace_seq buffer memory" );break ; }return -1 ; } + +int trace_seq_do_printf (struct trace_seq *s) +{ +return trace_seq_do_fprintf (s, stdout); +}
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 9/21 perf tools: Introduce event_format__fprintf method
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
The existing one, event_format__print() uses stdout unconditionally, and 'perf trace' needs to use it to format into a file that may have been set by the user, i.e. 'trace -o file.output'.
--- tools/perf/util/trace-event-parse.c | 12 +++++++++--- tools/perf/util/trace-event.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-)
tools/perf/util/trace-event-parse.c +9 -3
@@ -112,8 +112,8 @@ unsigned long long read_size(struct event_format *event, void *ptr, int size)return pevent_read_number (event->pevent, ptr, size); } -void event_format__print (struct event_format *event, -int cpu,void *data,int size) +void event_format__fprintf (struct event_format *event, +int cpu,void *data,int size,FILE *fp) {struct pevent_record record;struct trace_seq s;
@@ -125,10 +125,16 @@ void event_format__print(struct event_format *event,trace_seq_init (&s);pevent_event_info (&s, event, &record); -trace_seq_do_printf (&s); +trace_seq_do_fprintf (&s, fp);trace_seq_destroy (&s); } +void event_format__print (struct event_format *event, +int cpu,void *data,int size) +{ +return event_format__fprintf (event, cpu, data, size, stdout); +} +void parse_proc_kallsyms (struct pevent *pevent,char *file,unsigned int size__maybe_unused ) {
tools/perf/util/trace-event.h +3 -0
@@ -23,6 +23,9 @@ trace_event__tp_format(const char *sys, const char *name);int bigendian (void ); +void event_format__fprintf (struct event_format *event, +int cpu,void *data,int size,FILE *fp); +void event_format__print (struct event_format *event,int cpu,void *data,int size);
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 10/21 perf trace: No need to enable evsels for workload started from perf
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As they will have perf_event_attr.enable_on_exec set, starting as soon as we exec() the workload.
--- tools/perf/builtin-trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +2 -2
@@ -2109,10 +2109,10 @@ static int trace__run(struct trace *trace, int argc, const char **argv)if (err <0 ) goto out_error_mmap; -perf_evlist__enable (evlist); -if (forks)perf_evlist__start_workload (evlist); +else +perf_evlist__enable (evlist); trace->multiple_threads = evlist->threads->map[0 ] ==-1 || evlist->threads->nr >1 ; again:
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 12/21 perf tools: Do not check debugfs MAGIC for tracing files
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
It's rather strange to be checking the debugfs MAGIC number for the tracing directory. A system admin may want to have a custom set of events to trace and it should be allowed to let the admin make a temp file (even for tracing virtual boxes, this is useful).
Also with the coming tracefs, the files may not even be under debugfs, so checking the debugfs MAGIC number is pointless.
--- tools/lib/api/fs/debugfs.c | 28 ++++++++++++++-------------- tools/lib/api/fs/debugfs.h | 1 - tools/perf/util/parse-events.c | 19 ------------------- 3 files changed, 14 insertions(+), 34 deletions(-)
tools/lib/api/fs/debugfs.c +14 -14
@@ -20,6 +20,20 @@ static const char * const debugfs_known_mountpoints[] = {static bool debugfs_found; +/* verify that a mountpoint is actually a debugfs instance */ + +static int debugfs_valid_mountpoint (const char *debugfs) +{ +struct statfs st_fs; + +if (statfs (debugfs, &st_fs) <0 ) +return -ENOENT ; +else if ((long )st_fs.f_type != (long )DEBUGFS_MAGIC ) +return -ENOENT ; + +return 0 ; +} +/* find the path to the mounted debugfs */ const char *debugfs_find_mountpoint (void ) {
@@ -60,20 +74,6 @@ const char *debugfs_find_mountpoint(void)return debugfs_mountpoint; } -/* verify that a mountpoint is actually a debugfs instance */ - -int debugfs_valid_mountpoint (const char *debugfs) -{ -struct statfs st_fs; - -if (statfs (debugfs, &st_fs) <0 ) -return -ENOENT ; -else if ((long )st_fs.f_type != (long )DEBUGFS_MAGIC ) -return -ENOENT ; - -return 0 ; -} -/* mount the debugfs somewhere if it's not mounted */ char *debugfs_mount (const char *mountpoint) {
tools/lib/api/fs/debugfs.h +0 -1
@@ -21,7 +21,6 @@#endif const char *debugfs_find_mountpoint (void ); -int debugfs_valid_mountpoint (const char *debugfs);char *debugfs_mount (const char *mountpoint);extern char debugfs_mountpoint[];
tools/perf/util/parse-events.c +0 -19
@@ -175,9 +175,6 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)char evt_path[MAXPATHLEN ];char dir_path[MAXPATHLEN ]; -if (debugfs_valid_mountpoint (tracing_events_path)) -return NULL ; - sys_dir =opendir (tracing_events_path);if (!sys_dir)return NULL ;
@@ -473,12 +470,6 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,int parse_events_add_tracepoint (struct list_head *list,int *idx,char *sys,char *event) { -int ret; - - ret =debugfs_valid_mountpoint (tracing_events_path); -if (ret) -return ret; -if (strpbrk (sys,"*?" ))return add_tracepoint_multi_sys (list, idx, sys, event);else
@@ -1109,13 +1100,6 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;char evt_path[MAXPATHLEN ];char dir_path[MAXPATHLEN ]; -char sbuf[STRERR_BUFSIZE ]; - -if (debugfs_valid_mountpoint (tracing_events_path)) { -printf (" [ Tracepoints not available: %s ]\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); -return ; - } sys_dir =opendir (tracing_events_path);if (!sys_dir)
@@ -1163,9 +1147,6 @@ int is_valid_tracepoint(const char *event_string)char evt_path[MAXPATHLEN ];char dir_path[MAXPATHLEN ]; -if (debugfs_valid_mountpoint (tracing_events_path)) -return 0 ; - sys_dir =opendir (tracing_events_path);if (!sys_dir)return 0 ;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 13/21 tools lib fs: Add helper to find mounted file systems
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
In preparation for adding tracefs for perf to use, create a findfs helper utility that find_debugfs uses instead of hard coding the search in the code. This will allow for a find_tracefs to be used as well.
--- tools/lib/api/Makefile | 2 ++ tools/lib/api/fs/debugfs.c | 51 ++++++------------------------------- tools/lib/api/fs/debugfs.h | 11 +------- tools/lib/api/fs/findfs.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ tools/lib/api/fs/findfs.h | 21 ++++++++++++++++ 5 files changed, 94 insertions(+), 54 deletions(-) create mode 100644 tools/lib/api/fs/findfs.c create mode 100644 tools/lib/api/fs/findfs.h
tools/lib/api/Makefile +2 -0
@@ -9,11 +9,13 @@ LIB_H= LIB_OBJS= LIB_H += fs/debugfs.h +LIB_H += fs/findfs.h LIB_H += fs/fs.h # See comment below about piggybacking... LIB_H += fd/array.h LIB_OBJS += $(OUTPUT)fs/debugfs.o +LIB_OBJS += $(OUTPUT)fs/findfs.o LIB_OBJS += $(OUTPUT)fs/fs.o # XXX piggybacking here, need to introduce libapikfd, or rename this # to plain libapik.a and make it have it all api goodies
tools/lib/api/fs/debugfs.c +7 -44
65 lines not on this page · raw message
tools/lib/api/fs/debugfs.h +1 -10
@@ -1,16 +1,7 @@#ifndef __API_DEBUGFS_H__#define __API_DEBUGFS_H__ -#define _STR (x) #x -#define STR (x) _STR(x) - -/* -* On most systems <limits.h> would have given us this, but not on some systems -* (e.g. GNU/Hurd). -*/ -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif +#include "findfs.h" #ifndef DEBUGFS_MAGIC #define DEBUGFS_MAGIC 0x64626720
tools/lib/api/fs/findfs.c new file +63 -0
63 lines not on this page · raw message
tools/lib/api/fs/findfs.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef __API_FINDFS_H__ +#define __API_FINDFS_H__ + +#define _STR (x) #x +#define STR (x) _STR(x) + +/* +* On most systems <limits.h> would have given us this, but not on some systems +* (e.g. GNU/Hurd). +*/ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + +const char *find_mountpoint (const char *fstype,long magic, +char *mountpoint,int len, +const char *const *known_mountpoints); + +int valid_mountpoint (const char *mount,long magic); + +#endif /* __API_FINDFS_H__ */
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 14/21 tools lib api fs: Add tracefs mount helper functions
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Since tracefs will now hold the event directory for perf, and even though by default, debugfs still mounts tracefs on the debugfs/tracing directory, the system admin may now choose to not mount debugfs and instead just mount tracefs instead.
Having tracefs helper functions will facilitate having perf look for tracefs first, and then try debugfs as a fallback.
--- tools/lib/api/Makefile | 2 ++ tools/lib/api/fs/tracefs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++ tools/lib/api/fs/tracefs.h | 20 +++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 tools/lib/api/fs/tracefs.c create mode 100644 tools/lib/api/fs/tracefs.h
tools/lib/api/Makefile +2 -0
@@ -9,12 +9,14 @@ LIB_H= LIB_OBJS= LIB_H += fs/debugfs.h +LIB_H += fs/tracefs.h LIB_H += fs/findfs.h LIB_H += fs/fs.h # See comment below about piggybacking... LIB_H += fd/array.h LIB_OBJS += $(OUTPUT)fs/debugfs.o +LIB_OBJS += $(OUTPUT)fs/tracefs.o LIB_OBJS += $(OUTPUT)fs/findfs.o LIB_OBJS += $(OUTPUT)fs/fs.o # XXX piggybacking here, need to introduce libapikfd, or rename this
tools/lib/api/fs/tracefs.c new file +70 -0
70 lines not on this page · raw message
tools/lib/api/fs/tracefs.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __API_TRACEFS_H__ +#define __API_TRACEFS_H__ + +#include "findfs.h" + +#ifndef TRACEFS_MAGIC +#define TRACEFS_MAGIC 0x74726163 +#endif + +#ifndef PERF_TRACEFS_ENVIRONMENT +#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" +#endif + +const char *tracefs_find_mountpoint (void ); +int tracefs_valid_mountpoint (const char *debugfs); +char *tracefs_mount (const char *mountpoint); + +extern char tracefs_mountpoint[]; + +#endif /* __API_DEBUGFS_H__ */
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 16/21 tools lib api fs: Add {tracefs,debugfs}_configured() functions
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Add tracefs_configured() to return true if tracefs is configured in the kernel (succeeds to find tracefs), and debugfs_configured() if debugfs is configured in the kernel (succeeds to find debugfs).
--- tools/lib/api/fs/debugfs.c | 8 ++++++++ tools/lib/api/fs/debugfs.h | 1 + tools/lib/api/fs/findfs.h | 2 ++ tools/lib/api/fs/tracefs.c | 8 ++++++++ tools/lib/api/fs/tracefs.h | 1 + 5 files changed, 20 insertions(+)
tools/lib/api/fs/debugfs.c +8 -0
@@ -3,8 +3,11 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <stdbool.h> #include <sys/vfs.h> +#include <sys/types.h> +#include <sys/stat.h> #include <sys/mount.h> #include <linux/kernel.h>
@@ -24,6 +27,11 @@ static const char * const debugfs_known_mountpoints[] = {static bool debugfs_found; +bool debugfs_configured (void ) +{ +return debugfs_find_mountpoint () !=NULL ; +} +/* find the path to the mounted debugfs */ const char *debugfs_find_mountpoint (void ) {
tools/lib/api/fs/debugfs.h +1 -0
@@ -11,6 +11,7 @@#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"#endif +bool debugfs_configured (void );const char *debugfs_find_mountpoint (void );char *debugfs_mount (const char *mountpoint);
tools/lib/api/fs/findfs.h +2 -0
@@ -1,6 +1,8 @@#ifndef __API_FINDFS_H__#define __API_FINDFS_H__ +#include <stdbool.h> +#define _STR (x) #x#define STR (x) _STR(x)
tools/lib/api/fs/tracefs.c +8 -0
@@ -2,8 +2,11 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <stdbool.h> #include <sys/vfs.h> +#include <sys/types.h> +#include <sys/stat.h> #include <sys/mount.h> #include <linux/kernel.h>
@@ -25,6 +28,11 @@ static const char * const tracefs_known_mountpoints[] = {static bool tracefs_found; +bool tracefs_configured (void ) +{ +return tracefs_find_mountpoint () !=NULL ; +} +/* find the path to the mounted tracefs */ const char *tracefs_find_mountpoint (void ) {
tools/lib/api/fs/tracefs.h +1 -0
@@ -11,6 +11,7 @@#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"#endif +bool tracefs_configured (void );const char *tracefs_find_mountpoint (void );int tracefs_valid_mountpoint (const char *debugfs);char *tracefs_mount (const char *mountpoint);
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 17/21 perf tools: Make perf aware of tracefs
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
As tracefs may be mounted instead of debugfs to get to the event directories, have perf know about tracefs, and use that file system over debugfs if it is present.
--- tools/perf/tests/open-syscall-all-cpus.c | 7 +++- tools/perf/tests/open-syscall.c | 7 +++- tools/perf/tests/parse-events.c | 13 +++++-- tools/perf/util/cache.h | 1 + tools/perf/util/evlist.c | 1 - tools/perf/util/parse-events.h | 2 +- tools/perf/util/probe-event.c | 24 ++++++++----- tools/perf/util/util.c | 60 ++++++++++++++++++++++++++------ tools/perf/util/util.h | 1 + 9 files changed, 91 insertions(+), 25 deletions(-)
tools/perf/tests/open-syscall-all-cpus.c +6 -1
@@ -29,7 +29,12 @@ int test__open_syscall_event_on_all_cpus(void) evsel =perf_evsel__newtp ("syscalls" ,"sys_enter_open" );if (evsel ==NULL ) { -pr_debug ("is debugfs mounted on /sys/kernel/debug?\n" ); +if (tracefs_configured ()) +pr_debug ("is tracefs mounted on /sys/kernel/tracing?\n" ); +else if (debugfs_configured ()) +pr_debug ("is debugfs mounted on /sys/kernel/debug?\n" ); +else +pr_debug ("Neither tracefs or debugfs is enabled in this kernel\n" ); goto out_thread_map_delete; }
tools/perf/tests/open-syscall.c +6 -1
@@ -18,7 +18,12 @@ int test__open_syscall_event(void) evsel =perf_evsel__newtp ("syscalls" ,"sys_enter_open" );if (evsel ==NULL ) { -pr_debug ("is debugfs mounted on /sys/kernel/debug?\n" ); +if (tracefs_configured ()) +pr_debug ("is tracefs mounted on /sys/kernel/tracing?\n" ); +else if (debugfs_configured ()) +pr_debug ("is debugfs mounted on /sys/kernel/debug?\n" ); +else +pr_debug ("Neither tracefs or debugfs is enabled in this kernel\n" ); goto out_thread_map_delete; }
tools/perf/tests/parse-events.c +11 -2
@@ -3,6 +3,7 @@#include "evsel.h" #include "evlist.h" #include <api/fs/fs.h> +#include <api/fs/tracefs.h> #include <api/fs/debugfs.h> #include "tests.h" #include "debug.h"
@@ -1192,11 +1193,19 @@ static int count_tracepoints(void) {char events_path[PATH_MAX ];struct dirent *events_ent; +const char *mountpoint;DIR *events_dir;int cnt =0 ; -scnprintf (events_path,PATH_MAX ,"%s/tracing/events" , -debugfs_find_mountpoint ()); + mountpoint =tracefs_find_mountpoint (); +if (mountpoint) { +scnprintf (events_path,PATH_MAX ,"%s/events" , + mountpoint); + }else { + mountpoint =debugfs_find_mountpoint (); +scnprintf (events_path,PATH_MAX ,"%s/tracing/events" , + mountpoint); + } events_dir =opendir (events_path);
tools/perf/util/cache.h +1 -0
@@ -17,6 +17,7 @@#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" +#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"typedef int (*config_fn_t )(const char *,const char *,void *);extern int perf_default_config (const char *,const char *,void *);
tools/perf/util/evlist.c +0 -1
@@ -7,7 +7,6 @@* Released under the GPL v2. (and only v2, not any later version) */ #include "util.h" -#include <api/fs/debugfs.h> #include <api/fs/fs.h> #include <poll.h> #include "cpumap.h"
tools/perf/util/parse-events.h +1 -1
@@ -122,6 +122,6 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,int print_hwcache_events (const char *event_glob,bool name_only);extern int is_valid_tracepoint (const char *event_string); -extern int valid_debugfs_mount (const char *debugfs); +int valid_event_mount (const char *eventfs);#endif /* __PERF_PARSE_EVENTS_H */
tools/perf/util/probe-event.c +16 -8
@@ -41,6 +41,7 @@#include "symbol.h" #include "thread.h" #include <api/fs/debugfs.h> +#include <api/fs/tracefs.h> #include "trace-event.h" /* For __maybe_unused */ #include "probe-event.h" #include "probe-finder.h"
@@ -1805,7 +1806,7 @@ static void print_open_warning(int err, bool is_kprobe)" - please rebuild kernel with %s.\n" , is_kprobe ? 'k' : 'u', config); }else if (err == -ENOTSUP ) -pr_warning ("Debugfs is not mounted.\n" ); +pr_warning ("Tracefs or debugfs is not mounted.\n" );else pr_warning("Failed to open %cprobe_events: %s\n", is_kprobe ? 'k' : 'u',
@@ -1816,7 +1817,7 @@ static void print_both_open_warning(int kerr, int uerr) {/* Both kprobes and uprobes are disabled, warn it. */ if (kerr == -ENOTSUP && uerr == -ENOTSUP ) -pr_warning ("Debugfs is not mounted.\n" ); +pr_warning ("Tracefs or debugfs is not mounted.\n" );else if (kerr == -ENOENT && uerr == -ENOENT )pr_warning ("Please rebuild kernel with CONFIG_KPROBE_EVENTS " "or/and CONFIG_UPROBE_EVENTS.\n" );
@@ -1833,13 +1834,20 @@ static int open_probe_events(const char *trace_file, bool readwrite) {char buf[PATH_MAX ];const char *__debugfs; +const char *tracing_dir ="" ;int ret; - __debugfs =debugfs_find_mountpoint (); -if (__debugfs ==NULL ) -return -ENOTSUP ; + __debugfs =tracefs_find_mountpoint (); +if (__debugfs ==NULL ) { + tracing_dir ="tracing/" ; - ret =e_snprintf (buf,PATH_MAX ,"%s/%s" , __debugfs, trace_file); + __debugfs =debugfs_find_mountpoint (); +if (__debugfs ==NULL ) +return -ENOTSUP ; + } + + ret =e_snprintf (buf,PATH_MAX ,"%s/%s%s" , + __debugfs, tracing_dir, trace_file);if (ret >=0 ) {pr_debug ("Opening %s write=%d\n" , buf, readwrite);if (readwrite && !probe_event_dry_run)
@@ -1855,12 +1863,12 @@ static int open_probe_events(const char *trace_file, bool readwrite)static int open_kprobe_events (bool readwrite) { -return open_probe_events ("tracing/kprobe_events" , readwrite); +return open_probe_events ("kprobe_events" , readwrite); }static int open_uprobe_events (bool readwrite) { -return open_probe_events ("tracing/uprobe_events" , readwrite); +return open_probe_events ("uprobe_events" , readwrite); }/* Get raw string list of current kprobe_events or uprobe_events */
tools/perf/util/util.c +49 -11
98 lines not on this page · raw message
tools/perf/util/util.h +1 -0
@@ -75,6 +75,7 @@#include <linux/types.h> #include <sys/ttydefaults.h> #include <api/fs/debugfs.h> +#include <api/fs/tracefs.h> #include <termios.h> #include <linux/bitops.h> #include <termios.h>
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 19/21 perf buildid-cache: Remove unneeded debugdir parameters
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Functions related to buildid-cache subcommand use debugdir parameters for passing buildid cache directory path. However all callers just pass buildid_dir global variable. Moreover, other functions which refer buildid cache use buildid_dir directly.
This removes unneeded debugdir parameters from those functions and use buildid_dir if needed.
--- tools/perf/builtin-buildid-cache.c | 37 ++++++++++++++------------------ tools/perf/util/build-id.c | 44 +++++++++++++++++--------------------- tools/perf/util/build-id.h | 4 ++-- 3 files changed, 38 insertions(+), 47 deletions(-)
tools/perf/builtin-buildid-cache.c +16 -21
@@ -125,8 +125,7 @@ static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,return ret; } -static int build_id_cache__add_kcore (const char *filename,const char *debugdir, -bool force) +static int build_id_cache__add_kcore (const char *filename,bool force) {char dir[32 ], sbuildid[BUILD_ID_SIZE *2 +1 ];char from_dir[PATH_MAX ], to_dir[PATH_MAX ];
@@ -143,7 +142,7 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir,return -1 ;scnprintf (to_dir,sizeof (to_dir),"%s/[kernel.kcore]/%s" , - debugdir, sbuildid); + buildid_dir, sbuildid);if (!force && !build_id_cache__kcore_existing (from_dir, to_dir,sizeof (to_dir))) {
@@ -155,7 +154,7 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir,return -1 ;scnprintf (to_dir,sizeof (to_dir),"%s/[kernel.kcore]/%s/%s" , - debugdir, sbuildid, dir); + buildid_dir, sbuildid, dir);if (mkdir_p (to_dir,0755 ))return -1 ;
@@ -183,7 +182,7 @@ static int build_id_cache__add_kcore(const char *filename, const char *debugdir,return 0 ; } -static int build_id_cache__add_file (const char *filename,const char *debugdir) +static int build_id_cache__add_file (const char *filename) {char sbuild_id[BUILD_ID_SIZE *2 +1 ];u8 build_id[BUILD_ID_SIZE ];
@@ -195,7 +194,7 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir) }build_id__sprintf (build_id,sizeof (build_id), sbuild_id); - err =build_id_cache__add_s (sbuild_id, debugdir, filename, + err =build_id_cache__add_s (sbuild_id, filename, false, false);if (verbose) pr_info("Adding %s %s: %s\n", sbuild_id, filename,
@@ -203,8 +202,7 @@ static int build_id_cache__add_file(const char *filename, const char *debugdir)return err; } -static int build_id_cache__remove_file (const char *filename, -const char *debugdir) +static int build_id_cache__remove_file (const char *filename) {u8 build_id[BUILD_ID_SIZE ];char sbuild_id[BUILD_ID_SIZE *2 +1 ];
@@ -217,7 +215,7 @@ static int build_id_cache__remove_file(const char *filename, }build_id__sprintf (build_id,sizeof (build_id), sbuild_id); - err =build_id_cache__remove_s (sbuild_id, debugdir); + err =build_id_cache__remove_s (sbuild_id);if (verbose)pr_info ("Removing %s %s: %s\n" , sbuild_id, filename, err ?"FAIL" :"Ok" );
@@ -252,8 +250,7 @@ static int build_id_cache__fprintf_missing(struct perf_session *session, FILE *freturn 0 ; } -static int build_id_cache__update_file (const char *filename, -const char *debugdir) +static int build_id_cache__update_file (const char *filename) {u8 build_id[BUILD_ID_SIZE ];char sbuild_id[BUILD_ID_SIZE *2 +1 ];
@@ -266,11 +263,10 @@ static int build_id_cache__update_file(const char *filename, }build_id__sprintf (build_id,sizeof (build_id), sbuild_id); - err =build_id_cache__remove_s (sbuild_id, debugdir); -if (!err) { - err =build_id_cache__add_s (sbuild_id, debugdir, filename, - false, false); - } + err =build_id_cache__remove_s (sbuild_id); +if (!err) + err =build_id_cache__add_s (sbuild_id, filename, false, false); +if (verbose)pr_info ("Updating %s %s: %s\n" , sbuild_id, filename, err ?"FAIL" :"Ok" );
@@ -338,7 +334,7 @@ int cmd_buildid_cache(int argc, const char **argv, list =strlist__new (true, add_name_list_str);if (list) {strlist__for_each (pos, list) -if (build_id_cache__add_file (pos->s, buildid_dir)) { +if (build_id_cache__add_file (pos->s)) {if (errno ==EEXIST ) {pr_debug ("%s already in the cache\n" , pos->s);
@@ -356,7 +352,7 @@ int cmd_buildid_cache(int argc, const char **argv, list =strlist__new (true, remove_name_list_str);if (list) {strlist__for_each (pos, list) -if (build_id_cache__remove_file (pos->s, buildid_dir)) { +if (build_id_cache__remove_file (pos->s)) {if (errno ==ENOENT ) {pr_debug ("%s wasn't in the cache\n" , pos->s);
@@ -377,7 +373,7 @@ int cmd_buildid_cache(int argc, const char **argv, list =strlist__new (true, update_name_list_str);if (list) {strlist__for_each (pos, list) -if (build_id_cache__update_file (pos->s, buildid_dir)) { +if (build_id_cache__update_file (pos->s)) {if (errno ==ENOENT ) {pr_debug ("%s wasn't in the cache\n" , pos->s);
@@ -391,8 +387,7 @@ int cmd_buildid_cache(int argc, const char **argv, } } -if (kcore_filename && -build_id_cache__add_kcore (kcore_filename, buildid_dir, force)) +if (kcore_filename &&build_id_cache__add_kcore (kcore_filename, force))pr_warning ("Couldn't add %s\n" , kcore_filename); out:
tools/perf/util/build-id.c +20 -24
127 lines not on this page · raw message
tools/perf/util/build-id.h +2 -2
@@ -22,9 +22,9 @@ bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);int perf_session__write_buildid_table (struct perf_session *session,int fd);int perf_session__cache_build_ids (struct perf_session *session); -int build_id_cache__add_s (const char *sbuild_id,const char *debugdir, +int build_id_cache__add_s (const char *sbuild_id,const char *name,bool is_kallsyms,bool is_vdso); -int build_id_cache__remove_s (const char *sbuild_id,const char *debugdir); +int build_id_cache__remove_s (const char *sbuild_id);void disable_buildid_cache (void );#endif
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 21/21 perf tools: Define _GNU_SOURCE on pthread_attr_setaffinity_np feature check
In reply to Arnaldo Carvalho de MeloFrom: Josh Boyer <[email protected]>
The man page for pthread_attr_set_affinity_np states that _GNU_SOURCE must be defined before pthread.h is included in order to get the proper function declaration. Define this in the Makefile.
Without this defined, the feature check fails on a Fedora system with gcc5 and then the perf build later fails with conflicting prototypes for the function.
--- tools/perf/config/feature-checks/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/config/feature-checks/Makefile +1 -1
@@ -49,7 +49,7 @@ test-hello.bin: $(BUILD) test-pthread-attr-setaffinity-np.bin: - $(BUILD) -Werror -lpthread + $(BUILD) -D_GNU_SOURCE -Werror -lpthread test-stackprotector-all.bin: $(BUILD) -Werror -fstack-protector-all
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 20/21 perf buildid-cache: Consolidate .build-id cache path generators
In reply to Arnaldo Carvalho de MeloFrom: Masami Hiramatsu <[email protected]>
Consolidate .build-id cache path generating routines to build_id__filename() function. Other functions must use it to get the buildid cache path (link path) from build-id. This can reduce the risk of partial-update.
--- tools/perf/util/build-id.c | 58 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 17 deletions(-)
tools/perf/util/build-id.c +41 -17
@@ -93,6 +93,35 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf)return raw - build_id; } +/* asnprintf consolidates asprintf and snprintf */ +static int asnprintf (char **strp,size_t size,const char *fmt, ...) +{ +va_list ap; +int ret; + +if (!strp) +return -EINVAL ; + +va_start (ap, fmt); +if (*strp) + ret =vsnprintf (*strp, size, fmt, ap); +else + ret =vasprintf (strp, fmt, ap); +va_end (ap); + +return ret; +} + +static char *build_id__filename (const char *sbuild_id,char *bf,size_t size) +{ +char *tmp = bf; +int ret =asnprintf (&bf, size,"%s/.build-id/%.2s/%s" , buildid_dir, + sbuild_id, sbuild_id +2 ); +if (ret <0 || (tmp && size < (unsigned int )ret)) +return NULL ; +return bf; +} +char *dso__build_id_filename (const struct dso *dso,char *bf,size_t size) {char build_id_hex[BUILD_ID_SIZE *2 +1 ];
@@ -101,14 +130,7 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)return NULL ;build_id__sprintf (dso->build_id,sizeof (dso->build_id), build_id_hex); -if (bf ==NULL ) { -if (asprintf (&bf,"%s/.build-id/%.2s/%s" , buildid_dir, - build_id_hex, build_id_hex +2 ) <0 ) -return NULL ; - }else -snprintf (bf, size,"%s/.build-id/%.2s/%s" , buildid_dir, - build_id_hex, build_id_hex +2 ); -return bf; +return build_id__filename (build_id_hex, bf, size); }#define dsos__for_each_with_build_id (pos, head) \
@@ -264,7 +286,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name, {const size_t size =PATH_MAX ;char *realname, *filename =zalloc (size), - *linkname =zalloc (size), *targetname; + *linkname =zalloc (size), *targetname, *tmp;int len, err =-1 ;bool slash = is_kallsyms || is_vdso;
@@ -297,13 +319,15 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name, goto out_free; } - len =scnprintf (linkname, size,"%s/.build-id/%.2s" , - buildid_dir, sbuild_id); +if (!build_id__filename (sbuild_id, linkname, size)) + goto out_free; + tmp =strrchr (linkname,'/' ); + *tmp ='\0' ;if (access (linkname,X_OK ) &&mkdir_p (linkname,0755 )) goto out_free; -snprintf (linkname + len, size - len,"/%s" , sbuild_id +2 ); + *tmp ='/' ; targetname = filename +strlen (buildid_dir) -5 ;memcpy (targetname,"../.." ,5 );
@@ -332,14 +356,14 @@ int build_id_cache__remove_s(const char *sbuild_id) {const size_t size =PATH_MAX ;char *filename =zalloc (size), - *linkname =zalloc (size); + *linkname =zalloc (size), *tmp;int err =-1 ;if (filename ==NULL || linkname ==NULL ) goto out_free; -snprintf (linkname, size,"%s/.build-id/%.2s/%s" , - buildid_dir, sbuild_id, sbuild_id +2 ); +if (!build_id__filename (sbuild_id, linkname, size)) + goto out_free;if (access (linkname,F_OK )) goto out_free;
@@ -353,8 +377,8 @@ int build_id_cache__remove_s(const char *sbuild_id)/* * Since the link is relative, we must make it absolute: */ -snprintf (linkname, size,"%s/.build-id/%.2s/%s" , - buildid_dir, sbuild_id, filename); + tmp =strrchr (linkname,'/' ) +1 ; +snprintf (tmp, size - (tmp - linkname),"%s" , filename);if (unlink (linkname)) goto out_free;
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 15/21 tools lib api debugfs: Add DEBUGFS_DEFAULT_PATH macro
In reply to Arnaldo Carvalho de MeloFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Instead of hard coding "/sys/kernel/debug" everywhere, create a macro to hold where the default path exists.
--- tools/lib/api/fs/debugfs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/lib/api/fs/debugfs.c +7 -3
@@ -10,10 +10,14 @@#include "debugfs.h" -char debugfs_mountpoint[PATH_MAX +1 ] ="/sys/kernel/debug" ; +#ifndef DEBUGFS_DEFAULT_PATH +#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug" +#endif + +char debugfs_mountpoint[PATH_MAX +1 ] =DEBUGFS_DEFAULT_PATH ;static const char *const debugfs_known_mountpoints[] = { -"/sys/kernel/debug" , +DEBUGFS_DEFAULT_PATH ,"/debug" ,0 , };
@@ -50,7 +54,7 @@ char *debugfs_mount(const char *mountpoint) mountpoint =getenv (PERF_DEBUGFS_ENVIRONMENT );/* if no environment variable, use default */ if (mountpoint ==NULL ) - mountpoint ="/sys/kernel/debug" ; + mountpoint =DEBUGFS_DEFAULT_PATH ; }if (mount (NULL , mountpoint,"debugfs" ,0 ,NULL ) <0 )
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 11/21 perf evlist: Fix typo in comment
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/evlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evlist.c +1 -1
@@ -1329,7 +1329,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar* writing exactly one byte, in workload.cork_fd, usually via * perf_evlist__start_workload(). * -* For cancelling the workload without actuallin running it, +* For cancelling the workload without actually running it, * the parent will just close workload.cork_fd, without writing * anything, i.e. read will return zero and we just exit() * here.
Signature · 1 line
1.9.3
Arnaldo Carvalho de Melo
maintainerPATCH 1/21 perf test: Fix dso cache testcase
In reply to Arnaldo Carvalho de MeloFrom: Namhyung Kim <[email protected]>
The current dso cache permits to keep dso->data.fd is open under a half of open file limit. But test__dso_data_cache() sets dso_cnt to limit / 2 + 1 so it'll reach the limit in the loop even though the loop count is one less than the dso_cnt and it makes the final dso__data_fd() after the loop meaningless.
I guess the intention was dsos[0]->data.fd is open before the last open and gets closed after it. So add an assert before the last open.
--- tools/perf/tests/dso-data.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/tests/dso-data.c +6 -3
@@ -243,8 +243,8 @@ int test__dso_data_cache(void) limit = nr *4 ;TEST_ASSERT_VAL ("failed to set file limit" , !set_fd_limit (limit)); -/* and this is now our dso open FDs limit + 1 extra */ - dso_cnt = limit /2 +1 ; +/* and this is now our dso open FDs limit */ + dso_cnt = limit /2 ;TEST_ASSERT_VAL ("failed to create dsos\n" , !dsos__create (dso_cnt,TEST_FILE_SIZE ));
@@ -268,7 +268,10 @@ int test__dso_data_cache(void) } } -/* open +1 dso over the allowed limit */ +/* verify the first one is already open */ +TEST_ASSERT_VAL ("dsos[0] is not open" , dsos[0 ]->data.fd !=-1 ); + +/* open +1 dso to reach the allowed limit */ fd =dso__data_fd (dsos[i], &machine);TEST_ASSERT_VAL ("failed to get fd" , fd >0 );
Signature · 1 line
1.9.3
Hi Arnaldo, Ingo,
What happened with this pull request? I already see in v4.0-rc2 changes additions to one requested by this pull request, but I don't see this series itself.
For example e370a3d57664cd5e39c0b95d157ebc841b568409 "perf symbols: Define EM_AARCH64 for older OSes" by David is already in v4.0-rc2 and it is supposed to be addition to "perf symbols: Ignore mapping symbols on aarch64" that is part of this pull request but it did not make into v4.0-rcX yet. Looks quite strange.
Thanks,
Victor
Quoted 131 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit
2fde4f94e0a9531251e706fa57131b51b0df042e:perf: Decouple unthrottling and rotating (2015-02-04 08:07:16 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingofor you to fetch changes up to
39f5704399042fff5f0d5f6af32bbbc3e787a897:perf tools: Define
_GNU_SOURCEonpthread_attr_setaffinity_npfeature check (2015-02-11 17:38:55 -0300)----------------------------------------------------------------
perf/core improvement and fixes:User visible:
- No need to explicitely enable evsels for workload started from perf, let it be enabled via perf_event_attr.enable_on_exec, removing some events that take place in the 'perf trace' before a workload is really started by it. (Arnaldo Carvalho de Melo)
- Fix to handle optimized not-inlined functions in 'perf probe' (Masami Hiramatsu)
- Update 'perf probe' man page (Masami Hiramatsu)
Infrastructure:
Arnaldo Carvalho de Melo (4):
- Introduce {trace_seq_do,event_format_}_fprintf functions to allow a default tracepoint field list printer to be used in tools that allows redirecting output to a file. (Arnaldo Carvalho de Melo)- The man page for
pthread_attr_set_affinity_npstates that_GNU_SOURCEmust be defined beforepthread.h, do it to fix the build in some systems (Josh Boyer)- Cleanups in 'perf buildid-cache' (Masami Hiramatsu)
- Fix dso cache test case (Namhyung Kim)
- Do Not rely on
dso__data_read_offset()to open DSO (Namhyung Kim)- Make perf aware of tracefs (Steven Rostedt).
- Fix build by defining
STT_GNU_IFUNCfor glibc 2.9 and older (Vinson Lee)- AArch64 symbol resolution fixes (Victor Kamensky)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Arnaldo Carvalho de Melo (4):
tools lib traceevent: Introducetrace_seq_do_fprintffunction perf tools: Introduceevent_format__fprintfmethod
perf trace: No need to enable evsels for workload started from perf perf evlist: Fix typo in commentJosh Boyer (1):
perf tools: Define_GNU_SOURCEonpthread_attr_setaffinity_npfeature checkMasami Hiramatsu (4):
perf probe: Fix to handle optimized not-inlined functions perf probe: Update man page
perf buildid-cache: Remove unneeded debugdir parameters perf buildid-cache: Consolidate .build-id cache path generatorsNamhyung Kim (3):
perf test: Fix dso cache testcase
perf tests: Do not rely ondso__data_read_offset()to open dso perf tools: Fix a dso open fail messageSteven Rostedt (Red Hat) (6):
perf tools: Do not check debugfs MAGIC for tracing files tools lib fs: Add helper to find mounted file systems tools lib api fs: Add tracefs mount helper functions tools lib api debugfs: AddDEBUGFS_DEFAULT_PATHmacro tools lib api fs: Add {tracefs,debugfs}_configured() functions perf tools: Make perf aware of tracefsVictor Kamensky (2):
perf symbols: Ignore mapping symbols on aarch64 perf symbols: debuglink should take symfs option into accountVinson Lee (1):
perf symbols: DefineSTT_GNU_IFUNCfor glibc 2.9 and older.tools/lib/api/Makefile | 4 ++ tools/lib/api/fs/debugfs.c | 69 +++++++--------------- tools/lib/api/fs/debugfs.h | 13 +---- tools/lib/api/fs/findfs.c | 63 ++++++++++++++++++++ tools/lib/api/fs/findfs.h | 23 ++++++++ tools/lib/api/fs/tracefs.c | 78 +++++++++++++++++++++++++ tools/lib/api/fs/tracefs.h | 21 +++++++ tools/lib/traceevent/event-parse.h | 2 + tools/lib/traceevent/trace-seq.c | 13 +++-- tools/perf/Documentation/perf-probe.txt | 16 +++++- tools/perf/builtin-buildid-cache.c | 37 ++++++------ tools/perf/builtin-trace.c | 4 +- tools/perf/config/feature-checks/Makefile | 2 +- tools/perf/tests/dso-data.c | 22 ++++--- tools/perf/tests/open-syscall-all-cpus.c | 7 ++- tools/perf/tests/open-syscall.c | 7 ++- tools/perf/tests/parse-events.c | 13 ++++- tools/perf/util/build-id.c | 96 +++++++++++++++++++------------ tools/perf/util/build-id.h | 4 +- tools/perf/util/cache.h | 1 + tools/perf/util/dso.c | 8 +-- tools/perf/util/dwarf-aux.c | 15 +++++ tools/perf/util/dwarf-aux.h | 3 + tools/perf/util/evlist.c | 3 +- tools/perf/util/parse-events.c | 19 ------ tools/perf/util/parse-events.h | 2 +- tools/perf/util/probe-event.c | 24 +++++--- tools/perf/util/probe-finder.c | 12 ++-- tools/perf/util/symbol-elf.c | 11 ++-- tools/perf/util/trace-event-parse.c | 12 +++- tools/perf/util/trace-event.h | 3 + tools/perf/util/util.c | 60 +++++++++++++++---- tools/perf/util/util.h | 1 + 33 files changed, 468 insertions(+), 200 deletions(-) create mode 100644 tools/lib/api/fs/findfs.c create mode 100644 tools/lib/api/fs/findfs.h create mode 100644 tools/lib/api/fs/tracefs.c create mode 100644 tools/lib/api/fs/tracefs.h
Quoted 3 lines · Victor Kamensky
Hi Arnaldo, Ingo,
What happened with this pull request? [...]
This pull request was for v4.1, and I merged it in:
commit 8a26ce4e544659256349551283414df504889a59
Merge: acba3c7e4652 726f3234dd12
Author: Ingo Molnar <[email protected]>
Date: Wed Feb 18 19:14:54 2015 +0100
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
User visible changes:
Quoted 9 lines
[...] I already see in v4.0-rc2 changes additions to one requested by this pull request, but I don't see this series itself.
For example
e370a3d57664cd5e39c0b95d157ebc841b568409"perf symbols: DefineEM_AARCH64for older OSes" by David is already in v4.0-rc2 and it is supposed to be addition to "perf symbols: Ignore mapping symbols on aarch64" that is part of this pull request but it did not make into v4.0-rcX yet. Looks quite strange.
If some commits of the v4.1 queue are needed in v4.0 as well then they should be cherry-picked back into the urgent queue.
But maybe e370a3d57 was merged prematurely - in that case it appears to be harmless and v4.1 will sort it out.
Arnaldo?
Thanks,
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · Victor Kamensky
Hi Arnaldo, Ingo,
What happened with this pull request? [...]
This pull request was for v4.1, and I merged it in:
Ok, I got it. Sorry I missed that before.
Quoted 21 lines
commit
8a26ce4e544659256349551283414df504889a59
Merge:acba3c7e4652726f3234dd12
Author: Ingo Molnar <[email protected]>
Date: Wed Feb 18 19:14:54 2015 +0100Merge tag 'perf-core-for-mingo' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/corePull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
User visible changes:
Quoted 9 lines
[...] I already see in v4.0-rc2 changes additions to one requested by this pull request, but I don't see this series itself.
For example
e370a3d57664cd5e39c0b95d157ebc841b568409"perf symbols: DefineEM_AARCH64for older OSes" by David is already in v4.0-rc2 and it is supposed to be addition to "perf symbols: Ignore mapping symbols on aarch64" that is part of this pull request but it did not make into v4.0-rcX yet. Looks quite strange.
Quoted 5 lines
If some commits of the v4.1 queue are needed in v4.0 as well then they should be cherry-picked back into the urgent queue.
But maybe
e370a3d57was merged prematurely - in that case it appears to be harmless and v4.1 will sort it out.
Yes, this merge is harmless. Indeed it should be OK with v4.1.
Thanks for explanation.
- Victor
Quoted 5 lines
Arnaldo?
Thanks,
Ingo