From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0676EC433DF for ; Mon, 22 Jun 2020 22:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7CE820786 for ; Mon, 22 Jun 2020 22:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592865801; bh=1r88PiJ4+qN8LrCQuZ269REltscufpvg7w78mKLxLaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PzcS7ABwOUY/h01x1dIau4akWp2AcpQc2pqrehokTwSBCc2v6YPYVBHdVKpzpUbwb 1vmo2atr4jyNWaxZ5uXkb1DtfzyTzQnvAipoyYYm6l0sVMcZhenbopOQLAGPbc7AvU FftD68JSolBtLaErqHNslQGv+r1IspKxggRj0Rgw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731348AbgFVWnT (ORCPT ); Mon, 22 Jun 2020 18:43:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:59788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731289AbgFVWnI (ORCPT ); Mon, 22 Jun 2020 18:43:08 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75244207BC; Mon, 22 Jun 2020 22:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592865787; bh=1r88PiJ4+qN8LrCQuZ269REltscufpvg7w78mKLxLaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIsk6Gl1eiC+MlHSP5rnz2wNKCPYbYXYQwMpB6Yh7x6wNUFOem98yTQF7YqqbzI3b iZ9O4AfdakRzDbjQkNQGEuvIUJNGAWCY5NPN0F+EWJQsf6cwWPLcu4MzLZEDFVA1YN 7cI92fLDgdZ3yRl7o4JyLICv4n8dUWJe5OAcMvXo= From: Sasha Levin 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 04/14] tools bitmap: add bitmap_andnot definition Date: Mon, 22 Jun 2020 18:42:48 -0400 Message-Id: <20200622224258.1208588-5-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200622224258.1208588-1-sashal@kernel.org> References: <20200622224258.1208588-1-sashal@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.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 --- 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.25.1