From: Sasha Levin <sashal@kernel.org>
To: peterz@infradead.org
Cc: mingo@kernel.org, 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, sashal@kernel.org
Subject: [PATCH v3 06/14] tools bitmap: add bitmap_clear definition
Date: Mon, 22 Jun 2020 18:42:50 -0400 [thread overview]
Message-ID: <20200622224258.1208588-7-sashal@kernel.org> (raw)
In-Reply-To: <20200622224258.1208588-1-sashal@kernel.org>
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/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.25.1
next prev parent reply other threads:[~2020-06-22 22:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 22:42 [PATCH v3 00/14] Fix up liblockdep for 5.8-rc Sasha Levin
2020-06-22 22:42 ` [PATCH v3 01/14] tools headers: Add kprobes.h header Sasha Levin
2020-06-22 22:42 ` [PATCH v3 02/14] tools headers: Add rcupdate.h header Sasha Levin
2020-06-22 22:42 ` [PATCH v3 03/14] tools/kernel.h: extend with dummy RCU functions Sasha Levin
2020-06-22 22:42 ` [PATCH v3 04/14] tools bitmap: add bitmap_andnot definition Sasha Levin
2020-06-22 22:42 ` [PATCH v3 05/14] tools/lib/lockdep: add definition required for IRQ flag tracing Sasha Levin
2020-06-22 22:42 ` Sasha Levin [this message]
2020-06-22 22:42 ` [PATCH v3 07/14] tools/lib/lockdep: Hook up vsprintf, find_bit, hweight libraries Sasha Levin
2020-06-22 22:42 ` [PATCH v3 08/14] tools/lib/lockdep: Enable building with CONFIG_TRACE_IRQFLAGS Sasha Levin
2020-06-22 22:42 ` [PATCH v3 09/14] tools/lib/lockdep: New stacktrace API Sasha Levin
2020-06-22 22:42 ` [PATCH v3 10/14] tools/lib/lockdep: call lockdep_init_task on init Sasha Levin
2020-06-22 22:42 ` [PATCH v3 11/14] tools/lib/lockdep: switch to using lockdep_init_map_waits Sasha Levin
2020-06-22 22:42 ` [PATCH v3 12/14] tools/kernel.h: hide noinstr Sasha Levin
2020-06-23 3:12 ` kernel test robot
2020-06-22 22:42 ` [PATCH v3 13/14] tools/lib/lockdep: explicitly declare lockdep_init_task() Sasha Levin
2020-06-22 22:42 ` [PATCH v3 14/14] tools/kernel.h: hide task_struct.hardirq_chain_key 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=20200622224258.1208588-7-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox