Skip to content

Commit

Permalink
Merge tag 'perf-urgent-for-mingo-2' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

  - Fix 'perf top -u username', where not enough memory per thread_map
    entry was being allocated nor was being initialized, causing a
    segfault (Arnaldo Carvalho de Melo)

  - Fix locking lockup using 32-bit compat vdso (Adrian Hunter)

  - Fix shadow declaration of 'close' with older build environments (Jiri Olsa)

  - Make the 'clean' target do a better job, removing some more temp files (Riku Voipio)

  - The python binding also has a MANIFEST like file where we list the files that
    need to be built and linked to form the resulting python shared object module
    file. And it has an entry for rbtree.c that still pointed to the one in the
    kernel sources, fix it by also removing one level of indirection so that it
    uses the tools/lib/rbtree.c copy. (Arnaldo Carvalho de Melo)

  - For the same reasons as for rbtree.c, copy the kernel lib/hweight.c file to
    tools/lib/, sanitizing it in the process to remove kernel specific stuff like
    EXPORT_SYMBOL() lines and the linux/export.h include reference, as that file
    doesn't exist anymore in tools/include/linux. (Arnaldo Carvalho de Melo)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Jul 10, 2015
2 parents c4b5fd3 + 0aefc35 commit 4756e19
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tools/lib/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $(LIBFILE): $(API_IN)

clean:
$(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o | xargs $(RM)
find $(if $(OUTPUT),$(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)

FORCE:

Expand Down
62 changes: 62 additions & 0 deletions tools/lib/hweight.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <linux/bitops.h>
#include <asm/types.h>

/**
* hweightN - returns the hamming weight of a N-bit word
* @x: the word to weigh
*
* The Hamming Weight of a number is the total number of bits set in it.
*/

unsigned int __sw_hweight32(unsigned int w)
{
#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
w -= (w >> 1) & 0x55555555;
w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
w = (w + (w >> 4)) & 0x0f0f0f0f;
return (w * 0x01010101) >> 24;
#else
unsigned int res = w - ((w >> 1) & 0x55555555);
res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
res = (res + (res >> 4)) & 0x0F0F0F0F;
res = res + (res >> 8);
return (res + (res >> 16)) & 0x000000FF;
#endif
}

unsigned int __sw_hweight16(unsigned int w)
{
unsigned int res = w - ((w >> 1) & 0x5555);
res = (res & 0x3333) + ((res >> 2) & 0x3333);
res = (res + (res >> 4)) & 0x0F0F;
return (res + (res >> 8)) & 0x00FF;
}

unsigned int __sw_hweight8(unsigned int w)
{
unsigned int res = w - ((w >> 1) & 0x55);
res = (res & 0x33) + ((res >> 2) & 0x33);
return (res + (res >> 4)) & 0x0F;
}

unsigned long __sw_hweight64(__u64 w)
{
#if BITS_PER_LONG == 32
return __sw_hweight32((unsigned int)(w >> 32)) +
__sw_hweight32((unsigned int)w);
#elif BITS_PER_LONG == 64
#ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER
w -= (w >> 1) & 0x5555555555555555ul;
w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul);
w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful;
return (w * 0x0101010101010101ul) >> 56;
#else
__u64 res = w - ((w >> 1) & 0x5555555555555555ul);
res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
res = res + (res >> 8);
res = res + (res >> 16);
return (res + (res >> 32)) & 0x00000000000000FFul;
#endif
#endif
}
2 changes: 1 addition & 1 deletion tools/lib/traceevent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ install: install_lib

clean:
$(call QUIET_CLEAN, libtraceevent) \
$(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d \
$(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd \
$(RM) TRACEEVENT-CFLAGS tags TAGS

PHONY += force plugins
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tools/arch/x86/include/asm/atomic.h
tools/arch/x86/include/asm/rmwcc.h
tools/lib/traceevent
tools/lib/api
tools/lib/hweight.c
tools/lib/rbtree.c
tools/lib/symbol/kallsyms.c
tools/lib/symbol/kallsyms.h
Expand Down Expand Up @@ -57,7 +58,6 @@ include/linux/perf_event.h
include/linux/list.h
include/linux/hash.h
include/linux/stringify.h
lib/hweight.c
include/linux/swab.h
arch/*/include/asm/unistd*.h
arch/*/include/uapi/asm/unistd*.h
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static int read_counter(struct perf_evsel *counter)
return 0;
}

static void read_counters(bool close)
static void read_counters(bool close_counters)
{
struct perf_evsel *counter;

Expand All @@ -354,7 +354,7 @@ static void read_counters(bool close)
if (process_counter(counter))
pr_warning("failed to process counter %s\n", counter->name);

if (close) {
if (close_counters) {
perf_evsel__close_fd(counter, perf_evsel__nr_cpus(counter),
thread_map__nr(evsel_list->threads));
}
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/Build
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ $(OUTPUT)util/rbtree.o: ../lib/rbtree.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)

$(OUTPUT)util/hweight.o: ../../lib/hweight.c FORCE
$(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
4 changes: 2 additions & 2 deletions tools/perf/util/python-ext-sources
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ util/ctype.c
util/evlist.c
util/evsel.c
util/cpumap.c
../../lib/hweight.c
../lib/hweight.c
util/thread_map.c
util/util.c
util/xyarray.c
Expand All @@ -19,5 +19,5 @@ util/rblist.c
util/stat.c
util/strlist.c
util/trace-event.c
../../lib/rbtree.c
../lib/rbtree.c
util/string.c
3 changes: 1 addition & 2 deletions tools/perf/util/thread_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
if (grow) {
struct thread_map *tmp;

tmp = realloc(threads, (sizeof(*threads) +
max_threads * sizeof(pid_t)));
tmp = thread_map__realloc(threads, max_threads);
if (tmp == NULL)
goto out_free_namelist;

Expand Down
8 changes: 3 additions & 5 deletions tools/perf/util/vdso.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,16 @@ static struct dso *__machine__findnew_compat(struct machine *machine,
const char *file_name;
struct dso *dso;

pthread_rwlock_wrlock(&machine->dsos.lock);
dso = __dsos__find(&machine->dsos, vdso_file->dso_name, true);
if (dso)
goto out_unlock;
goto out;

file_name = vdso__get_compat_file(vdso_file);
if (!file_name)
goto out_unlock;
goto out;

dso = __machine__addnew_vdso(machine, vdso_file->dso_name, file_name);
out_unlock:
pthread_rwlock_unlock(&machine->dsos.lock);
out:
return dso;
}

Expand Down

0 comments on commit 4756e19

Please sign in to comment.