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

perf tools: Use kernel bitmap library

Use the kernel bitmap library for internal perf tools uses.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1255792354-11304-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Frederic Weisbecker and committed by
Ingo Molnar
5a116dd2 11018201

+156 -5
+16
tools/perf/Makefile
··· 363 363 LIB_OBJS += util/parse-events.o 364 364 LIB_OBJS += util/path.o 365 365 LIB_OBJS += util/rbtree.o 366 + LIB_OBJS += util/bitmap.o 367 + LIB_OBJS += util/hweight.o 368 + LIB_OBJS += util/find_next_bit.o 366 369 LIB_OBJS += util/run-command.o 367 370 LIB_OBJS += util/quote.o 368 371 LIB_OBJS += util/strbuf.o ··· 792 789 793 790 util/rbtree.o: ../../lib/rbtree.c PERF-CFLAGS 794 791 $(QUIET_CC)$(CC) -o util/rbtree.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 792 + 793 + # some perf warning policies can't fit to lib/bitmap.c, eg: it warns about variable shadowing 794 + # from <string.h> that comes from kernel headers wrapping. 795 + KBITMAP_FLAGS=`echo $(ALL_CFLAGS) | sed s/-Wshadow// | sed s/-Wswitch-default// | sed s/-Wextra//` 796 + 797 + util/bitmap.o: ../../lib/bitmap.c PERF-CFLAGS 798 + $(QUIET_CC)$(CC) -o util/bitmap.o -c $(KBITMAP_FLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 799 + 800 + util/hweight.o: ../../lib/hweight.c PERF-CFLAGS 801 + $(QUIET_CC)$(CC) -o util/hweight.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 802 + 803 + util/find_next_bit.o: ../../lib/find_next_bit.c PERF-CFLAGS 804 + $(QUIET_CC)$(CC) -o util/find_next_bit.o -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $< 795 805 796 806 perf-%$X: %.o $(PERFLIBS) 797 807 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
-3
tools/perf/builtin-record.c
··· 21 21 #include <unistd.h> 22 22 #include <sched.h> 23 23 24 - #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1) 25 - #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask)) 26 - 27 24 static int fd[MAX_NR_CPUS][MAX_COUNTERS]; 28 25 29 26 static long default_interval = 0;
-2
tools/perf/builtin-sched.c
··· 38 38 #define PR_SET_NAME 15 /* Set process name */ 39 39 #define MAX_CPUS 4096 40 40 41 - #define BUG_ON(x) assert(!(x)) 42 - 43 41 static u64 run_measurement_overhead; 44 42 static u64 sleep_measurement_overhead; 45 43
+6
tools/perf/util/include/asm/bitops.h
··· 1 + #include "../../../../include/asm-generic/bitops/__fls.h" 2 + #include "../../../../include/asm-generic/bitops/fls.h" 3 + #include "../../../../include/asm-generic/bitops/fls64.h" 4 + #include "../../../../include/asm-generic/bitops/__ffs.h" 5 + #include "../../../../include/asm-generic/bitops/ffz.h" 6 + #include "../../../../include/asm-generic/bitops/hweight.h"
+2
tools/perf/util/include/asm/byteorder.h
··· 1 + #include "../asm/types.h" 2 + #include "../../../../include/linux/swab.h"
+1
tools/perf/util/include/asm/swab.h
··· 1 + /* stub */
+17
tools/perf/util/include/asm/types.h
··· 1 + #ifndef PERF_ASM_TYPES_H_ 2 + #define PERF_ASM_TYPES_H_ 3 + 4 + #include <linux/compiler.h> 5 + #include "../../types.h" 6 + #include <sys/types.h> 7 + 8 + /* CHECKME: Not sure both always match */ 9 + #define BITS_PER_LONG __WORDSIZE 10 + 11 + typedef u64 __u64; 12 + typedef u32 __u32; 13 + typedef u16 __u16; 14 + typedef u8 __u8; 15 + typedef s64 __s64; 16 + 17 + #endif /* PERF_ASM_TYPES_H_ */
+14
tools/perf/util/include/asm/uaccess.h
··· 1 + #ifndef _PERF_ASM_UACCESS_H_ 2 + #define _PERF_ASM_UACCESS_H_ 3 + 4 + #define __get_user(src, dest) \ 5 + ({ \ 6 + (src) = *dest; \ 7 + 0; \ 8 + }) 9 + 10 + #define get_user __get_user 11 + 12 + #define access_ok(type, addr, size) 1 13 + 14 + #endif
+2
tools/perf/util/include/linux/bitmap.h
··· 1 + #include "../../../../include/linux/bitmap.h" 2 + #include "../../../../include/asm-generic/bitops/find.h"
+27
tools/perf/util/include/linux/bitops.h
··· 1 + #ifndef _PERF_LINUX_BITOPS_H_ 2 + #define _PERF_LINUX_BITOPS_H_ 3 + 4 + #define __KERNEL__ 5 + 6 + #define CONFIG_GENERIC_FIND_NEXT_BIT 7 + #define CONFIG_GENERIC_FIND_FIRST_BIT 8 + #include "../../../../include/linux/bitops.h" 9 + 10 + static inline void set_bit(int nr, unsigned long *addr) 11 + { 12 + addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG); 13 + } 14 + 15 + static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) 16 + { 17 + return ((1UL << (nr % BITS_PER_LONG)) & 18 + (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0; 19 + } 20 + 21 + unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, unsigned 22 + long size, unsigned long offset); 23 + 24 + unsigned long generic_find_next_le_bit(const unsigned long *addr, unsigned 25 + long size, unsigned long offset); 26 + 27 + #endif
+10
tools/perf/util/include/linux/compiler.h
··· 1 + #ifndef _PERF_LINUX_COMPILER_H_ 2 + #define _PERF_LINUX_COMPILER_H_ 3 + 4 + #ifndef __always_inline 5 + #define __always_inline inline 6 + #endif 7 + #define __user 8 + #define __attribute_const__ 9 + 10 + #endif
+1
tools/perf/util/include/linux/ctype.h
··· 1 + #include "../../../../include/linux/ctype.h"
+59
tools/perf/util/include/linux/kernel.h
··· 1 1 #ifndef PERF_LINUX_KERNEL_H_ 2 2 #define PERF_LINUX_KERNEL_H_ 3 3 4 + #include <stdarg.h> 5 + #include <stdio.h> 6 + #include <stdlib.h> 7 + #include <assert.h> 8 + 9 + #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 10 + 11 + #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) 12 + #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) 13 + 4 14 #ifndef offsetof 5 15 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 6 16 #endif ··· 35 25 (void) (&_max1 == &_max2); \ 36 26 _max1 > _max2 ? _max1 : _max2; }) 37 27 #endif 28 + 29 + #ifndef min 30 + #define min(x, y) ({ \ 31 + typeof(x) _min1 = (x); \ 32 + typeof(y) _min2 = (y); \ 33 + (void) (&_min1 == &_min2); \ 34 + _min1 < _min2 ? _min1 : _min2; }) 35 + #endif 36 + 37 + #ifndef BUG_ON 38 + #define BUG_ON(cond) assert(!(cond)) 39 + #endif 40 + 41 + /* 42 + * Both need more care to handle endianness 43 + * (Don't use bitmap_copy_le() for now) 44 + */ 45 + #define cpu_to_le64(x) (x) 46 + #define cpu_to_le32(x) (x) 47 + 48 + static inline int 49 + vscnprintf(char *buf, size_t size, const char *fmt, va_list args) 50 + { 51 + int i; 52 + ssize_t ssize = size; 53 + 54 + i = vsnprintf(buf, size, fmt, args); 55 + 56 + return (i >= ssize) ? (ssize - 1) : i; 57 + } 58 + 59 + static inline int scnprintf(char * buf, size_t size, const char * fmt, ...) 60 + { 61 + va_list args; 62 + ssize_t ssize = size; 63 + int i; 64 + 65 + va_start(args, fmt); 66 + i = vsnprintf(buf, size, fmt, args); 67 + va_end(args); 68 + 69 + return (i >= ssize) ? (ssize - 1) : i; 70 + } 71 + 72 + static inline unsigned long 73 + simple_strtoul(const char *nptr, char **endptr, int base) 74 + { 75 + return strtoul(nptr, endptr, base); 76 + } 38 77 39 78 #endif
+1
tools/perf/util/include/linux/types.h
··· 1 + /* stub */