From: Sasha Levin <sashal@kernel.org>
To: mingo@kernel.org, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
jolsa@redhat.com, alexey.budankov@linux.intel.com,
songliubraving@fb.com, acme@redhat.com, allison@lohutok.net,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 04/11] tools bitmap: add bitmap_andnot definition
Date: Mon, 17 Feb 2020 21:41:26 -0500 [thread overview]
Message-ID: <20200218024133.5059-5-sashal@kernel.org> (raw)
In-Reply-To: <20200218024133.5059-1-sashal@kernel.org>
Add definition of bitmap_andnot() and wire tools/lib/bitmap.c into
liblockdep.
This is needed as a result of de4643a77356 ("locking/lockdep: Reuse lock
chains that have been freed").
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/include/linux/bitmap.h | 10 ++++++++++
tools/lib/bitmap.c | 15 +++++++++++++++
tools/lib/lockdep/Build | 2 +-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
index 477a1cae513f2..ab5df035f8eda 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -18,6 +18,8 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
int __bitmap_equal(const unsigned long *bitmap1,
const unsigned long *bitmap2, unsigned int bits);
void bitmap_clear(unsigned long *map, unsigned int start, int len);
+int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int bits);
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
@@ -178,4 +180,12 @@ static inline int bitmap_equal(const unsigned long *src1,
return __bitmap_equal(src1, src2, nbits);
}
+static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1,
+ const unsigned long *src2, unsigned int nbits)
+{
+ if (small_const_nbits(nbits))
+ return (*dst = *src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
+ return __bitmap_andnot(dst, src1, src2, nbits);
+}
+
#endif /* _PERF_BITOPS_H */
diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c
index 5043747ef6c5f..b6bc037623fc1 100644
--- a/tools/lib/bitmap.c
+++ b/tools/lib/bitmap.c
@@ -86,3 +86,18 @@ int __bitmap_equal(const unsigned long *bitmap1,
return 1;
}
+
+int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int bits)
+{
+ unsigned int k;
+ unsigned int lim = bits/BITS_PER_LONG;
+ unsigned long result = 0;
+
+ for (k = 0; k < lim; k++)
+ result |= (dst[k] = bitmap1[k] & ~bitmap2[k]);
+ if (bits % BITS_PER_LONG)
+ result |= (dst[k] = bitmap1[k] & ~bitmap2[k] &
+ BITMAP_LAST_WORD_MASK(bits));
+ return result != 0;
+}
diff --git a/tools/lib/lockdep/Build b/tools/lib/lockdep/Build
index 6f667355b0687..219a9e2d9e0ba 100644
--- a/tools/lib/lockdep/Build
+++ b/tools/lib/lockdep/Build
@@ -1 +1 @@
-liblockdep-y += common.o lockdep.o preload.o rbtree.o
+liblockdep-y += common.o lockdep.o preload.o rbtree.o ../../lib/bitmap.o
--
2.20.1
next prev parent reply other threads:[~2020-02-18 2:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 2:41 [PATCH 00/11] Fix up liblockdep for 5.6-rc Sasha Levin
2020-02-18 2:41 ` [PATCH 01/11] tools headers: Add kprobes.h header Sasha Levin
2020-02-18 2:41 ` [PATCH 02/11] tools headers: Add rcupdate.h header Sasha Levin
2020-02-18 2:41 ` [PATCH 03/11] tools/kernel.h: extend with dummy RCU functions Sasha Levin
2020-02-18 2:41 ` Sasha Levin [this message]
2020-02-18 2:41 ` [PATCH 05/11] tools/lib/lockdep: add definition required for IRQ flag tracing Sasha Levin
2020-02-18 2:41 ` [PATCH 06/11] tools/kernel.h: add BUILD_BUG_ON_NOT_POWER_OF_2 macro Sasha Levin
2020-02-18 2:41 ` [PATCH 07/11] tools bitmap: add bitmap_clear definition Sasha Levin
2020-02-18 2:41 ` [PATCH 08/11] tools/lib/lockdep: Hook up vsprintf, find_bit, hweight libraries Sasha Levin
2020-02-18 2:41 ` [PATCH 09/11] tools/lib/lockdep: Enable building with CONFIG_TRACE_IRQFLAGS Sasha Levin
2020-02-18 2:41 ` [PATCH 10/11] tools/lib/lockdep: New stacktrace API Sasha Levin
2020-02-18 2:41 ` [PATCH 11/11] tools/lib/lockdep: call lockdep_init_task on init Sasha Levin
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=20200218024133.5059-5-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=acme@redhat.com \
--cc=alexey.budankov@linux.intel.com \
--cc=allison@lohutok.net \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
/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.