Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp514318pxv; Wed, 30 Jun 2021 10:43:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTxU+9clIG98ax7zZZW3KjAYJ1Cvp/0Cd13Ibq9vqSEAEUTg/JmdIQ6BfiRYjQQtnOE9C5 X-Received: by 2002:a6b:6209:: with SMTP id f9mr8778595iog.109.1625075029920; Wed, 30 Jun 2021 10:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625075029; cv=none; d=google.com; s=arc-20160816; b=u3G2U5jMPRwe/NbyZ2rKr9m1HJwx5mv2vJz5Zt4uvNhvIHtFZnL5rzrgdlyiifb+Dt gnPyRuM7J4D1ROW1Gq5Iw9cojNl60jhScxB3bCzdFP4zgX0T6FzC1/ngsaINteymLuuC xl9zZwIV1wbspNLKCqwIsHheojvISug+t11A7kO45Rb1Y5c7SYYUziLkZpQtkEA9Uep4 +urOx1v8gHun+2CJgt8Ku4mFh8ORQoijr29x60+/38swjHJNu6rz/d2s/cruiz+0w7E1 zxVWhbdUZhdrv2/EdUu5wkgbqYObigYgcdGgyXvEYea6jSkTqmPvsEOQHCesh1bbsZoE SbrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0T2++UTf1rXBT29oCFgqzxfF2hTCO1urKz3llgWgFBI=; b=AOQIpfUT3KmJaZPVpe8ElGWDbpQzBZgoA+vy7idgW2slYe/GTJ7vB5u9C3HFYCzOH3 X0BmFKSVZ9NMSQz0zO8vVzgnlGfqA9cCj3vz6q4yycvIC0HKQRz6K4IHhnn3OYXrXUpR S3mlTpOqR/sCZJz0XgmuWc0SSnZK9dbzuBhmd6caeNcodHoRPHh9w47pJKvgbZAw32oM Io1nMEUGpp0KXjKgb1UhTcGvfnZsNxJrkeU2hoteIq5xnI7XtTB3RTrbBCDyHNHuFH0y n+NBrEoTuy1DhYI1UTS2rA+dEcNJSfMFd85ba0pChqsETi54pXIR2wX2NpurYBGrAx/s q48g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mCojysB+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n21si18740755ioo.26.2021.06.30.10.43.37; Wed, 30 Jun 2021 10:43:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mCojysB+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232773AbhF3RpA (ORCPT + 99 others); Wed, 30 Jun 2021 13:45:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:58444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbhF3Ro7 (ORCPT ); Wed, 30 Jun 2021 13:44:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4FFD86147E; Wed, 30 Jun 2021 17:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625074948; bh=xWWpj5twvOx7Y4AtxL4SiU2orhB/aR6msN0R0RPnt8k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mCojysB+NOEseMJtF/iN8SWWOD1SRoZ/3T5pHqlJyOPlgMJ6Zj+XjYA7Q8U0gv5N5 YHkIHTKOSRQGdLErem2nya4uvC5O19vygEDu8T6nixV4ZIVNBHuSQMdA6/0CGerpwC Gag1qmnNBKxlXSDHO1lkKJOyQxSHG851fnQUCMvxVce55PtrteziphCcL/4tuhR4tC XixOy/wBlQehf3qeDhmlB3JkOxDE8ULjbgR2cUgggV4m3CRdDoUGfVYrIaLLKuND// 1/uF/mIK0RiVmETU1q0vWXZ4THmugWyv1bNBAOQ3ZchDvciKeFL2OwMwkfDXzzSun7 Wale9ZxYwypMA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E848540B1A; Wed, 30 Jun 2021 14:42:24 -0300 (-03) Date: Wed, 30 Jun 2021 14:42:24 -0300 From: Arnaldo Carvalho de Melo To: Alexey Bayduraev Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini Subject: Re: [PATCH v8 09/22] tools lib: Introduce bitmap_intersects() operation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Jun 30, 2021 at 02:24:26PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Wed, Jun 30, 2021 at 06:54:48PM +0300, Alexey Bayduraev escreveu: > > Introduce bitmap_intersects() routine that tests whether > > Is this _adopting_ bitmap_intersects() from the kernel sources? Ok, clarified that in the changeset comment and applied this patch to reduce the number of patches in this patchset, there is another patch I think can cherry picked, checking. - ARnaldo > > bitmaps bitmap1 and bitmap2 intersects. This routine will > > be used during thread masks initialization. > > > > Acked-by: Andi Kleen > > Acked-by: Namhyung Kim > > Signed-off-by: Alexey Bayduraev > > --- > > tools/include/linux/bitmap.h | 11 +++++++++++ > > tools/lib/bitmap.c | 14 ++++++++++++++ > > 2 files changed, 25 insertions(+) > > > > diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h > > index 330dbf7509cc..9d959bc24859 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_intersects(const unsigned long *bitmap1, > > + const unsigned long *bitmap2, unsigned int bits); > > > > #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) > > #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) > > @@ -170,4 +172,13 @@ static inline int bitmap_equal(const unsigned long *src1, > > return __bitmap_equal(src1, src2, nbits); > > } > > > > +static inline int bitmap_intersects(const unsigned long *src1, > > + const unsigned long *src2, unsigned int nbits) > > +{ > > + if (small_const_nbits(nbits)) > > + return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; > > + else > > + return __bitmap_intersects(src1, src2, nbits); > > +} > > + > > #endif /* _PERF_BITOPS_H */ > > diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c > > index f4e914712b6f..db466ef7be9d 100644 > > --- a/tools/lib/bitmap.c > > +++ b/tools/lib/bitmap.c > > @@ -86,3 +86,17 @@ int __bitmap_equal(const unsigned long *bitmap1, > > > > return 1; > > } > > + > > +int __bitmap_intersects(const unsigned long *bitmap1, > > + const unsigned long *bitmap2, unsigned int bits) > > +{ > > + unsigned int k, lim = bits/BITS_PER_LONG; > > + for (k = 0; k < lim; ++k) > > + if (bitmap1[k] & bitmap2[k]) > > + return 1; > > + > > + if (bits % BITS_PER_LONG) > > + if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) > > + return 1; > > + return 0; > > +} > > -- > > 2.19.0 > > > > -- > > - Arnaldo -- - Arnaldo