diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-19 16:15:24 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-19 16:15:24 -0500 |
| commit | 88a57667f2990f00b019d46c8426441c9e516d51 (patch) | |
| tree | 392f5dcb9724e688aa307e2ed2cc8ee13e66f570 /tools/perf/util/include | |
| parent | 34b85e3574424beb30e4cd163e6da2e2282d2683 (diff) | |
| parent | ac931f87a647ca156f65a4c00e7297165e4fa2d8 (diff) | |
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes and cleanups from Ingo Molnar:
"A kernel fix plus mostly tooling fixes, but also some tooling
restructuring and cleanups"
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (39 commits)
perf: Fix building warning on ARM 32
perf symbols: Fix use after free in filename__read_build_id
perf evlist: Use roundup_pow_of_two
tools: Adopt roundup_pow_of_two
perf tools: Make the mmap length autotuning more robust
tools: Adopt rounddown_pow_of_two and deps
tools: Adopt fls_long and deps
tools: Move bitops.h from tools/perf/util to tools/
tools: Introduce asm-generic/bitops.h
tools lib: Move asm-generic/bitops/find.h code to tools/include and tools/lib
tools: Whitespace prep patches for moving bitops.h
tools: Move code originally from asm-generic/atomic.h into tools/include/asm-generic/
tools: Move code originally from linux/log2.h to tools/include/linux/
tools: Move __ffs implementation to tools/include/asm-generic/bitops/__ffs.h
perf evlist: Do not use hard coded value for a mmap_pages default
perf trace: Let the perf_evlist__mmap autosize the number of pages to use
perf evlist: Improve the strerror_mmap method
perf evlist: Clarify sterror_mmap variable names
perf evlist: Fixup brown paper bag on "hint" for --mmap-pages cmdline arg
perf trace: Provide a better explanation when mmap fails
...
Diffstat (limited to 'tools/perf/util/include')
| -rw-r--r-- | tools/perf/util/include/linux/bitops.h | 162 |
1 files changed, 0 insertions, 162 deletions
diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h deleted file mode 100644 index c3294163de17..000000000000 --- a/tools/perf/util/include/linux/bitops.h +++ /dev/null | |||
| @@ -1,162 +0,0 @@ | |||
| 1 | #ifndef _PERF_LINUX_BITOPS_H_ | ||
| 2 | #define _PERF_LINUX_BITOPS_H_ | ||
| 3 | |||
| 4 | #include <linux/kernel.h> | ||
| 5 | #include <linux/compiler.h> | ||
| 6 | #include <asm/hweight.h> | ||
| 7 | |||
| 8 | #ifndef __WORDSIZE | ||
| 9 | #define __WORDSIZE (__SIZEOF_LONG__ * 8) | ||
| 10 | #endif | ||
| 11 | |||
| 12 | #define BITS_PER_LONG __WORDSIZE | ||
| 13 | #define BITS_PER_BYTE 8 | ||
| 14 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) | ||
| 15 | #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) | ||
| 16 | #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) | ||
| 17 | #define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE) | ||
| 18 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | ||
| 19 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
| 20 | |||
| 21 | #define for_each_set_bit(bit, addr, size) \ | ||
| 22 | for ((bit) = find_first_bit((addr), (size)); \ | ||
| 23 | (bit) < (size); \ | ||
| 24 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | ||
| 25 | |||
| 26 | /* same as for_each_set_bit() but use bit as value to start with */ | ||
| 27 | #define for_each_set_bit_from(bit, addr, size) \ | ||
| 28 | for ((bit) = find_next_bit((addr), (size), (bit)); \ | ||
| 29 | (bit) < (size); \ | ||
| 30 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | ||
| 31 | |||
| 32 | static inline void set_bit(int nr, unsigned long *addr) | ||
| 33 | { | ||
| 34 | addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG); | ||
| 35 | } | ||
| 36 | |||
| 37 | static inline void clear_bit(int nr, unsigned long *addr) | ||
| 38 | { | ||
| 39 | addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG)); | ||
| 40 | } | ||
| 41 | |||
| 42 | static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) | ||
| 43 | { | ||
| 44 | return ((1UL << (nr % BITS_PER_LONG)) & | ||
| 45 | (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0; | ||
| 46 | } | ||
| 47 | |||
| 48 | static inline unsigned long hweight_long(unsigned long w) | ||
| 49 | { | ||
| 50 | return sizeof(w) == 4 ? hweight32(w) : hweight64(w); | ||
| 51 | } | ||
| 52 | |||
| 53 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
| 54 | |||
| 55 | /** | ||
| 56 | * __ffs - find first bit in word. | ||
| 57 | * @word: The word to search | ||
| 58 | * | ||
| 59 | * Undefined if no bit exists, so code should check against 0 first. | ||
| 60 | */ | ||
| 61 | static __always_inline unsigned long __ffs(unsigned long word) | ||
| 62 | { | ||
| 63 | int num = 0; | ||
| 64 | |||
| 65 | #if BITS_PER_LONG == 64 | ||
| 66 | if ((word & 0xffffffff) == 0) { | ||
| 67 | num += 32; | ||
| 68 | word >>= 32; | ||
| 69 | } | ||
| 70 | #endif | ||
| 71 | if ((word & 0xffff) == 0) { | ||
| 72 | num += 16; | ||
| 73 | word >>= 16; | ||
| 74 | } | ||
| 75 | if ((word & 0xff) == 0) { | ||
| 76 | num += 8; | ||
| 77 | word >>= 8; | ||
| 78 | } | ||
| 79 | if ((word & 0xf) == 0) { | ||
| 80 | num += 4; | ||
| 81 | word >>= 4; | ||
| 82 | } | ||
| 83 | if ((word & 0x3) == 0) { | ||
| 84 | num += 2; | ||
| 85 | word >>= 2; | ||
| 86 | } | ||
| 87 | if ((word & 0x1) == 0) | ||
| 88 | num += 1; | ||
| 89 | return num; | ||
| 90 | } | ||
| 91 | |||
| 92 | typedef const unsigned long __attribute__((__may_alias__)) long_alias_t; | ||
| 93 | |||
| 94 | /* | ||
| 95 | * Find the first set bit in a memory region. | ||
| 96 | */ | ||
| 97 | static inline unsigned long | ||
| 98 | find_first_bit(const unsigned long *addr, unsigned long size) | ||
| 99 | { | ||
| 100 | long_alias_t *p = (long_alias_t *) addr; | ||
| 101 | unsigned long result = 0; | ||
| 102 | unsigned long tmp; | ||
| 103 | |||
| 104 | while (size & ~(BITS_PER_LONG-1)) { | ||
| 105 | if ((tmp = *(p++))) | ||
| 106 | goto found; | ||
| 107 | result += BITS_PER_LONG; | ||
| 108 | size -= BITS_PER_LONG; | ||
| 109 | } | ||
| 110 | if (!size) | ||
| 111 | return result; | ||
| 112 | |||
| 113 | tmp = (*p) & (~0UL >> (BITS_PER_LONG - size)); | ||
| 114 | if (tmp == 0UL) /* Are any bits set? */ | ||
| 115 | return result + size; /* Nope. */ | ||
| 116 | found: | ||
| 117 | return result + __ffs(tmp); | ||
| 118 | } | ||
| 119 | |||
| 120 | /* | ||
| 121 | * Find the next set bit in a memory region. | ||
| 122 | */ | ||
| 123 | static inline unsigned long | ||
| 124 | find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) | ||
| 125 | { | ||
| 126 | const unsigned long *p = addr + BITOP_WORD(offset); | ||
| 127 | unsigned long result = offset & ~(BITS_PER_LONG-1); | ||
| 128 | unsigned long tmp; | ||
| 129 | |||
| 130 | if (offset >= size) | ||
| 131 | return size; | ||
| 132 | size -= result; | ||
| 133 | offset %= BITS_PER_LONG; | ||
| 134 | if (offset) { | ||
| 135 | tmp = *(p++); | ||
| 136 | tmp &= (~0UL << offset); | ||
| 137 | if (size < BITS_PER_LONG) | ||
| 138 | goto found_first; | ||
| 139 | if (tmp) | ||
| 140 | goto found_middle; | ||
| 141 | size -= BITS_PER_LONG; | ||
| 142 | result += BITS_PER_LONG; | ||
| 143 | } | ||
| 144 | while (size & ~(BITS_PER_LONG-1)) { | ||
| 145 | if ((tmp = *(p++))) | ||
| 146 | goto found_middle; | ||
| 147 | result += BITS_PER_LONG; | ||
| 148 | size -= BITS_PER_LONG; | ||
| 149 | } | ||
| 150 | if (!size) | ||
| 151 | return result; | ||
| 152 | tmp = *p; | ||
| 153 | |||
| 154 | found_first: | ||
| 155 | tmp &= (~0UL >> (BITS_PER_LONG - size)); | ||
| 156 | if (tmp == 0UL) /* Are any bits set? */ | ||
| 157 | return result + size; /* Nope. */ | ||
| 158 | found_middle: | ||
| 159 | return result + __ffs(tmp); | ||
| 160 | } | ||
| 161 | |||
| 162 | #endif | ||
