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

tools: Remove bitops/hweight usage of bits in tools/perf

We need to use lib/hweight.c for that, just like we do for lib/rbtree.c,
so tools need to link hweight.o. For now do it directly, but we need to
have a tools/lib/lk.a or .so that collects these goodies...

Reported-by: Jan Beulich <JBeulich@suse.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-a1e91dx3apzqw5kbdt7ut21s@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+30 -42
+2
tools/include/asm-generic/bitops.h
··· 22 22 #error only <linux/bitops.h> can be included directly 23 23 #endif 24 24 25 + #include <asm-generic/bitops/hweight.h> 26 + 25 27 #include <asm-generic/bitops/atomic.h> 26 28 27 29 #endif /* __TOOLS_ASM_GENERIC_BITOPS_H */
+1
tools/include/asm-generic/bitops/arch_hweight.h
··· 1 + #include "../../../../include/asm-generic/bitops/arch_hweight.h"
+1
tools/include/asm-generic/bitops/const_hweight.h
··· 1 + #include "../../../../include/asm-generic/bitops/const_hweight.h"
+7
tools/include/asm-generic/bitops/hweight.h
··· 1 + #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ 2 + #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ 3 + 4 + #include <asm-generic/bitops/arch_hweight.h> 5 + #include <asm-generic/bitops/const_hweight.h> 6 + 7 + #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_HWEIGHT_H_ */
+6 -1
tools/include/linux/bitops.h
··· 1 1 #ifndef _TOOLS_LINUX_BITOPS_H_ 2 2 #define _TOOLS_LINUX_BITOPS_H_ 3 3 4 + #include <asm/types.h> 4 5 #include <linux/kernel.h> 5 6 #include <linux/compiler.h> 6 - #include <asm/hweight.h> 7 7 8 8 #ifndef __WORDSIZE 9 9 #define __WORDSIZE (__SIZEOF_LONG__ * 8) ··· 18 18 #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) 19 19 #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) 20 20 #define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE) 21 + 22 + extern unsigned int __sw_hweight8(unsigned int w); 23 + extern unsigned int __sw_hweight16(unsigned int w); 24 + extern unsigned int __sw_hweight32(unsigned int w); 25 + extern unsigned long __sw_hweight64(__u64 w); 21 26 22 27 /* 23 28 * Include this here because some architectures need generic_ffs/fls in
+6
tools/perf/MANIFEST
··· 6 6 tools/lib/symbol/kallsyms.h 7 7 tools/lib/util/find_next_bit.c 8 8 tools/include/asm/bug.h 9 + tools/include/asm-generic/bitops/arch_hweight.h 9 10 tools/include/asm-generic/bitops/atomic.h 11 + tools/include/asm-generic/bitops/const_hweight.h 10 12 tools/include/asm-generic/bitops/__ffs.h 11 13 tools/include/asm-generic/bitops/__fls.h 12 14 tools/include/asm-generic/bitops/find.h 13 15 tools/include/asm-generic/bitops/fls64.h 14 16 tools/include/asm-generic/bitops/fls.h 17 + tools/include/asm-generic/bitops/hweight.h 15 18 tools/include/asm-generic/bitops.h 16 19 tools/include/linux/bitops.h 17 20 tools/include/linux/compiler.h ··· 22 19 tools/include/linux/hash.h 23 20 tools/include/linux/log2.h 24 21 tools/include/linux/types.h 22 + include/asm-generic/bitops/arch_hweight.h 23 + include/asm-generic/bitops/const_hweight.h 25 24 include/asm-generic/bitops/fls64.h 26 25 include/asm-generic/bitops/__fls.h 27 26 include/asm-generic/bitops/fls.h ··· 34 29 include/linux/hash.h 35 30 include/linux/stringify.h 36 31 lib/find_next_bit.c 32 + lib/hweight.c 37 33 lib/rbtree.c 38 34 include/linux/swab.h 39 35 arch/*/include/asm/unistd*.h
+6 -1
tools/perf/Makefile.perf
··· 232 232 LIB_H += ../../include/linux/stringify.h 233 233 LIB_H += util/include/linux/bitmap.h 234 234 LIB_H += ../include/linux/bitops.h 235 + LIB_H += ../include/asm-generic/bitops/arch_hweight.h 235 236 LIB_H += ../include/asm-generic/bitops/atomic.h 237 + LIB_H += ../include/asm-generic/bitops/const_hweight.h 236 238 LIB_H += ../include/asm-generic/bitops/find.h 237 239 LIB_H += ../include/asm-generic/bitops/fls64.h 238 240 LIB_H += ../include/asm-generic/bitops/fls.h 239 241 LIB_H += ../include/asm-generic/bitops/__ffs.h 240 242 LIB_H += ../include/asm-generic/bitops/__fls.h 243 + LIB_H += ../include/asm-generic/bitops/hweight.h 241 244 LIB_H += ../include/asm-generic/bitops.h 242 245 LIB_H += ../include/linux/compiler.h 243 246 LIB_H += ../include/linux/log2.h ··· 258 255 LIB_H += util/include/asm/asm-offsets.h 259 256 LIB_H += ../include/asm/bug.h 260 257 LIB_H += util/include/asm/byteorder.h 261 - LIB_H += util/include/asm/hweight.h 262 258 LIB_H += util/include/asm/swab.h 263 259 LIB_H += util/include/asm/system.h 264 260 LIB_H += util/include/asm/uaccess.h ··· 745 743 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $< 746 744 747 745 $(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS 746 + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 747 + 748 + $(OUTPUT)util/hweight.o: ../../lib/hweight.c $(OUTPUT)PERF-CFLAGS 748 749 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 749 750 750 751 $(OUTPUT)util/find_next_bit.o: ../lib/util/find_next_bit.c $(OUTPUT)PERF-CFLAGS
-31
tools/perf/util/hweight.c
··· 1 - #include <linux/bitops.h> 2 - 3 - /** 4 - * hweightN - returns the hamming weight of a N-bit word 5 - * @x: the word to weigh 6 - * 7 - * The Hamming Weight of a number is the total number of bits set in it. 8 - */ 9 - 10 - unsigned int hweight32(unsigned int w) 11 - { 12 - unsigned int res = w - ((w >> 1) & 0x55555555); 13 - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); 14 - res = (res + (res >> 4)) & 0x0F0F0F0F; 15 - res = res + (res >> 8); 16 - return (res + (res >> 16)) & 0x000000FF; 17 - } 18 - 19 - unsigned long hweight64(__u64 w) 20 - { 21 - #if BITS_PER_LONG == 32 22 - return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); 23 - #elif BITS_PER_LONG == 64 24 - __u64 res = w - ((w >> 1) & 0x5555555555555555ul); 25 - res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); 26 - res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; 27 - res = res + (res >> 8); 28 - res = res + (res >> 16); 29 - return (res + (res >> 32)) & 0x00000000000000FFul; 30 - #endif 31 - }
-8
tools/perf/util/include/asm/hweight.h
··· 1 - #ifndef PERF_HWEIGHT_H 2 - #define PERF_HWEIGHT_H 3 - 4 - #include <linux/types.h> 5 - unsigned int hweight32(unsigned int w); 6 - unsigned long hweight64(__u64 w); 7 - 8 - #endif /* PERF_HWEIGHT_H */
+1 -1
tools/perf/util/python-ext-sources
··· 10 10 util/evlist.c 11 11 util/evsel.c 12 12 util/cpumap.c 13 - util/hweight.c 13 + ../../lib/hweight.c 14 14 util/thread_map.c 15 15 util/util.c 16 16 util/xyarray.c