From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
George@infradead.org, "Spelvin <linux"@horizon.com,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Wang Nan <wangnan0@huawei.com>, Yury Norov <yury.norov@gmail.com>
Subject: [PATCH 41/59] tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/
Date: Fri, 8 Jan 2016 15:02:48 -0300 [thread overview]
Message-ID: <1452276186-15202-42-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1452276186-15202-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
So that lib/find_bit.c doesn't requires anything inside tools/perf/
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: George Spelvin <linux@horizon.com
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Yury Norov <yury.norov@gmail.com>
Link: http://lkml.kernel.org/n/tip-7lxe7jgohaac5faodndhdmvk@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/include/linux/bitmap.h | 68 ++++++++++++++++++++++++++++++++++
tools/lib/bitmap.c | 31 ++++++++++++++++
tools/perf/util/Build | 5 +++
tools/perf/util/bitmap.c | 31 ----------------
tools/perf/util/include/linux/bitmap.h | 68 ----------------------------------
tools/perf/util/python-ext-sources | 2 +-
6 files changed, 105 insertions(+), 100 deletions(-)
create mode 100644 tools/include/linux/bitmap.h
create mode 100644 tools/lib/bitmap.c
delete mode 100644 tools/perf/util/bitmap.c
delete mode 100644 tools/perf/util/include/linux/bitmap.h
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
new file mode 100644
index 000000000000..28f5493da491
--- /dev/null
+++ b/tools/include/linux/bitmap.h
@@ -0,0 +1,68 @@
+#ifndef _PERF_BITOPS_H
+#define _PERF_BITOPS_H
+
+#include <string.h>
+#include <linux/bitops.h>
+
+#define DECLARE_BITMAP(name,bits) \
+ unsigned long name[BITS_TO_LONGS(bits)]
+
+int __bitmap_weight(const unsigned long *bitmap, int bits);
+void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, int bits);
+
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
+
+#define BITMAP_LAST_WORD_MASK(nbits) \
+( \
+ ((nbits) % BITS_PER_LONG) ? \
+ (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
+)
+
+#define small_const_nbits(nbits) \
+ (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
+
+static inline void bitmap_zero(unsigned long *dst, int nbits)
+{
+ if (small_const_nbits(nbits))
+ *dst = 0UL;
+ else {
+ int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
+ memset(dst, 0, len);
+ }
+}
+
+static inline int bitmap_weight(const unsigned long *src, int nbits)
+{
+ if (small_const_nbits(nbits))
+ return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
+ return __bitmap_weight(src, nbits);
+}
+
+static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
+ const unsigned long *src2, int nbits)
+{
+ if (small_const_nbits(nbits))
+ *dst = *src1 | *src2;
+ else
+ __bitmap_or(dst, src1, src2, nbits);
+}
+
+/**
+ * test_and_set_bit - Set a bit and return its old value
+ * @nr: Bit to set
+ * @addr: Address to count from
+ */
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+ unsigned long mask = BIT_MASK(nr);
+ unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+ unsigned long old;
+
+ old = *p;
+ *p = old | mask;
+
+ return (old & mask) != 0;
+}
+
+#endif /* _PERF_BITOPS_H */
diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c
new file mode 100644
index 000000000000..0a1adc1111fd
--- /dev/null
+++ b/tools/lib/bitmap.c
@@ -0,0 +1,31 @@
+/*
+ * From lib/bitmap.c
+ * Helper functions for bitmap.h.
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+#include <linux/bitmap.h>
+
+int __bitmap_weight(const unsigned long *bitmap, int bits)
+{
+ int k, w = 0, lim = bits/BITS_PER_LONG;
+
+ for (k = 0; k < lim; k++)
+ w += hweight_long(bitmap[k]);
+
+ if (bits % BITS_PER_LONG)
+ w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
+
+ return w;
+}
+
+void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, int bits)
+{
+ int k;
+ int nr = BITS_TO_LONGS(bits);
+
+ for (k = 0; k < nr; k++)
+ dst[k] = bitmap1[k] | bitmap2[k];
+}
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index e8bc10b41b66..5eec53a3f4ac 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -132,6 +132,7 @@ CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w
$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
+CFLAGS_bitmap.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
CFLAGS_find_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
CFLAGS_rbtree.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
@@ -142,6 +143,10 @@ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
+$(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE
+ $(call rule_mkdir)
+ $(call if_changed_dep,cc_o_c)
+
$(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
diff --git a/tools/perf/util/bitmap.c b/tools/perf/util/bitmap.c
deleted file mode 100644
index 0a1adc1111fd..000000000000
--- a/tools/perf/util/bitmap.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * From lib/bitmap.c
- * Helper functions for bitmap.h.
- *
- * This source code is licensed under the GNU General Public License,
- * Version 2. See the file COPYING for more details.
- */
-#include <linux/bitmap.h>
-
-int __bitmap_weight(const unsigned long *bitmap, int bits)
-{
- int k, w = 0, lim = bits/BITS_PER_LONG;
-
- for (k = 0; k < lim; k++)
- w += hweight_long(bitmap[k]);
-
- if (bits % BITS_PER_LONG)
- w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
-
- return w;
-}
-
-void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
- const unsigned long *bitmap2, int bits)
-{
- int k;
- int nr = BITS_TO_LONGS(bits);
-
- for (k = 0; k < nr; k++)
- dst[k] = bitmap1[k] | bitmap2[k];
-}
diff --git a/tools/perf/util/include/linux/bitmap.h b/tools/perf/util/include/linux/bitmap.h
deleted file mode 100644
index 28f5493da491..000000000000
--- a/tools/perf/util/include/linux/bitmap.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef _PERF_BITOPS_H
-#define _PERF_BITOPS_H
-
-#include <string.h>
-#include <linux/bitops.h>
-
-#define DECLARE_BITMAP(name,bits) \
- unsigned long name[BITS_TO_LONGS(bits)]
-
-int __bitmap_weight(const unsigned long *bitmap, int bits);
-void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
- const unsigned long *bitmap2, int bits);
-
-#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
-
-#define BITMAP_LAST_WORD_MASK(nbits) \
-( \
- ((nbits) % BITS_PER_LONG) ? \
- (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
-)
-
-#define small_const_nbits(nbits) \
- (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
-
-static inline void bitmap_zero(unsigned long *dst, int nbits)
-{
- if (small_const_nbits(nbits))
- *dst = 0UL;
- else {
- int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
- memset(dst, 0, len);
- }
-}
-
-static inline int bitmap_weight(const unsigned long *src, int nbits)
-{
- if (small_const_nbits(nbits))
- return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
- return __bitmap_weight(src, nbits);
-}
-
-static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
- const unsigned long *src2, int nbits)
-{
- if (small_const_nbits(nbits))
- *dst = *src1 | *src2;
- else
- __bitmap_or(dst, src1, src2, nbits);
-}
-
-/**
- * test_and_set_bit - Set a bit and return its old value
- * @nr: Bit to set
- * @addr: Address to count from
- */
-static inline int test_and_set_bit(int nr, unsigned long *addr)
-{
- unsigned long mask = BIT_MASK(nr);
- unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
- unsigned long old;
-
- old = *p;
- *p = old | mask;
-
- return (old & mask) != 0;
-}
-
-#endif /* _PERF_BITOPS_H */
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index f15d14fb35eb..8162ba0e2e57 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -10,7 +10,7 @@ util/ctype.c
util/evlist.c
util/evsel.c
util/cpumap.c
-util/bitmap.c
+../lib/bitmap.c
../lib/find_bit.c
../lib/hweight.c
util/thread_map.c
--
2.1.0
next prev parent reply other threads:[~2016-01-08 18:05 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 18:02 [GIT PULL 00/59] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 01/59] perf hist: Pass struct sample to __hists__add_entry() Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 02/59] perf hist: Save raw_data/size for tracepoint events Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 03/59] tools lib traceevent: Factor out and export print_event_field[s]() Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 04/59] perf top: Create the evlist sooner Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 05/59] perf tools: Pass evlist to setup_sorting() Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 06/59] perf tools: Add dynamic sort key for tracepoint events Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 07/59] perf tools: Try to show pretty printed output for dynamic sort keys Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 08/59] perf tools: Add 'trace' sort key Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 09/59] perf report/top: Add --raw-trace option Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 10/59] perf tools: Support shortcuts for events in dynamic sort keys Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 11/59] perf tools: Support '<event>.*' dynamic sort key Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 12/59] perf tools: Skip dynamic fields not defined for current event Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 13/59] perf tools: Add 'trace_fields' dynamic sort key Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 14/59] perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 15/59] tools build feature: Fix feature_check_display_code typo Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 16/59] tools build feature: Move dwarf post unwind choice output into perf Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 17/59] tools build feature: Introduce feature_assign macro Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 18/59] tools build feature: Use value assignment form for FEATURE-DUMP file Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 19/59] perf build: Use FEATURE-DUMP in bpf subproject Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 20/59] perf tools: Add all matching dynamic sort keys for field name Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 21/59] perf report: Add documentation for dynamic sort keys Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 22/59] perf stat record: Keep sample_type 0 for pipe session Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 23/59] perf script: Process cpu/threads maps Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 24/59] perf script: Process stat config event Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 25/59] perf script: Add process_stat/process_stat_interval scripting interface Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 26/59] perf script: Add stat default handlers Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 27/59] perf script: Add python support for stat events Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 28/59] perf cpumap: Fix cpu conversion in cpu_map__from_entries Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 29/59] perf script: Display stat events by default Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 30/59] perf script: Add stat-cpi.py script Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 31/59] perf pmu: fix alias->snapshot missing initialization bug Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 32/59] perf tests: No need to set attr.sample_freq in the perf time to TSC test Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 33/59] perf evlist: Introduce perf_evlist__new_dummy constructor Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 34/59] perf test: Use "dummy" events in the PERF_RECORD_ test Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 35/59] perf test: No need for setting attr.sample_freq on the RECORD test Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 36/59] perf python: Add missing files to binding link list Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 37/59] perf tests: No need to set attr.sample_freq for tracking !PERF_RECORD_SAMPLE Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 38/59] perf tests: Give a bit more information on the CQM test failure path Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 39/59] tools lib: Move find_next_bit.c to tools/lib/ Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 40/59] tools lib: Sync tools/lib/find_bit.c with the kernel Arnaldo Carvalho de Melo
2016-01-08 18:02 ` Arnaldo Carvalho de Melo [this message]
2016-01-08 18:02 ` [PATCH 42/59] perf top: Decay periods in callchains Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 43/59] perf report: Change default to use event group view Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 44/59] perf tools: Do not show trace command if it's not compiled in Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 45/59] perf tools: Add missing headers in perf's MANIFEST Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 46/59] perf script: Align event name properly Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 47/59] perf tools: Include all tools/lib directory for tags/cscope/TAGS targets Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 48/59] perf tools: Remove list entry from struct sort_entry Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 49/59] perf tools: Add overhead/overhead_children keys defaults via string Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 50/59] perf diff: Use perf_hpp__register_sort_field interface Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 51/59] perf hists: Export a couple of hist functions Arnaldo Carvalho de Melo
2016-01-08 18:02 ` [PATCH 52/59] perf report: Show random usage tip on the help line Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 53/59] perf evlist: Make perf_evlist__open() open evsels with their cpus and threads (like perf record does) Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 54/59] perf evlist: Remove perf_evlist__(enable|disable)_event functions Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 55/59] perf unwind: Use find_map function in access_dso_mem Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 56/59] perf unwind: Check for mmaps also in MAP__VARIABLE tree Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 57/59] perf libdw: " Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 58/59] perf record: Store data mmaps for dwarf unwind Arnaldo Carvalho de Melo
2016-01-08 18:03 ` [PATCH 59/59] perf evlist: Add --trace-fields option to show trace fields Arnaldo Carvalho de Melo
2016-01-09 16:20 ` [GIT PULL 00/59] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452276186-15202-42-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc="Spelvin <linux"@horizon.com \
--cc=George@infradead.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=bp@suse.de \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.