Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf updates/fixes from Ingo Molnar:
"Mostly tooling updates, but also two kernel fixes: a call chain
handling robustness fix and an x86 PMU driver event definition fix"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf/callchain: Force USER_DS when invoking perf_callchain_user()
tools build: Fixup sched_getcpu feature test
perf tests kmod-path: Don't fail if compressed modules aren't supported
perf annotate: Fix AArch64 comment char
perf tools: Fix spelling mistakes
perf/x86: Fix Broadwell-EP DRAM RAPL events
perf config: Refactor a duplicated code for obtaining config file name
perf symbols: Allow user probes on versioned symbols
perf symbols: Accept symbols starting at address 0
tools lib string: Adopt prefixcmp() from perf and subcmd
perf units: Move parse_tag_value() to units.[ch]
perf ui gtk: Move gtk .so name to the only place where it is used
perf tools: Move HAS_BOOL define to where perl headers are used
perf memswap: Split the byteswap memory range wrappers from util.[ch]
perf tools: Move event prototypes from util.h to event.h
perf buildid: Move prototypes from util.h to build-id.h

+252 -167
+1 -1
arch/x86/events/intel/rapl.c
··· 761 761 762 762 X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_CORE, hsw_rapl_init), 763 763 X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_GT3E, hsw_rapl_init), 764 - X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_X, hsw_rapl_init), 764 + X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_X, hsx_rapl_init), 765 765 X86_RAPL_MODEL_MATCH(INTEL_FAM6_BROADWELL_XEON_D, hsw_rapl_init), 766 766 767 767 X86_RAPL_MODEL_MATCH(INTEL_FAM6_XEON_PHI_KNL, knl_rapl_init),
+6
kernel/events/callchain.c
··· 229 229 } 230 230 231 231 if (regs) { 232 + mm_segment_t fs; 233 + 232 234 if (crosstask) 233 235 goto exit_put; 234 236 235 237 if (add_mark) 236 238 perf_callchain_store_context(&ctx, PERF_CONTEXT_USER); 239 + 240 + fs = get_fs(); 241 + set_fs(USER_DS); 237 242 perf_callchain_user(&ctx, regs); 243 + set_fs(fs); 238 244 } 239 245 } 240 246
+2
tools/build/feature/test-sched_getcpu.c
··· 1 + #ifndef _GNU_SOURCE 1 2 #define _GNU_SOURCE 3 + #endif 2 4 #include <sched.h> 3 5 4 6 int main(void)
+2
tools/include/linux/string.h
··· 18 18 19 19 char *str_error_r(int errnum, char *buf, size_t buflen); 20 20 21 + int prefixcmp(const char *str, const char *prefix); 22 + 21 23 #endif /* _LINUX_STRING_H_ */
+9
tools/lib/string.c
··· 87 87 } 88 88 return ret; 89 89 } 90 + 91 + int prefixcmp(const char *str, const char *prefix) 92 + { 93 + for (; ; str++, prefix++) 94 + if (!*prefix) 95 + return 0; 96 + else if (*str != *prefix) 97 + return (unsigned char)*prefix - (unsigned char)*str; 98 + }
+1
tools/lib/subcmd/help.c
··· 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 + #include <linux/string.h> 4 5 #include <termios.h> 5 6 #include <sys/ioctl.h> 6 7 #include <sys/types.h>
+1
tools/lib/subcmd/parse-options.c
··· 1 1 #include <linux/compiler.h> 2 + #include <linux/string.h> 2 3 #include <linux/types.h> 3 4 #include <stdio.h> 4 5 #include <stdlib.h>
-9
tools/lib/subcmd/subcmd-util.h
··· 79 79 free(tmp); 80 80 } 81 81 82 - static inline int prefixcmp(const char *str, const char *prefix) 83 - { 84 - for (; ; str++, prefix++) 85 - if (!*prefix) 86 - return 0; 87 - else if (*str != *prefix) 88 - return (unsigned char)*prefix - (unsigned char)*str; 89 - } 90 - 91 82 #endif /* __SUBCMD_UTIL_H */
+2 -2
tools/perf/Documentation/perf-c2c.txt
··· 76 76 77 77 -c:: 78 78 --coalesce:: 79 - Specify sorintg fields for single cacheline display. 79 + Specify sorting fields for single cacheline display. 80 80 Following fields are available: tid,pid,iaddr,dso 81 81 (see COALESCE) 82 82 ··· 106 106 107 107 -d:: 108 108 --display:: 109 - Siwtch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. 109 + Switch to HITM type (rmt, lcl) to display and sort on. Total HITMs as default. 110 110 111 111 C2C RECORD 112 112 ----------
+1 -1
tools/perf/Documentation/perf-record.txt
··· 225 225 the libunwind or libdw library) should be used instead. 226 226 Using the "lbr" method doesn't require any compiler options. It 227 227 will produce call graphs from the hardware LBR registers. The 228 - main limition is that it is only available on new Intel 228 + main limitation is that it is only available on new Intel 229 229 platforms, such as Haswell. It can only get user call chain. It 230 230 doesn't work with branch stack sampling at the same time. 231 231
+3 -3
tools/perf/Documentation/perf-report.txt
··· 182 182 --parent=<regex>:: 183 183 A regex filter to identify parent. The parent is a caller of this 184 184 function and searched through the callchain, thus it requires callchain 185 - information recorded. The pattern is in the exteneded regex format and 185 + information recorded. The pattern is in the extended regex format and 186 186 defaults to "\^sys_|^do_page_fault", see '--sort parent'. 187 187 188 188 -x:: ··· 207 207 -g:: 208 208 --call-graph=<print_type,threshold[,print_limit],order,sort_key[,branch],value>:: 209 209 Display call chains using type, min percent threshold, print limit, 210 - call order, sort key, optional branch and value. Note that ordering of 211 - parameters is not fixed so any parement can be given in an arbitraty order. 210 + call order, sort key, optional branch and value. Note that ordering 211 + is not fixed so any parameter can be given in an arbitrary order. 212 212 One exception is the print_limit which should be preceded by threshold. 213 213 214 214 print_type can be either:
+2 -2
tools/perf/Documentation/perf.data-file-format.txt
··· 270 270 by an ID. This can be either through the PERF_SAMPLE_ID or the 271 271 PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is 272 272 at a fixed offset from the event header, which allows reliable 273 - parsing of the header. Relying on ID may be ambigious. 273 + parsing of the header. Relying on ID may be ambiguous. 274 274 IDENTIFIER is only supported by newer Linux kernels. 275 275 276 276 Perf record specific events: ··· 288 288 uint64_t id[]; 289 289 }; 290 290 291 - PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ 291 + PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */ 292 292 293 293 #define MAX_EVENT_NAME 64 294 294
+1 -1
tools/perf/Documentation/tips.txt
··· 23 23 For tracepoint events, try: perf report -s trace_fields 24 24 To record callchains for each sample: perf record -g 25 25 To record every process run by a user: perf record -u <user> 26 - Skip collecing build-id when recording: perf record -B 26 + Skip collecting build-id when recording: perf record -B 27 27 To change sampling frequency to 100 Hz: perf record -F 100 28 28 See assembly instructions with percentage: perf annotate <symbol> 29 29 If you prefer Intel style assembly, try: perf annotate -M intel
+1 -1
tools/perf/arch/arm64/annotate/instructions.c
··· 50 50 arch->initialized = true; 51 51 arch->priv = arm; 52 52 arch->associate_instruction_ops = arm64__associate_instruction_ops; 53 - arch->objdump.comment_char = ';'; 53 + arch->objdump.comment_char = '/'; 54 54 arch->objdump.skip_functions_char = '+'; 55 55 return 0; 56 56
+12
tools/perf/arch/powerpc/util/sym-handling.c
··· 52 52 53 53 return strcmp(namea, nameb); 54 54 } 55 + 56 + int arch__compare_symbol_names_n(const char *namea, const char *nameb, 57 + unsigned int n) 58 + { 59 + /* Skip over initial dot */ 60 + if (*namea == '.') 61 + namea++; 62 + if (*nameb == '.') 63 + nameb++; 64 + 65 + return strncmp(namea, nameb, n); 66 + } 55 67 #endif 56 68 57 69 #if defined(_CALL_ELF) && _CALL_ELF == 2
+8 -5
tools/perf/builtin-buildid-cache.c
··· 49 49 char to[PATH_MAX]; 50 50 const char *name; 51 51 u64 addr1 = 0, addr2 = 0; 52 - int i; 52 + int i, err = -1; 53 53 54 54 scnprintf(from, sizeof(from), "%s/kallsyms", from_dir); 55 55 scnprintf(to, sizeof(to), "%s/kallsyms", to_dir); 56 56 57 57 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { 58 - addr1 = kallsyms__get_function_start(from, name); 59 - if (addr1) 58 + err = kallsyms__get_function_start(from, name, &addr1); 59 + if (!err) 60 60 break; 61 61 } 62 62 63 - if (name) 64 - addr2 = kallsyms__get_function_start(to, name); 63 + if (err) 64 + return false; 65 + 66 + if (kallsyms__get_function_start(to, name, &addr2)) 67 + return false; 65 68 66 69 return addr1 == addr2; 67 70 }
+1
tools/perf/builtin-c2c.c
··· 27 27 #include "tool.h" 28 28 #include "data.h" 29 29 #include "sort.h" 30 + #include "event.h" 30 31 #include "evlist.h" 31 32 #include "evsel.h" 32 33 #include <asm/bug.h>
+8 -11
tools/perf/builtin-config.c
··· 159 159 int i, ret = 0; 160 160 struct perf_config_set *set; 161 161 char *user_config = mkpath("%s/.perfconfig", getenv("HOME")); 162 + const char *config_filename; 162 163 163 164 argc = parse_options(argc, argv, config_options, config_usage, 164 165 PARSE_OPT_STOP_AT_NON_OPTION); ··· 175 174 config_exclusive_filename = perf_etc_perfconfig(); 176 175 else if (use_user_config) 177 176 config_exclusive_filename = user_config; 177 + 178 + if (!config_exclusive_filename) 179 + config_filename = user_config; 180 + else 181 + config_filename = config_exclusive_filename; 178 182 179 183 /* 180 184 * At only 'config' sub-command, individually use the config set ··· 198 192 parse_options_usage(config_usage, config_options, "l", 1); 199 193 } else { 200 194 ret = show_config(set); 201 - if (ret < 0) { 202 - const char * config_filename = config_exclusive_filename; 203 - if (!config_exclusive_filename) 204 - config_filename = user_config; 195 + if (ret < 0) 205 196 pr_err("Nothing configured, " 206 197 "please check your %s \n", config_filename); 207 - } 208 198 } 209 199 break; 210 200 default: ··· 223 221 224 222 if (value == NULL) 225 223 ret = show_spec_config(set, var); 226 - else { 227 - const char *config_filename = config_exclusive_filename; 228 - 229 - if (!config_exclusive_filename) 230 - config_filename = user_config; 224 + else 231 225 ret = set_config(set, config_filename, var, value); 232 - } 233 226 free(arg); 234 227 } 235 228 } else
+1 -1
tools/perf/builtin-top.c
··· 27 27 #include "util/drv_configs.h" 28 28 #include "util/evlist.h" 29 29 #include "util/evsel.h" 30 + #include "util/event.h" 30 31 #include "util/machine.h" 31 32 #include "util/session.h" 32 33 #include "util/symbol.h" 33 34 #include "util/thread.h" 34 35 #include "util/thread_map.h" 35 36 #include "util/top.h" 36 - #include "util/util.h" 37 37 #include <linux/rbtree.h> 38 38 #include <subcmd/parse-options.h> 39 39 #include "util/parse-events.h"
+1
tools/perf/builtin-trace.c
··· 21 21 #include "builtin.h" 22 22 #include "util/color.h" 23 23 #include "util/debug.h" 24 + #include "util/event.h" 24 25 #include "util/evlist.h" 25 26 #include <subcmd/exec-cmd.h> 26 27 #include "util/machine.h"
+1
tools/perf/perf.c
··· 17 17 #include <subcmd/parse-options.h> 18 18 #include "util/bpf-loader.h" 19 19 #include "util/debug.h" 20 + #include "util/event.h" 20 21 #include <api/fs/fs.h> 21 22 #include <api/fs/tracing_path.h> 22 23 #include <errno.h>
+1
tools/perf/tests/hists_cumulate.c
··· 1 1 #include "perf.h" 2 2 #include "util/debug.h" 3 + #include "util/event.h" 3 4 #include "util/symbol.h" 4 5 #include "util/sort.h" 5 6 #include "util/evsel.h"
+1
tools/perf/tests/hists_filter.c
··· 3 3 #include "util/symbol.h" 4 4 #include "util/sort.h" 5 5 #include "util/evsel.h" 6 + #include "util/event.h" 6 7 #include "util/evlist.h" 7 8 #include "util/machine.h" 8 9 #include "util/thread.h"
+1
tools/perf/tests/hists_output.c
··· 1 1 #include "perf.h" 2 2 #include "util/debug.h" 3 + #include "util/event.h" 3 4 #include "util/symbol.h" 4 5 #include "util/sort.h" 5 6 #include "util/evsel.h"
+2
tools/perf/tests/kmod-path.c
··· 61 61 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_KERNEL, true); 62 62 M("/xxxx/xxxx/x-x.ko", PERF_RECORD_MISC_USER, false); 63 63 64 + #ifdef HAVE_ZLIB_SUPPORT 64 65 /* path alloc_name alloc_ext kmod comp name ext */ 65 66 T("/xxxx/xxxx/x.ko.gz", true , true , true, true, "[x]", "gz"); 66 67 T("/xxxx/xxxx/x.ko.gz", false , true , true, true, NULL , "gz"); ··· 97 96 M("x.ko.gz", PERF_RECORD_MISC_CPUMODE_UNKNOWN, true); 98 97 M("x.ko.gz", PERF_RECORD_MISC_KERNEL, true); 99 98 M("x.ko.gz", PERF_RECORD_MISC_USER, false); 99 + #endif 100 100 101 101 /* path alloc_name alloc_ext kmod comp name ext */ 102 102 T("[test_module]", true , true , true, false, "[test_module]", NULL);
-1
tools/perf/tests/sdt.c
··· 1 1 #include <errno.h> 2 2 #include <stdio.h> 3 3 #include <sys/epoll.h> 4 - #include <util/util.h> 5 4 #include <util/evlist.h> 6 5 #include <linux/filter.h> 7 6 #include "tests.h"
+3
tools/perf/ui/setup.c
··· 10 10 void *perf_gtk_handle; 11 11 int use_browser = -1; 12 12 13 + #define PERF_GTK_DSO "libperf-gtk.so" 14 + 13 15 #ifdef HAVE_GTK2_SUPPORT 16 + 14 17 static int setup_gtk_browser(void) 15 18 { 16 19 int (*perf_ui_init)(void);
+1
tools/perf/util/Build
··· 13 13 libperf-y += kallsyms.o 14 14 libperf-y += levenshtein.o 15 15 libperf-y += llvm-utils.o 16 + libperf-y += memswap.o 16 17 libperf-y += parse-events.o 17 18 libperf-y += perf_regs.o 18 19 libperf-y += path.o
+4
tools/perf/util/build-id.h
··· 44 44 int build_id_cache__add_s(const char *sbuild_id, 45 45 const char *name, bool is_kallsyms, bool is_vdso); 46 46 int build_id_cache__remove_s(const char *sbuild_id); 47 + 48 + extern char buildid_dir[]; 49 + 50 + void set_buildid_dir(const char *dir); 47 51 void disable_buildid_cache(void); 48 52 49 53 #endif
+6 -4
tools/perf/util/event.c
··· 8 8 #include <unistd.h> 9 9 #include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ 10 10 #include <api/fs/fs.h> 11 + #include <linux/perf_event.h> 11 12 #include "event.h" 12 13 #include "debug.h" 13 14 #include "hist.h" ··· 768 767 return 1; 769 768 } 770 769 771 - u64 kallsyms__get_function_start(const char *kallsyms_filename, 772 - const char *symbol_name) 770 + int kallsyms__get_function_start(const char *kallsyms_filename, 771 + const char *symbol_name, u64 *addr) 773 772 { 774 773 struct process_symbol_args args = { .name = symbol_name, }; 775 774 776 775 if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0) 777 - return 0; 776 + return -1; 778 777 779 - return args.start; 778 + *addr = args.start; 779 + return 0; 780 780 } 781 781 782 782 int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
+11 -3
tools/perf/util/event.h
··· 229 229 enum perf_user_event_type { /* above any possible kernel type */ 230 230 PERF_RECORD_USER_TYPE_START = 64, 231 231 PERF_RECORD_HEADER_ATTR = 64, 232 - PERF_RECORD_HEADER_EVENT_TYPE = 65, /* depreceated */ 232 + PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */ 233 233 PERF_RECORD_HEADER_TRACING_DATA = 66, 234 234 PERF_RECORD_HEADER_BUILD_ID = 67, 235 235 PERF_RECORD_FINISHED_ROUND = 68, ··· 675 675 size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); 676 676 size_t perf_event__fprintf(union perf_event *event, FILE *fp); 677 677 678 - u64 kallsyms__get_function_start(const char *kallsyms_filename, 679 - const char *symbol_name); 678 + int kallsyms__get_function_start(const char *kallsyms_filename, 679 + const char *symbol_name, u64 *addr); 680 680 681 681 void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max); 682 682 void cpu_map_data__synthesize(struct cpu_map_data *data, struct cpu_map *map, 683 683 u16 type, int max); 684 + 685 + void event_attr_init(struct perf_event_attr *attr); 686 + 687 + int perf_event_paranoid(void); 688 + 689 + extern int sysctl_perf_event_max_stack; 690 + extern int sysctl_perf_event_max_contexts_per_stack; 691 + 684 692 #endif /* __PERF_RECORD_H */
+1
tools/perf/util/evsel.c
··· 21 21 #include "asm/bug.h" 22 22 #include "callchain.h" 23 23 #include "cgroup.h" 24 + #include "event.h" 24 25 #include "evsel.h" 25 26 #include "evlist.h" 26 27 #include "util.h"
+1
tools/perf/util/header.c
··· 19 19 #include "evlist.h" 20 20 #include "evsel.h" 21 21 #include "header.h" 22 + #include "memswap.h" 22 23 #include "../perf.h" 23 24 #include "trace-event.h" 24 25 #include "session.h"
+1
tools/perf/util/intel-pt.c
··· 23 23 #include "../perf.h" 24 24 #include "session.h" 25 25 #include "machine.h" 26 + #include "memswap.h" 26 27 #include "sort.h" 27 28 #include "tool.h" 28 29 #include "event.h"
+17 -11
tools/perf/util/machine.c
··· 796 796 * Returns the name of the start symbol in *symbol_name. Pass in NULL as 797 797 * symbol_name if it's not that important. 798 798 */ 799 - static u64 machine__get_running_kernel_start(struct machine *machine, 800 - const char **symbol_name) 799 + static int machine__get_running_kernel_start(struct machine *machine, 800 + const char **symbol_name, u64 *start) 801 801 { 802 802 char filename[PATH_MAX]; 803 - int i; 803 + int i, err = -1; 804 804 const char *name; 805 805 u64 addr = 0; 806 806 ··· 810 810 return 0; 811 811 812 812 for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { 813 - addr = kallsyms__get_function_start(filename, name); 814 - if (addr) 813 + err = kallsyms__get_function_start(filename, name, &addr); 814 + if (!err) 815 815 break; 816 816 } 817 + 818 + if (err) 819 + return -1; 817 820 818 821 if (symbol_name) 819 822 *symbol_name = name; 820 823 821 - return addr; 824 + *start = addr; 825 + return 0; 822 826 } 823 827 824 828 int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) 825 829 { 826 830 int type; 827 - u64 start = machine__get_running_kernel_start(machine, NULL); 831 + u64 start = 0; 832 + 833 + if (machine__get_running_kernel_start(machine, NULL, &start)) 834 + return -1; 828 835 829 836 /* In case of renewal the kernel map, destroy previous one */ 830 837 machine__destroy_kernel_maps(machine); ··· 1192 1185 int machine__create_kernel_maps(struct machine *machine) 1193 1186 { 1194 1187 struct dso *kernel = machine__get_kernel(machine); 1195 - const char *name; 1196 - u64 addr; 1188 + const char *name = NULL; 1189 + u64 addr = 0; 1197 1190 int ret; 1198 1191 1199 1192 if (kernel == NULL) ··· 1218 1211 */ 1219 1212 map_groups__fixup_end(&machine->kmaps); 1220 1213 1221 - addr = machine__get_running_kernel_start(machine, &name); 1222 - if (!addr) { 1214 + if (machine__get_running_kernel_start(machine, &name, &addr)) { 1223 1215 } else if (maps__set_kallsyms_ref_reloc_sym(machine->vmlinux_maps, name, addr)) { 1224 1216 machine__destroy_kernel_maps(machine); 1225 1217 return -1;
-5
tools/perf/util/map.c
··· 325 325 return 0; 326 326 } 327 327 328 - int __weak arch__compare_symbol_names(const char *namea, const char *nameb) 329 - { 330 - return strcmp(namea, nameb); 331 - } 332 - 333 328 struct symbol *map__find_symbol(struct map *map, u64 addr) 334 329 { 335 330 if (map__load(map) < 0)
+3 -2
tools/perf/util/map.h
··· 130 130 */ 131 131 #define __map__for_each_symbol_by_name(map, sym_name, pos) \ 132 132 for (pos = map__find_symbol_by_name(map, sym_name); \ 133 - pos && arch__compare_symbol_names(pos->name, sym_name) == 0; \ 133 + pos && \ 134 + !symbol__match_symbol_name(pos->name, sym_name, \ 135 + SYMBOL_TAG_INCLUDE__DEFAULT_ONLY); \ 134 136 pos = symbol__next_by_name(pos)) 135 137 136 138 #define map__for_each_symbol_by_name(map, sym_name, pos) \ 137 139 __map__for_each_symbol_by_name(map, sym_name, (pos)) 138 140 139 - int arch__compare_symbol_names(const char *namea, const char *nameb); 140 141 void map__init(struct map *map, enum map_type type, 141 142 u64 start, u64 end, u64 pgoff, struct dso *dso); 142 143 struct map *map__new(struct machine *machine, u64 start, u64 len,
+24
tools/perf/util/memswap.c
··· 1 + #include <byteswap.h> 2 + #include "memswap.h" 3 + #include <linux/types.h> 4 + 5 + void mem_bswap_32(void *src, int byte_size) 6 + { 7 + u32 *m = src; 8 + while (byte_size > 0) { 9 + *m = bswap_32(*m); 10 + byte_size -= sizeof(u32); 11 + ++m; 12 + } 13 + } 14 + 15 + void mem_bswap_64(void *src, int byte_size) 16 + { 17 + u64 *m = src; 18 + 19 + while (byte_size > 0) { 20 + *m = bswap_64(*m); 21 + byte_size -= sizeof(u64); 22 + ++m; 23 + } 24 + }
+7
tools/perf/util/memswap.h
··· 1 + #ifndef PERF_MEMSWAP_H_ 2 + #define PERF_MEMSWAP_H_ 3 + 4 + void mem_bswap_64(void *src, int byte_size); 5 + void mem_bswap_32(void *src, int byte_size); 6 + 7 + #endif /* PERF_MEMSWAP_H_ */
+3 -1
tools/perf/util/scripting-engines/trace-event-perl.c
··· 28 28 #include <linux/bitmap.h> 29 29 #include <linux/time64.h> 30 30 31 - #include "../util.h" 31 + #include <stdbool.h> 32 + /* perl needs the following define, right after including stdbool.h */ 33 + #define HAS_BOOL 32 34 #include <EXTERN.h> 33 35 #include <perl.h> 34 36
+1
tools/perf/util/session.c
··· 11 11 12 12 #include "evlist.h" 13 13 #include "evsel.h" 14 + #include "memswap.h" 14 15 #include "session.h" 15 16 #include "tool.h" 16 17 #include "sort.h"
-9
tools/perf/util/strbuf.c
··· 3 3 #include <linux/kernel.h> 4 4 #include <errno.h> 5 5 6 - int prefixcmp(const char *str, const char *prefix) 7 - { 8 - for (; ; str++, prefix++) 9 - if (!*prefix) 10 - return 0; 11 - else if (*str != *prefix) 12 - return (unsigned char)*prefix - (unsigned char)*str; 13 - } 14 - 15 6 /* 16 7 * Used as the default ->buf value, so that people can always assume 17 8 * buf is non NULL and ->buf is NUL terminated even for a freshly
+53 -19
tools/perf/util/symbol.c
··· 90 90 return tail - str; 91 91 } 92 92 93 + int __weak arch__compare_symbol_names(const char *namea, const char *nameb) 94 + { 95 + return strcmp(namea, nameb); 96 + } 97 + 98 + int __weak arch__compare_symbol_names_n(const char *namea, const char *nameb, 99 + unsigned int n) 100 + { 101 + return strncmp(namea, nameb, n); 102 + } 103 + 93 104 int __weak arch__choose_best_symbol(struct symbol *syma, 94 105 struct symbol *symb __maybe_unused) 95 106 { ··· 410 399 } 411 400 } 412 401 402 + int symbol__match_symbol_name(const char *name, const char *str, 403 + enum symbol_tag_include includes) 404 + { 405 + const char *versioning; 406 + 407 + if (includes == SYMBOL_TAG_INCLUDE__DEFAULT_ONLY && 408 + (versioning = strstr(name, "@@"))) { 409 + int len = strlen(str); 410 + 411 + if (len < versioning - name) 412 + len = versioning - name; 413 + 414 + return arch__compare_symbol_names_n(name, str, len); 415 + } else 416 + return arch__compare_symbol_names(name, str); 417 + } 418 + 413 419 static struct symbol *symbols__find_by_name(struct rb_root *symbols, 414 - const char *name) 420 + const char *name, 421 + enum symbol_tag_include includes) 415 422 { 416 423 struct rb_node *n; 417 424 struct symbol_name_rb_node *s = NULL; ··· 443 414 int cmp; 444 415 445 416 s = rb_entry(n, struct symbol_name_rb_node, rb_node); 446 - cmp = arch__compare_symbol_names(name, s->sym.name); 417 + cmp = symbol__match_symbol_name(s->sym.name, name, includes); 447 418 448 - if (cmp < 0) 419 + if (cmp > 0) 449 420 n = n->rb_left; 450 - else if (cmp > 0) 421 + else if (cmp < 0) 451 422 n = n->rb_right; 452 423 else 453 424 break; ··· 456 427 if (n == NULL) 457 428 return NULL; 458 429 459 - /* return first symbol that has same name (if any) */ 460 - for (n = rb_prev(n); n; n = rb_prev(n)) { 461 - struct symbol_name_rb_node *tmp; 430 + if (includes != SYMBOL_TAG_INCLUDE__DEFAULT_ONLY) 431 + /* return first symbol that has same name (if any) */ 432 + for (n = rb_prev(n); n; n = rb_prev(n)) { 433 + struct symbol_name_rb_node *tmp; 462 434 463 - tmp = rb_entry(n, struct symbol_name_rb_node, rb_node); 464 - if (arch__compare_symbol_names(tmp->sym.name, s->sym.name)) 465 - break; 435 + tmp = rb_entry(n, struct symbol_name_rb_node, rb_node); 436 + if (arch__compare_symbol_names(tmp->sym.name, s->sym.name)) 437 + break; 466 438 467 - s = tmp; 468 - } 439 + s = tmp; 440 + } 469 441 470 442 return &s->sym; 471 443 } ··· 496 466 struct symbol *dso__find_symbol(struct dso *dso, 497 467 enum map_type type, u64 addr) 498 468 { 499 - if (dso->last_find_result[type].addr != addr) { 469 + if (dso->last_find_result[type].addr != addr || dso->last_find_result[type].symbol == NULL) { 500 470 dso->last_find_result[type].addr = addr; 501 471 dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr); 502 472 } ··· 533 503 struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, 534 504 const char *name) 535 505 { 536 - return symbols__find_by_name(&dso->symbol_names[type], name); 506 + struct symbol *s = symbols__find_by_name(&dso->symbol_names[type], name, 507 + SYMBOL_TAG_INCLUDE__NONE); 508 + if (!s) 509 + s = symbols__find_by_name(&dso->symbol_names[type], name, 510 + SYMBOL_TAG_INCLUDE__DEFAULT_ONLY); 511 + return s; 537 512 } 538 513 539 514 void dso__sort_by_name(struct dso *dso, enum map_type type) ··· 1110 1075 if (kmap->ref_reloc_sym && kmap->ref_reloc_sym->name) { 1111 1076 u64 start; 1112 1077 1113 - start = kallsyms__get_function_start(kallsyms_filename, 1114 - kmap->ref_reloc_sym->name); 1078 + if (kallsyms__get_function_start(kallsyms_filename, 1079 + kmap->ref_reloc_sym->name, &start)) 1080 + return -ENOENT; 1115 1081 if (start != kmap->ref_reloc_sym->addr) 1116 1082 return -EINVAL; 1117 1083 } ··· 1284 1248 if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->name) 1285 1249 return 0; 1286 1250 1287 - addr = kallsyms__get_function_start(filename, 1288 - kmap->ref_reloc_sym->name); 1289 - if (!addr) 1251 + if (kallsyms__get_function_start(filename, kmap->ref_reloc_sym->name, &addr)) 1290 1252 return -1; 1291 1253 1292 1254 *delta = addr - kmap->ref_reloc_sym->addr;
+11
tools/perf/util/symbol.h
··· 348 348 #define SYMBOL_A 0 349 349 #define SYMBOL_B 1 350 350 351 + int arch__compare_symbol_names(const char *namea, const char *nameb); 352 + int arch__compare_symbol_names_n(const char *namea, const char *nameb, 353 + unsigned int n); 351 354 int arch__choose_best_symbol(struct symbol *syma, struct symbol *symb); 355 + 356 + enum symbol_tag_include { 357 + SYMBOL_TAG_INCLUDE__NONE = 0, 358 + SYMBOL_TAG_INCLUDE__DEFAULT_ONLY 359 + }; 360 + 361 + int symbol__match_symbol_name(const char *namea, const char *nameb, 362 + enum symbol_tag_include includes); 352 363 353 364 /* structure containing an SDT note's info */ 354 365 struct sdt_note {
+29
tools/perf/util/units.c
··· 1 1 #include "units.h" 2 2 #include <inttypes.h> 3 + #include <limits.h> 4 + #include <stdlib.h> 5 + #include <string.h> 3 6 #include <linux/kernel.h> 4 7 #include <linux/time64.h> 8 + 9 + unsigned long parse_tag_value(const char *str, struct parse_tag *tags) 10 + { 11 + struct parse_tag *i = tags; 12 + 13 + while (i->tag) { 14 + char *s = strchr(str, i->tag); 15 + 16 + if (s) { 17 + unsigned long int value; 18 + char *endptr; 19 + 20 + value = strtoul(str, &endptr, 10); 21 + if (s != endptr) 22 + break; 23 + 24 + if (value > ULONG_MAX / i->mult) 25 + break; 26 + value *= i->mult; 27 + return value; 28 + } 29 + i++; 30 + } 31 + 32 + return (unsigned long) -1; 33 + } 5 34 6 35 unsigned long convert_unit(unsigned long value, char *unit) 7 36 {
+7
tools/perf/util/units.h
··· 4 4 #include <stddef.h> 5 5 #include <linux/types.h> 6 6 7 + struct parse_tag { 8 + char tag; 9 + int mult; 10 + }; 11 + 12 + unsigned long parse_tag_value(const char *str, struct parse_tag *tags); 13 + 7 14 unsigned long convert_unit(unsigned long value, char *unit); 8 15 int unit_number__scnprintf(char *buf, size_t size, u64 n); 9 16
-49
tools/perf/util/util.c
··· 13 13 #include <string.h> 14 14 #include <errno.h> 15 15 #include <limits.h> 16 - #include <byteswap.h> 17 16 #include <linux/kernel.h> 18 17 #include <linux/log2.h> 19 18 #include <linux/time64.h> ··· 334 335 return p - ptr; 335 336 } 336 337 337 - unsigned long parse_tag_value(const char *str, struct parse_tag *tags) 338 - { 339 - struct parse_tag *i = tags; 340 - 341 - while (i->tag) { 342 - char *s; 343 - 344 - s = strchr(str, i->tag); 345 - if (s) { 346 - unsigned long int value; 347 - char *endptr; 348 - 349 - value = strtoul(str, &endptr, 10); 350 - if (s != endptr) 351 - break; 352 - 353 - if (value > ULONG_MAX / i->mult) 354 - break; 355 - value *= i->mult; 356 - return value; 357 - } 358 - i++; 359 - } 360 - 361 - return (unsigned long) -1; 362 - } 363 - 364 338 int perf_event_paranoid(void) 365 339 { 366 340 int value; ··· 342 370 return INT_MAX; 343 371 344 372 return value; 345 - } 346 - 347 - void mem_bswap_32(void *src, int byte_size) 348 - { 349 - u32 *m = src; 350 - while (byte_size > 0) { 351 - *m = bswap_32(*m); 352 - byte_size -= sizeof(u32); 353 - ++m; 354 - } 355 - } 356 - 357 - void mem_bswap_64(void *src, int byte_size) 358 - { 359 - u64 *m = src; 360 - 361 - while (byte_size > 0) { 362 - *m = bswap_64(*m); 363 - byte_size -= sizeof(u64); 364 - ++m; 365 - } 366 373 } 367 374 368 375 bool find_process(const char *name)
-26
tools/perf/util/util.h
··· 5 5 #define _BSD_SOURCE 1 6 6 /* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */ 7 7 #define _DEFAULT_SOURCE 1 8 - #define HAS_BOOL 9 8 10 9 #include <fcntl.h> 11 10 #include <stdbool.h> ··· 12 13 #include <stdlib.h> 13 14 #include <stdarg.h> 14 15 #include <linux/types.h> 15 - 16 - extern char buildid_dir[]; 17 16 18 17 #ifdef __GNUC__ 19 18 #define NORETURN __attribute__((__noreturn__)) ··· 22 25 #endif 23 26 #endif 24 27 25 - #define PERF_GTK_DSO "libperf-gtk.so" 26 - 27 28 /* General helper functions */ 28 29 void usage(const char *err) NORETURN; 29 30 void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); ··· 29 34 void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); 30 35 31 36 void set_warning_routine(void (*routine)(const char *err, va_list params)); 32 - 33 - int prefixcmp(const char *str, const char *prefix); 34 - void set_buildid_dir(const char *dir); 35 37 36 38 static inline void *zalloc(size_t size) 37 39 { ··· 51 59 ssize_t readn(int fd, void *buf, size_t n); 52 60 ssize_t writen(int fd, void *buf, size_t n); 53 61 54 - struct perf_event_attr; 55 - 56 - void event_attr_init(struct perf_event_attr *attr); 57 - 58 62 size_t hex_width(u64 v); 59 63 int hex2u64(const char *ptr, u64 *val); 60 64 61 65 extern unsigned int page_size; 62 66 extern int cacheline_size; 63 - extern int sysctl_perf_event_max_stack; 64 - extern int sysctl_perf_event_max_contexts_per_stack; 65 - 66 - struct parse_tag { 67 - char tag; 68 - int mult; 69 - }; 70 - 71 - unsigned long parse_tag_value(const char *str, struct parse_tag *tags); 72 - 73 - int perf_event_paranoid(void); 74 - 75 - void mem_bswap_64(void *src, int byte_size); 76 - void mem_bswap_32(void *src, int byte_size); 77 67 78 68 bool find_process(const char *name); 79 69