perf fixes and changes for v3.19, #2
Subsystems (4)
Linus,
Please pull the latest perf-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-for-linus
# HEAD: ac931f87a647ca156f65a4c00e7297165e4fa2d8 perf: Fix building warning on ARM 32
A kernel fix plus mostly tooling fixes, but also some tooling restructuring and cleanups.
Thanks,
Ingo
------------------>
Alexander Yarygin (1):
perf kvm stat live: Mark events as (x86 only) in help output
Arjun Sreedharan (1):
calloc/xcalloc: Fix argument order
Arnaldo Carvalho de Melo (22):
tools lib fs: Adopt filename__read_int from tools/perf/
tools lib fs: Add sysctl__read_int helper
perf tools: Use sysctl__read_int instead of ad-hoc copies
perf evlist: Introduce strerror_mmap method
perf trace: Provide a better explanation when mmap fails
perf evlist: Fixup brown paper bag on "hint" for --mmap-pages cmdline arg perf evlist: Clarify sterror_mmap variable names
perf evlist: Improve the strerror_mmap method
perf trace: Let the perf_evlist__mmap autosize the number of pages to use perf evlist: Do not use hard coded value for a mmap_pages default
tools: Move __ffs implementation to tools/include/asm-generic/bitops/__ffs.h
tools: Move code originally from linux/log2.h to tools/include/linux/
tools: Move code originally from asm-generic/atomic.h into tools/include/asm-generic/
tools: Whitespace prep patches for moving bitops.h
tools lib: Move asm-generic/bitops/find.h code to tools/include and tools/lib
tools: Introduce asm-generic/bitops.h
tools: Move bitops.h from tools/perf/util to tools/
tools: Adopt fls_long and deps
tools: Adopt rounddown_pow_of_two and deps
perf tools: Make the mmap length autotuning more robust
tools: Adopt roundup_pow_of_two
perf evlist: Use roundup_pow_of_two
Jiri Olsa (7):
perf tools: Use single strcmp call instead of two
perf buildid-cache: Remove extra debugdir variables
perf buildid cache: Fix -a segfault related to kcore handling
perf tools: Add --buildid-dir option to set cache directory
perf tests: Fix attr tests size values to cope with machine state on interrupt ABI changes perf/x86/intel/uncore: Make sure only uncore events are collected
perf: Fix events installation during moving group
Kan Liang (2):
perf callchain: Fixup parameter handling error message perf callchain: Move cpumode resolve code to add_callchain_ip
Mitchell Krome (1):
perf symbols: Fix use after free in filename__read_build_id
Rabin Vincent (3):
perf bench: Prepare memcpy for merge
perf bench: Merge memset into memcpy
perf bench: Fix memcpy/memset output
Tom Huynh (1):
perf hists browser: Change print format from %lu to %PRIu64
Wang Nan (1):
perf: Fix building warning on ARM 32
arch/x86/kernel/cpu/perf_event_intel_uncore.c | 22 +- kernel/events/core.c | 4 +- scripts/kconfig/mconf.c | 4 +- tools/include/asm-generic/bitops.h | 27 +++ tools/include/asm-generic/bitops/__ffs.h | 43 ++++ tools/include/asm-generic/bitops/__fls.h | 1 + tools/include/asm-generic/bitops/atomic.h | 22 ++ tools/include/asm-generic/bitops/find.h | 33 +++ tools/include/asm-generic/bitops/fls.h | 1 + tools/include/asm-generic/bitops/fls64.h | 1 + tools/include/linux/bitops.h | 53 +++++ tools/include/linux/log2.h | 185 ++++++++++++++++ tools/lib/api/fs/fs.c | 34 +++ tools/lib/api/fs/fs.h | 3 + tools/lib/util/find_next_bit.c | 89 ++++++++ tools/perf/Documentation/perf.txt | 4 + tools/perf/MANIFEST | 16 +- tools/perf/Makefile.perf | 15 +- tools/perf/bench/mem-memcpy.c | 286 +++++++++++++++++------- tools/perf/bench/mem-memset.c | 304 -------------------------- tools/perf/builtin-buildid-cache.c | 13 +- tools/perf/builtin-kvm.c | 3 +- tools/perf/builtin-trace.c | 14 +- tools/perf/perf.c | 14 +- tools/perf/tests/attr/base-record | 2 +- tools/perf/tests/attr/base-stat | 2 +- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/hist.c | 4 +- tools/perf/util/build-id.c | 9 +- tools/perf/util/callchain.c | 2 +- tools/perf/util/config.c | 10 +- tools/perf/util/evlist.c | 57 ++++- tools/perf/util/evlist.h | 1 + tools/perf/util/include/linux/bitops.h | 162 -------------- tools/perf/util/machine.c | 72 +++--- tools/perf/util/record.c | 11 +- tools/perf/util/srcline.c | 12 +- tools/perf/util/symbol-minimal.c | 8 +- tools/perf/util/util.c | 26 +-- tools/perf/util/util.h | 34 +-- tools/thermal/tmon/sysfs.c | 6 +- 41 files changed, 897 insertions(+), 714 deletions(-) create mode 100644 tools/include/asm-generic/bitops.h create mode 100644 tools/include/asm-generic/bitops/__ffs.h create mode 100644 tools/include/asm-generic/bitops/__fls.h create mode 100644 tools/include/asm-generic/bitops/atomic.h create mode 100644 tools/include/asm-generic/bitops/find.h create mode 100644 tools/include/asm-generic/bitops/fls.h create mode 100644 tools/include/asm-generic/bitops/fls64.h create mode 100644 tools/include/linux/bitops.h create mode 100644 tools/include/linux/log2.h create mode 100644 tools/lib/util/find_next_bit.c delete mode 100644 tools/perf/bench/mem-memset.c delete mode 100644 tools/perf/util/include/linux/bitops.h
arch/x86/kernel/cpu/perf_event_intel_uncore.c +19 -3
@@ -276,6 +276,17 @@ static struct intel_uncore_box *uncore_alloc_box(struct intel_uncore_type *type,return box; } +/* +* Using uncore_pmu_event_init pmu event_init callback +* as a detection point for uncore events. +*/ +static int uncore_pmu_event_init (struct perf_event *event); + +static bool is_uncore_event (struct perf_event *event) +{ +return event->pmu->event_init == uncore_pmu_event_init; +} +static int uncore_collect_events (struct intel_uncore_box *box,struct perf_event *leader,bool dogrp) {
@@ -290,13 +301,18 @@ uncore_collect_events(struct intel_uncore_box *box, struct perf_event *leader, breturn -EINVAL ; n = box->n_events; - box->event_list[n] = leader; - n++; + +if (is_uncore_event (leader)) { + box->event_list[n] = leader; + n++; + } +if (!dogrp)return n;list_for_each_entry (event, &leader->sibling_list, group_entry) { -if (event->state <=PERF_EVENT_STATE_OFF ) +if (!is_uncore_event (event) || + event->state <=PERF_EVENT_STATE_OFF )continue ;if (n >= max_count)
kernel/events/core.c +2 -2
@@ -7477,11 +7477,11 @@ SYSCALL_DEFINE5(perf_event_open,if (move_group) {synchronize_rcu (); -perf_install_in_context (ctx, group_leader, event->cpu); +perf_install_in_context (ctx, group_leader, group_leader->cpu);get_ctx (ctx);list_for_each_entry (sibling, &group_leader->sibling_list, group_entry) { -perf_install_in_context (ctx, sibling, event->cpu); +perf_install_in_context (ctx, sibling, sibling->cpu);get_ctx (ctx); } }
scripts/kconfig/mconf.c +2 -2
@@ -330,10 +330,10 @@ static void set_subtitle(void)list_for_each_entry (sp, &trail, entries) {if (sp->text) {if (pos) { - pos->next =xcalloc (sizeof (*pos),1 ); + pos->next =xcalloc (1 ,sizeof (*pos)); pos = pos->next; }else { - subtitles = pos =xcalloc (sizeof (*pos),1 ); + subtitles = pos =xcalloc (1 ,sizeof (*pos)); } pos->text = sp->text; }
tools/include/asm-generic/bitops.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef __TOOLS_ASM_GENERIC_BITOPS_H +#define __TOOLS_ASM_GENERIC_BITOPS_H + +/* +* tools/ copied this from include/asm-generic/bitops.h, bit by bit as it needed +* some functions. +* +* For the benefit of those who are trying to port Linux to another +* architecture, here are some C-language equivalents. You should +* recode these in the native assembly language, if at all possible. +* +* C language equivalents written by Theodore Ts'o, 9/26/92 +*/ + +#include <asm-generic/bitops/__ffs.h> +#include <asm-generic/bitops/fls.h> +#include <asm-generic/bitops/__fls.h> +#include <asm-generic/bitops/fls64.h> +#include <asm-generic/bitops/find.h> + +#ifndef _TOOLS_LINUX_BITOPS_H_ +#error only <linux/bitops.h> can be included directly +#endif + +#include <asm-generic/bitops/atomic.h> + +#endif /* __TOOLS_ASM_GENERIC_BITOPS_H */
tools/include/asm-generic/bitops/__ffs.h new file +43 -0
43 lines not on this page · raw message
tools/include/asm-generic/bitops/__fls.h new file +1 -0
@@ -0,0 +1 @@ +#include <../../../../include/asm-generic/bitops/__fls.h>
tools/include/asm-generic/bitops/atomic.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ +#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ + +#include <asm/types.h> + +static inline void set_bit (int nr,unsigned long *addr) +{ + addr[nr / __BITS_PER_LONG] |=1UL << (nr % __BITS_PER_LONG); +} + +static inline void clear_bit (int nr,unsigned long *addr) +{ + addr[nr / __BITS_PER_LONG] &= ~(1UL << (nr % __BITS_PER_LONG)); +} + +static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) +{ +return ((1UL << (nr % __BITS_PER_LONG)) & + (((unsigned long *)addr)[nr / __BITS_PER_LONG])) !=0 ; +} + +#endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ */
tools/include/asm-generic/bitops/find.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ +#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ + +#ifndef find_next_bit +/** +* find_next_bit - find the next set bit in a memory region +* @addr: The address to base the search on +* @offset: The bitnumber to start searching at +* @size: The bitmap size in bits +* +* Returns the bit number for the next set bit +* If no bits are set, returns @size. +*/ +extern unsigned long find_next_bit (const unsigned long *addr,unsigned long + size,unsigned long offset); +#endif + +#ifndef find_first_bit + +/** +* find_first_bit - find the first set bit in a memory region +* @addr: The address to start the search at +* @size: The maximum number of bits to search +* +* Returns the bit number of the first set bit. +* If no bits are set, returns @size. +*/ +extern unsigned long find_first_bit (const unsigned long *addr, +unsigned long size); + +#endif /* find_first_bit */ + +#endif /*_TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ */
tools/include/asm-generic/bitops/fls.h new file +1 -0
@@ -0,0 +1 @@ +#include <../../../../include/asm-generic/bitops/fls.h>
tools/include/asm-generic/bitops/fls64.h new file +1 -0
@@ -0,0 +1 @@ +#include <../../../../include/asm-generic/bitops/fls64.h>
tools/include/linux/bitops.h new file +53 -0
53 lines not on this page · raw message
tools/include/linux/log2.h new file +185 -0
185 lines not on this page · raw message
tools/lib/api/fs/fs.c +34 -0
@@ -7,6 +7,10 @@#include <stdlib.h> #include <string.h> #include <sys/vfs.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> #include "debugfs.h" #include "fs.h"
@@ -163,3 +167,33 @@ const char *name##__mountpoint(void) \FS__MOUNTPOINT (sysfs,FS__SYSFS );FS__MOUNTPOINT (procfs,FS__PROCFS ); + +int filename__read_int (const char *filename,int *value) +{ +char line[64 ]; +int fd =open (filename,O_RDONLY ), err =-1 ; + +if (fd <0 ) +return -1 ; + +if (read (fd, line,sizeof (line)) >0 ) { + *value =atoi (line); + err =0 ; + } + +close (fd); +return err; +} + +int sysctl__read_int (const char *sysctl,int *value) +{ +char path[PATH_MAX ]; +const char *procfs =procfs__mountpoint (); + +if (!procfs) +return -1 ; + +snprintf (path,sizeof (path),"%s/sys/%s" , procfs, sysctl); + +return filename__read_int (path, value); +}
tools/lib/api/fs/fs.h +3 -0
@@ -11,4 +11,7 @@const char *sysfs__mountpoint (void );const char *procfs__mountpoint (void ); + +int filename__read_int (const char *filename,int *value); +int sysctl__read_int (const char *sysctl,int *value);#endif /* __API_FS__ */
tools/lib/util/find_next_bit.c new file +89 -0
89 lines not on this page · raw message
tools/perf/Documentation/perf.txt +4 -0
@@ -18,6 +18,10 @@ OPTIONS --debug verbose # sets verbose = 1 --debug verbose=2 # sets verbose = 2 +--buildid-dir:: + Setup buildid cache directory. It has higher priority than + buildid.dir config file option. + DESCRIPTION ----------- Performance counters for Linux are a new kernel-based subsystem
tools/perf/MANIFEST +15 -1
@@ -4,17 +4,31 @@ tools/lib/traceevent tools/lib/api tools/lib/symbol/kallsyms.c tools/lib/symbol/kallsyms.h +tools/lib/util/find_next_bit.c tools/include/asm/bug.h +tools/include/asm-generic/bitops/atomic.h +tools/include/asm-generic/bitops/__ffs.h +tools/include/asm-generic/bitops/__fls.h +tools/include/asm-generic/bitops/find.h +tools/include/asm-generic/bitops/fls64.h +tools/include/asm-generic/bitops/fls.h +tools/include/asm-generic/bitops.h +tools/include/linux/bitops.h tools/include/linux/compiler.h -tools/include/linux/hash.h tools/include/linux/export.h +tools/include/linux/hash.h +tools/include/linux/log2.h tools/include/linux/types.h +include/asm-generic/bitops/fls64.h +include/asm-generic/bitops/__fls.h +include/asm-generic/bitops/fls.h include/linux/const.h include/linux/perf_event.h include/linux/rbtree.h include/linux/list.h include/linux/hash.h include/linux/stringify.h +lib/find_next_bit.c lib/rbtree.c include/linux/swab.h arch/*/include/asm/unistd*.h
tools/perf/Makefile.perf +13 -2
@@ -231,8 +231,16 @@ LIB_H += ../../include/uapi/linux/const.h LIB_H += ../include/linux/hash.h LIB_H += ../../include/linux/stringify.h LIB_H += util/include/linux/bitmap.h -LIB_H += util/include/linux/bitops.h +LIB_H += ../include/linux/bitops.h +LIB_H += ../include/asm-generic/bitops/atomic.h +LIB_H += ../include/asm-generic/bitops/find.h +LIB_H += ../include/asm-generic/bitops/fls64.h +LIB_H += ../include/asm-generic/bitops/fls.h +LIB_H += ../include/asm-generic/bitops/__ffs.h +LIB_H += ../include/asm-generic/bitops/__fls.h +LIB_H += ../include/asm-generic/bitops.h LIB_H += ../include/linux/compiler.h +LIB_H += ../include/linux/log2.h LIB_H += util/include/linux/const.h LIB_H += util/include/linux/ctype.h LIB_H += util/include/linux/kernel.h
@@ -335,6 +343,7 @@ LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/evlist.o LIB_OBJS += $(OUTPUT)util/evsel.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o +LIB_OBJS += $(OUTPUT)util/find_next_bit.o LIB_OBJS += $(OUTPUT)util/help.o LIB_OBJS += $(OUTPUT)util/kallsyms.o LIB_OBJS += $(OUTPUT)util/levenshtein.o
@@ -458,7 +467,6 @@ BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o endif BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o -BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o BUILTIN_OBJS += $(OUTPUT)bench/futex-hash.o BUILTIN_OBJS += $(OUTPUT)bench/futex-wake.o BUILTIN_OBJS += $(OUTPUT)bench/futex-requeue.o
@@ -735,6 +743,9 @@ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< +$(OUTPUT)util/find_next_bit.o: ../lib/util/find_next_bit.c $(OUTPUT)PERF-CFLAGS + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< + $(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $<
tools/perf/bench/mem-memcpy.c +202 -84
396 lines not on this page · raw message
tools/perf/bench/mem-memset.c deleted +0 -304
304 lines not on this page · raw message
tools/perf/builtin-buildid-cache.c +5 -8
@@ -285,12 +285,11 @@ int cmd_buildid_cache(int argc, const char **argv,struct str_node *pos;int ret =0 ;bool force = false; -char debugdir[PATH_MAX ];char const *add_name_list_str =NULL , *remove_name_list_str =NULL , *missing_filename =NULL , *update_name_list_str =NULL , - *kcore_filename; + *kcore_filename =NULL ;char sbuf[STRERR_BUFSIZE ];struct perf_data_file file = {
@@ -335,13 +334,11 @@ int cmd_buildid_cache(int argc, const char **argv,setup_pager (); -snprintf (debugdir,sizeof (debugdir),"%s" , buildid_dir); -if (add_name_list_str) { list =strlist__new (true, add_name_list_str);if (list) {strlist__for_each (pos, list) -if (build_id_cache__add_file (pos->s, debugdir)) { +if (build_id_cache__add_file (pos->s, buildid_dir)) {if (errno ==EEXIST ) {pr_debug ("%s already in the cache\n" , pos->s);
@@ -359,7 +356,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, debugdir)) { +if (build_id_cache__remove_file (pos->s, buildid_dir)) {if (errno ==ENOENT ) {pr_debug ("%s wasn't in the cache\n" , pos->s);
@@ -380,7 +377,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, debugdir)) { +if (build_id_cache__update_file (pos->s, buildid_dir)) {if (errno ==ENOENT ) {pr_debug ("%s wasn't in the cache\n" , pos->s);
@@ -395,7 +392,7 @@ int cmd_buildid_cache(int argc, const char **argv, }if (kcore_filename && -build_id_cache__add_kcore (kcore_filename, debugdir, force)) +build_id_cache__add_kcore (kcore_filename, buildid_dir, force))pr_warning ("Couldn't add %s\n" , kcore_filename); out:
tools/perf/builtin-kvm.c +2 -1
@@ -1293,7 +1293,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,OPT_UINTEGER ('d' ,"display" , &kvm->display_time,"time in seconds between display updates" ),OPT_STRING (0 ,"event" , &kvm->report_event,"report event" , -"event for reporting: vmexit, mmio, ioport" ), +"event for reporting: " +"vmexit, mmio (x86 only), ioport (x86 only)" ),OPT_INTEGER (0 ,"vcpu" , &kvm->trace_vcpu,"vcpu id to report" ), OPT_STRING('k', "key", &kvm->sort_key, "sort-key",
tools/perf/builtin-trace.c +7 -7
@@ -2045,7 +2045,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv)unsigned long before;const bool forks = argc >0 ;bool draining = false; -char sbuf[STRERR_BUFSIZE ]; trace->live = true;
@@ -2106,11 +2105,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv) goto out_error_open; err =perf_evlist__mmap (evlist, trace->opts.mmap_pages, false); -if (err <0 ) { -fprintf (trace->output,"Couldn't mmap the events: %s\n" , -strerror_r (errno, sbuf,sizeof (sbuf))); - goto out_delete_evlist; - } +if (err <0 ) + goto out_error_mmap;perf_evlist__enable (evlist);
@@ -2210,6 +2206,10 @@ static int trace__run(struct trace *trace, int argc, const char **argv)perf_evlist__strerror_tp (evlist, errno, errbuf,sizeof (errbuf)); goto out_error; +out_error_mmap: +perf_evlist__strerror_mmap (evlist, errno, errbuf,sizeof (errbuf)); + goto out_error; + out_error_open:perf_evlist__strerror_open (evlist, errno, errbuf,sizeof (errbuf));
@@ -2485,7 +2485,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) .user_freq = UINT_MAX, .user_interval = ULLONG_MAX, .no_buffering = true, - .mmap_pages = 1024, + .mmap_pages = UINT_MAX, }, .output = stdout, .show_comm = true,
tools/perf/perf.c +12 -2
@@ -200,6 +200,16 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) *envchanged =1 ; (*argv)++; (*argc)--; + }else if (!strcmp (cmd,"--buildid-dir" )) { +if (*argc <2 ) { +fprintf (stderr,"No directory given for --buildid-dir.\n" ); +usage (perf_usage_string); + } +set_buildid_dir ((*argv)[1 ]); +if (envchanged) + *envchanged =1 ; + (*argv)++; + (*argc)--; }else if (!prefixcmp (cmd,CMD_DEBUGFS_DIR )) {perf_debugfs_set_path (cmd +strlen (CMD_DEBUGFS_DIR ));fprintf (stderr,"dir: %s\n" , debugfs_mountpoint);
@@ -499,7 +509,7 @@ int main(int argc, const char **argv) }if (!prefixcmp (cmd,"trace" )) {#ifdef HAVE_LIBAUDIT_SUPPORT -set_buildid_dir (); +set_buildid_dir (NULL );setup_path (); argv[0 ] ="trace" ;return cmd_trace (argc, argv,NULL );
@@ -514,7 +524,7 @@ int main(int argc, const char **argv) argc--;handle_options (&argv, &argc,NULL );commit_pager_choice (); -set_buildid_dir (); +set_buildid_dir (NULL );if (argc >0 ) {if (!prefixcmp (argv[0 ],"--" ))
tools/perf/tests/attr/base-record +1 -1
@@ -5,7 +5,7 @@ group_fd=-1 flags=0|8 cpu=* type=0|1 -size=96 +size=104 config=0 sample_period=4000 sample_type=263
tools/perf/tests/attr/base-stat +1 -1
@@ -5,7 +5,7 @@ group_fd=-1 flags=0|8 cpu=* type=0 -size=96 +size=104 config=0 sample_period=0 sample_type=0
tools/perf/ui/browsers/hists.c +1 -1
@@ -1252,7 +1252,7 @@ static int hists__browser_title(struct hists *hists, nr_samples =convert_unit (nr_samples, &unit); printed =scnprintf (bf, size, -"Samples: %lu%c of event '%s', Event count (approx.): %lu" , +"Samples: %lu%c of event '%s', Event count (approx.): %" PRIu64, nr_samples, unit, ev_name, nr_events);
tools/perf/ui/hist.c +2 -2
@@ -162,8 +162,8 @@ static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,return ret; nr_members = evsel->nr_members; - fields_a =calloc (sizeof (*fields_a), nr_members); - fields_b =calloc (sizeof (*fields_b), nr_members); + fields_a =calloc (nr_members,sizeof (*fields_a)); + fields_b =calloc (nr_members,sizeof (*fields_b));if (!fields_a || !fields_b) goto out;
tools/perf/util/build-id.c +3 -6
@@ -410,21 +410,18 @@ int perf_session__cache_build_ids(struct perf_session *session) {struct rb_node *nd;int ret; -char debugdir[PATH_MAX ];if (no_buildid_cache)return 0 ; -snprintf (debugdir,sizeof (debugdir),"%s" , buildid_dir); - -if (mkdir (debugdir,0755 ) !=0 && errno !=EEXIST ) +if (mkdir (buildid_dir,0755 ) !=0 && errno !=EEXIST )return -1 ; - ret =machine__cache_build_ids (&session->machines.host, debugdir); + ret =machine__cache_build_ids (&session->machines.host, buildid_dir);for (nd =rb_first (&session->machines.guests); nd; nd =rb_next (nd)) { struct machine *pos = rb_entry(nd, struct machine, rb_node); - ret |=machine__cache_build_ids (pos, debugdir); + ret |=machine__cache_build_ids (pos, buildid_dir); }return ret ?-1 :0 ; }
tools/perf/util/callchain.c +1 -1
@@ -77,7 +77,7 @@ int parse_callchain_record_opt(const char *arg) ret =0 ; }else pr_err ("callchain: No more arguments " -"needed for -g fp\n" ); +"needed for --call-graph fp\n" );break ;#ifdef HAVE_DWARF_UNWIND_SUPPORT
tools/perf/util/config.c +6 -4
@@ -522,7 +522,7 @@ static int buildid_dir_command_config(const char *var, const char *value,const char *v;/* same dir for all commands */ -if (!prefixcmp (var,"buildid." ) && !strcmp (var +8 ,"dir" )) { +if (!strcmp (var,"buildid.dir" )) { v =perf_config_dirname (var, value);if (!v)return -1 ;
@@ -539,12 +539,14 @@ static void check_buildid_dir_config(void)perf_config (buildid_dir_command_config, &c); } -void set_buildid_dir (void ) +void set_buildid_dir (const char *dir) { - buildid_dir[0 ] ='\0' ; +if (dir) +scnprintf (buildid_dir,MAXPATHLEN -1 ,"%s" , dir);/* try config file */ -check_buildid_dir_config (); +if (buildid_dir[0 ] =='\0' ) +check_buildid_dir_config ();/* default to $HOME/.debug */ if (buildid_dir[0 ] =='\0' ) {
tools/perf/util/evlist.c +52 -5
87 lines not on this page · raw message
tools/perf/util/evlist.h +1 -0
@@ -185,6 +185,7 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);int perf_evlist__strerror_tp (struct perf_evlist *evlist,int err,char *buf,size_t size);int perf_evlist__strerror_open (struct perf_evlist *evlist,int err,char *buf,size_t size); +int perf_evlist__strerror_mmap (struct perf_evlist *evlist,int err,char *buf,size_t size);static inline unsigned int perf_mmap__read_head (struct perf_mmap *mm) {
tools/perf/util/include/linux/bitops.h deleted +0 -162
162 lines not on this page · raw message
tools/perf/util/machine.c +35 -37
111 lines not on this page · raw message
tools/perf/util/record.c +1 -10
@@ -137,16 +137,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts)static int get_max_rate (unsigned int *rate) { -char path[PATH_MAX ]; -const char *procfs =procfs__mountpoint (); - -if (!procfs) -return -1 ; - -snprintf (path,PATH_MAX , -"%s/sys/kernel/perf_event_max_sample_rate" , procfs); - -return filename__read_int (path, (int *) rate); +return sysctl__read_int ("kernel/perf_event_max_sample_rate" , (int *)rate); }static int record_opts__config_freq (struct record_opts *opts)
tools/perf/util/srcline.c +6 -6
@@ -20,7 +20,7 @@struct a2l_data {const char *input; -unsigned long addr; +u64 addr;bool found;const char *filename;
@@ -147,7 +147,7 @@ static void addr2line_cleanup(struct a2l_data *a2l)free (a2l); } -static int addr2line (const char *dso_name,unsigned long addr, +static int addr2line (const char *dso_name,u64 addr,char **file,unsigned int *line,struct dso *dso) {int ret =0 ;
@@ -193,7 +193,7 @@ void dso__free_a2l(struct dso *dso)#else /* HAVE_LIBBFD_SUPPORT */ -static int addr2line (const char *dso_name,unsigned long addr, +static int addr2line (const char *dso_name,u64 addr,char **file,unsigned int *line_nr,struct dso *dso__maybe_unused ) {
@@ -252,7 +252,7 @@ void dso__free_a2l(struct dso *dso __maybe_unused)*/ #define A2L_FAIL_LIMIT 123 -char *get_srcline (struct dso *dso,unsigned long addr,struct symbol *sym, +char *get_srcline (struct dso *dso,u64 addr,struct symbol *sym,bool show_sym) {char *file =NULL ;
@@ -293,10 +293,10 @@ char *get_srcline(struct dso *dso, unsigned long addr, struct symbol *sym,dso__free_a2l (dso); }if (sym) { -if (asprintf (&srcline,"%s+%ld" , show_sym ? sym->name :"" , +if (asprintf (&srcline,"%s+%" PRIu64, show_sym ? sym->name :"" , addr - sym->start) <0 )return SRCLINE_UNKNOWN ; - }else if (asprintf (&srcline,"%s[%lx]" , dso->short_name, addr) <0 ) + }else if (asprintf (&srcline,"%s[%" PRIx64"]" , dso->short_name, addr) <0 )return SRCLINE_UNKNOWN ;return srcline; }
tools/perf/util/symbol-minimal.c +6 -2
@@ -129,6 +129,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)for (i =0 , phdr = buf; i < ehdr.e_phnum; i++, phdr++) {void *tmp; +long offset;if (need_swap) { phdr->p_type =bswap_32 (phdr->p_type);
@@ -140,12 +141,13 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)continue ; buf_size = phdr->p_filesz; + offset = phdr->p_offset; tmp =realloc (buf, buf_size);if (tmp ==NULL ) goto out_free; buf = tmp; -fseek (fp, phdr->p_offset,SEEK_SET ); +fseek (fp, offset,SEEK_SET );if (fread (buf, buf_size,1 , fp) !=1 ) goto out_free;
@@ -178,6 +180,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)for (i =0 , phdr = buf; i < ehdr.e_phnum; i++, phdr++) {void *tmp; +long offset;if (need_swap) { phdr->p_type =bswap_32 (phdr->p_type);
@@ -189,12 +192,13 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)continue ; buf_size = phdr->p_filesz; + offset = phdr->p_offset; tmp =realloc (buf, buf_size);if (tmp ==NULL ) goto out_free; buf = tmp; -fseek (fp, phdr->p_offset,SEEK_SET ); +fseek (fp, offset,SEEK_SET );if (fread (buf, buf_size,1 , fp) !=1 ) goto out_free;
tools/perf/util/util.c +1 -25
@@ -442,23 +442,6 @@ unsigned long parse_tag_value(const char *str, struct parse_tag *tags)return (unsigned long )-1 ; } -int filename__read_int (const char *filename,int *value) -{ -char line[64 ]; -int fd =open (filename,O_RDONLY ), err =-1 ; - -if (fd <0 ) -return -1 ; - -if (read (fd, line,sizeof (line)) >0 ) { - *value =atoi (line); - err =0 ; - } - -close (fd); -return err; -} -int filename__read_str (const char *filename,char **buf,size_t *sizep) {size_t size =0 , alloc_size =0 ;
@@ -523,16 +506,9 @@ const char *get_filename_for_perf_kvm(void)int perf_event_paranoid (void ) { -char path[PATH_MAX ]; -const char *procfs =procfs__mountpoint ();int value; -if (!procfs) -return INT_MAX ; - -scnprintf (path,PATH_MAX ,"%s/sys/kernel/perf_event_paranoid" , procfs); - -if (filename__read_int (path, &value)) +if (sysctl__read_int ("kernel/perf_event_paranoid" , &value))return INT_MAX ;return value;
tools/perf/util/util.h +2 -32
@@ -153,7 +153,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))extern void set_die_routine (void (*routine)(const char *err,va_list params)NORETURN );extern int prefixcmp (const char *str,const char *prefix); -extern void set_buildid_dir (void ); +extern void set_buildid_dir (const char *dir);static inline const char *skip_prefix (const char *str,const char *prefix) {
@@ -269,35 +269,6 @@ void event_attr_init(struct perf_event_attr *attr);#define _STR (x) #x#define STR (x) _STR(x) -/* -* Determine whether some value is a power of two, where zero is -* *not* considered a power of two. -*/ - -static inline __attribute__((const)) -bool is_power_of_2 (unsigned long n) -{ -return (n !=0 && ((n & (n -1 )) ==0 )); -} - -static inline unsigned next_pow2 (unsigned x) -{ -if (!x) -return 1 ; -return 1ULL << (32 -__builtin_clz (x -1 )); -} - -static inline unsigned long next_pow2_l (unsigned long x) -{ -#if BITS_PER_LONG ==64 -if (x <= (1UL <<31 )) -return next_pow2 (x); -return (unsigned long )next_pow2 (x >>32 ) <<32 ; -#else -return next_pow2 (x); -#endif -} -size_t hex_width (u64 v);int hex2u64 (const char *ptr,u64 *val);
@@ -339,11 +310,10 @@ static inline int path__join3(char *bf, size_t size,struct dso ;struct symbol ; -char *get_srcline (struct dso *dso,unsigned long addr,struct symbol *sym, +char *get_srcline (struct dso *dso,u64 addr,struct symbol *sym,bool show_sym);void free_srcline (char *srcline); -int filename__read_int (const char *filename,int *value);int filename__read_str (const char *filename,char **buf,size_t *sizep);int perf_event_paranoid (void );
tools/thermal/tmon/sysfs.c +3 -3
@@ -446,7 +446,7 @@ int probe_thermal_sysfs(void)return -1 ; } - ptdata.tzi =calloc (sizeof (struct tz_info ), ptdata.max_tz_instance+1 ); + ptdata.tzi =calloc (ptdata.max_tz_instance+1 ,sizeof (struct tz_info ));if (!ptdata.tzi) {fprintf (stderr,"Err: allocate tz_info\n" );return -1 ;
@@ -454,8 +454,8 @@ int probe_thermal_sysfs(void)/* we still show thermal zone information if there is no cdev */ if (ptdata.nr_cooling_dev) { - ptdata.cdi =calloc (sizeof (struct cdev_info ), - ptdata.max_cdev_instance +1 ); + ptdata.cdi =calloc (ptdata.max_cdev_instance +1 , +sizeof (struct cdev_info ));if (!ptdata.cdi) {free (ptdata.tzi);fprintf (stderr,"Err: allocate cdev_info\n" );