[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200218024133.5059-8-sashal@kernel.org>
Date: Mon, 17 Feb 2020 21:41:29 -0500
From: Sasha Levin <sashal@...nel.org>
To: mingo@...nel.org, peterz@...radead.org
Cc: linux-kernel@...r.kernel.org, tglx@...utronix.de, jolsa@...hat.com,
alexey.budankov@...ux.intel.com, songliubraving@...com,
acme@...hat.com, allison@...utok.net,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 07/11] tools bitmap: add bitmap_clear definition
This is needed as a result of de4643a77356 ("locking/lockdep: Reuse lock
chains that have been freed").
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/lib/bitmap.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c
index b6bc037623fc1..873176c501e43 100644
--- a/tools/lib/bitmap.c
+++ b/tools/lib/bitmap.c
@@ -101,3 +101,23 @@ int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
BITMAP_LAST_WORD_MASK(bits));
return result != 0;
}
+
+void bitmap_clear(unsigned long *map, unsigned int start, int len)
+{
+ unsigned long *p = map + BIT_WORD(start);
+ const unsigned int size = start + len;
+ int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
+ unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
+
+ while (len - bits_to_clear >= 0) {
+ *p &= ~mask_to_clear;
+ len -= bits_to_clear;
+ bits_to_clear = BITS_PER_LONG;
+ mask_to_clear = ~0UL;
+ p++;
+ }
+ if (len) {
+ mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
+ *p &= ~mask_to_clear;
+ }
+}
--
2.20.1
Powered by blists - more mailing lists