diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/lib/api/Makefile | 2 | ||||
| -rw-r--r-- | tools/lib/hweight.c | 62 | ||||
| -rw-r--r-- | tools/lib/traceevent/Makefile | 2 | ||||
| -rw-r--r-- | tools/perf/MANIFEST | 2 | ||||
| -rw-r--r-- | tools/perf/builtin-stat.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/Build | 2 | ||||
| -rw-r--r-- | tools/perf/util/python-ext-sources | 4 | ||||
| -rw-r--r-- | tools/perf/util/thread_map.c | 3 | ||||
| -rw-r--r-- | tools/perf/util/vdso.c | 8 |
9 files changed, 74 insertions, 15 deletions
diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile index 8bd960658463..fe1b02c2c95b 100644 --- a/tools/lib/api/Makefile +++ b/tools/lib/api/Makefile | |||
| @@ -36,7 +36,7 @@ $(LIBFILE): $(API_IN) | |||
| 36 | 36 | ||
| 37 | clean: | 37 | clean: |
| 38 | $(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \ | 38 | $(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \ |
| 39 | find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o | xargs $(RM) | 39 | find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM) |
| 40 | 40 | ||
| 41 | FORCE: | 41 | FORCE: |
| 42 | 42 | ||
diff --git a/tools/lib/hweight.c b/tools/lib/hweight.c new file mode 100644 index 000000000000..0b859b884339 --- /dev/null +++ b/tools/lib/hweight.c | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #include <linux/bitops.h> | ||
| 2 | #include <asm/types.h> | ||
| 3 | |||
| 4 | /** | ||
| 5 | * hweightN - returns the hamming weight of a N-bit word | ||
| 6 | * @x: the word to weigh | ||
| 7 | * | ||
| 8 | * The Hamming Weight of a number is the total number of bits set in it. | ||
| 9 | */ | ||
| 10 | |||
| 11 | unsigned int __sw_hweight32(unsigned int w) | ||
| 12 | { | ||
| 13 | #ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER | ||
| 14 | w -= (w >> 1) & 0x55555555; | ||
| 15 | w = (w & 0x33333333) + ((w >> 2) & 0x33333333); | ||
| 16 | w = (w + (w >> 4)) & 0x0f0f0f0f; | ||
| 17 | return (w * 0x01010101) >> 24; | ||
| 18 | #else | ||
| 19 | unsigned int res = w - ((w >> 1) & 0x55555555); | ||
| 20 | res = (res & 0x33333333) + ((res >> 2) & 0x33333333); | ||
| 21 | res = (res + (res >> 4)) & 0x0F0F0F0F; | ||
| 22 | res = res + (res >> 8); | ||
| 23 | return (res + (res >> 16)) & 0x000000FF; | ||
| 24 | #endif | ||
| 25 | } | ||
| 26 | |||
| 27 | unsigned int __sw_hweight16(unsigned int w) | ||
| 28 | { | ||
| 29 | unsigned int res = w - ((w >> 1) & 0x5555); | ||
| 30 | res = (res & 0x3333) + ((res >> 2) & 0x3333); | ||
| 31 | res = (res + (res >> 4)) & 0x0F0F; | ||
| 32 | return (res + (res >> 8)) & 0x00FF; | ||
| 33 | } | ||
| 34 | |||
| 35 | unsigned int __sw_hweight8(unsigned int w) | ||
| 36 | { | ||
| 37 | unsigned int res = w - ((w >> 1) & 0x55); | ||
| 38 | res = (res & 0x33) + ((res >> 2) & 0x33); | ||
| 39 | return (res + (res >> 4)) & 0x0F; | ||
| 40 | } | ||
| 41 | |||
| 42 | unsigned long __sw_hweight64(__u64 w) | ||
| 43 | { | ||
| 44 | #if BITS_PER_LONG == 32 | ||
| 45 | return __sw_hweight32((unsigned int)(w >> 32)) + | ||
| 46 | __sw_hweight32((unsigned int)w); | ||
| 47 | #elif BITS_PER_LONG == 64 | ||
| 48 | #ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER | ||
| 49 | w -= (w >> 1) & 0x5555555555555555ul; | ||
| 50 | w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul); | ||
| 51 | w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful; | ||
| 52 | return (w * 0x0101010101010101ul) >> 56; | ||
| 53 | #else | ||
| 54 | __u64 res = w - ((w >> 1) & 0x5555555555555555ul); | ||
| 55 | res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); | ||
| 56 | res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; | ||
| 57 | res = res + (res >> 8); | ||
| 58 | res = res + (res >> 16); | ||
| 59 | return (res + (res >> 32)) & 0x00000000000000FFul; | ||
| 60 | #endif | ||
| 61 | #endif | ||
| 62 | } | ||
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 6daaff652aff..7851df1490e0 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile | |||
| @@ -268,7 +268,7 @@ install: install_lib | |||
| 268 | 268 | ||
| 269 | clean: | 269 | clean: |
| 270 | $(call QUIET_CLEAN, libtraceevent) \ | 270 | $(call QUIET_CLEAN, libtraceevent) \ |
| 271 | $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d \ | 271 | $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd \ |
| 272 | $(RM) TRACEEVENT-CFLAGS tags TAGS | 272 | $(RM) TRACEEVENT-CFLAGS tags TAGS |
| 273 | 273 | ||
| 274 | PHONY += force plugins | 274 | PHONY += force plugins |
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index 09dc0aabb515..d01a0aad5a01 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST | |||
| @@ -18,6 +18,7 @@ tools/arch/x86/include/asm/atomic.h | |||
| 18 | tools/arch/x86/include/asm/rmwcc.h | 18 | tools/arch/x86/include/asm/rmwcc.h |
| 19 | tools/lib/traceevent | 19 | tools/lib/traceevent |
| 20 | tools/lib/api | 20 | tools/lib/api |
| 21 | tools/lib/hweight.c | ||
| 21 | tools/lib/rbtree.c | 22 | tools/lib/rbtree.c |
| 22 | tools/lib/symbol/kallsyms.c | 23 | tools/lib/symbol/kallsyms.c |
| 23 | tools/lib/symbol/kallsyms.h | 24 | tools/lib/symbol/kallsyms.h |
| @@ -57,7 +58,6 @@ include/linux/perf_event.h | |||
| 57 | include/linux/list.h | 58 | include/linux/list.h |
| 58 | include/linux/hash.h | 59 | include/linux/hash.h |
| 59 | include/linux/stringify.h | 60 | include/linux/stringify.h |
| 60 | lib/hweight.c | ||
| 61 | include/linux/swab.h | 61 | include/linux/swab.h |
| 62 | arch/*/include/asm/unistd*.h | 62 | arch/*/include/asm/unistd*.h |
| 63 | arch/*/include/uapi/asm/unistd*.h | 63 | arch/*/include/uapi/asm/unistd*.h |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 37e301a32f43..d99d850e1444 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
| @@ -343,7 +343,7 @@ static int read_counter(struct perf_evsel *counter) | |||
| 343 | return 0; | 343 | return 0; |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | static void read_counters(bool close) | 346 | static void read_counters(bool close_counters) |
| 347 | { | 347 | { |
| 348 | struct perf_evsel *counter; | 348 | struct perf_evsel *counter; |
| 349 | 349 | ||
| @@ -354,7 +354,7 @@ static void read_counters(bool close) | |||
| 354 | if (process_counter(counter)) | 354 | if (process_counter(counter)) |
| 355 | pr_warning("failed to process counter %s\n", counter->name); | 355 | pr_warning("failed to process counter %s\n", counter->name); |
| 356 | 356 | ||
| 357 | if (close) { | 357 | if (close_counters) { |
| 358 | perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter), | 358 | perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter), |
| 359 | thread_map__nr(evsel_list->threads)); | 359 | thread_map__nr(evsel_list->threads)); |
| 360 | } | 360 | } |
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 601d11440596..d2d318c59b37 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
| @@ -143,6 +143,6 @@ $(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE | |||
| 143 | $(call rule_mkdir) | 143 | $(call rule_mkdir) |
| 144 | $(call if_changed_dep,cc_o_c) | 144 | $(call if_changed_dep,cc_o_c) |
| 145 | 145 | ||
| 146 | $(OUTPUT)util/hweight.o: ../../lib/hweight.c FORCE | 146 | $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE |
| 147 | $(call rule_mkdir) | 147 | $(call rule_mkdir) |
| 148 | $(call if_changed_dep,cc_o_c) | 148 | $(call if_changed_dep,cc_o_c) |
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index e23ded40c79e..0766d98c5da5 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
| @@ -10,7 +10,7 @@ util/ctype.c | |||
| 10 | util/evlist.c | 10 | util/evlist.c |
| 11 | util/evsel.c | 11 | util/evsel.c |
| 12 | util/cpumap.c | 12 | util/cpumap.c |
| 13 | ../../lib/hweight.c | 13 | ../lib/hweight.c |
| 14 | util/thread_map.c | 14 | util/thread_map.c |
| 15 | util/util.c | 15 | util/util.c |
| 16 | util/xyarray.c | 16 | util/xyarray.c |
| @@ -19,5 +19,5 @@ util/rblist.c | |||
| 19 | util/stat.c | 19 | util/stat.c |
| 20 | util/strlist.c | 20 | util/strlist.c |
| 21 | util/trace-event.c | 21 | util/trace-event.c |
| 22 | ../../lib/rbtree.c | 22 | ../lib/rbtree.c |
| 23 | util/string.c | 23 | util/string.c |
diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index da7646d767fe..292ae2c90e06 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c | |||
| @@ -136,8 +136,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid) | |||
| 136 | if (grow) { | 136 | if (grow) { |
| 137 | struct thread_map *tmp; | 137 | struct thread_map *tmp; |
| 138 | 138 | ||
| 139 | tmp = realloc(threads, (sizeof(*threads) + | 139 | tmp = thread_map__realloc(threads, max_threads); |
| 140 | max_threads * sizeof(pid_t))); | ||
| 141 | if (tmp == NULL) | 140 | if (tmp == NULL) |
| 142 | goto out_free_namelist; | 141 | goto out_free_namelist; |
| 143 | 142 | ||
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 4b89118f158d..44d440da15dc 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c | |||
| @@ -236,18 +236,16 @@ static struct dso *__machine__findnew_compat(struct machine *machine, | |||
| 236 | const char *file_name; | 236 | const char *file_name; |
| 237 | struct dso *dso; | 237 | struct dso *dso; |
| 238 | 238 | ||
| 239 | pthread_rwlock_wrlock(&machine->dsos.lock); | ||
| 240 | dso = __dsos__find(&machine->dsos, vdso_file->dso_name, true); | 239 | dso = __dsos__find(&machine->dsos, vdso_file->dso_name, true); |
| 241 | if (dso) | 240 | if (dso) |
| 242 | goto out_unlock; | 241 | goto out; |
| 243 | 242 | ||
| 244 | file_name = vdso__get_compat_file(vdso_file); | 243 | file_name = vdso__get_compat_file(vdso_file); |
| 245 | if (!file_name) | 244 | if (!file_name) |
| 246 | goto out_unlock; | 245 | goto out; |
| 247 | 246 | ||
| 248 | dso = __machine__addnew_vdso(machine, vdso_file->dso_name, file_name); | 247 | dso = __machine__addnew_vdso(machine, vdso_file->dso_name, file_name); |
| 249 | out_unlock: | 248 | out: |
| 250 | pthread_rwlock_unlock(&machine->dsos.lock); | ||
| 251 | return dso; | 249 | return dso; |
| 252 | } | 250 | } |
| 253 | 251 | ||
