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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E51CFC433EF for ; Fri, 11 Feb 2022 18:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352426AbiBKSCF (ORCPT ); Fri, 11 Feb 2022 13:02:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352442AbiBKSCC (ORCPT ); Fri, 11 Feb 2022 13:02:02 -0500 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40CB62C9 for ; Fri, 11 Feb 2022 10:02:01 -0800 (PST) Received: by mail-io1-xd33.google.com with SMTP id d188so12365276iof.7 for ; Fri, 11 Feb 2022 10:02:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WuU98BQWJ3JvxA0l3dqFEtp2hO3xbYQYBGFwDoum9mA=; b=IQQa84bdtaXRSdyR/rpKt0SgnPXBqmxmJhh+I01uwaxqxWu4ojcAKkL5xNw2hhBGl0 SqAcTIwGJOKoKuNltCzgv257aZj9Vr99QBpN7fDwSCfVrlHje/fQNIOKoT2Oaziq8EXi hkg4zp1Ee8VavOB4GljXvcV5lpnMc4zLiaQNUHF7HdGtilmw7DZd+3t0qKZgd5a2HdpH BakB8fh/e/dFXB9ddZuAAmTUp44pbvrS24H8kEGWZ/eS+JxRgohZIyxGzmv6OnwEinWq gyu2ZbJDXNO8o/ygp6HsRMRkWmTYq9HG8fLk2PoQbf5hE34N7V6vcspEXm8Qk3ExjvaJ +tiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WuU98BQWJ3JvxA0l3dqFEtp2hO3xbYQYBGFwDoum9mA=; b=Nsr8XBnyqBenJvbkWRzEKj79v3ah3qCFFC/SGYeV87lR1HMy44wNYqPxske30pdPHv Bl7wDYUT75PX393XF5gFu+b4jd9ltIFEUWuz/T5b29BlerA23s+HvoBWNctapEKY6ZQe 5x31C0RNUl15p3QhMe/QS+yYKC48NkLxoyigKBAeGU2LjOhr5uJxKoQ5hmaeoOHeOFFx C97ymDoa4Ua9Xwk/OTmCU3ST1o2xt4xJNwiwJunhDNJxQ+j4owl6DUJwtXAMujPHzcWo UB609unNdg4B6luLaASuHdmrY4fEahBn5yIVkANzN0pvcApGIVlWXaCgXaEw02IlRif/ 1+4g== X-Gm-Message-State: AOAM532epJvmlA4QcqeBDx4JrQ7I4bvJdUJTuu4Fd7+IlCgiPn8PD7L1 Kq6G4opxqy2PYYERw06ttHE= X-Google-Smtp-Source: ABdhPJxJmxFpXOYmnUs8JwVDIPbLVn5DtmHoImtfp1nRCsmQ3PoW8zuCBCZu/2oyU1rR5Wa33NzJlQ== X-Received: by 2002:a6b:ef06:: with SMTP id k6mr1445483ioh.70.1644602520515; Fri, 11 Feb 2022 10:02:00 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id m1sm13808221ilu.87.2022.02.11.10.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 10:02:00 -0800 (PST) Date: Fri, 11 Feb 2022 09:59:49 -0800 From: Yury Norov To: Mark Rutland Cc: Will Deacon , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Shaokun Zhang , Qi Liu , Khuong Dinh , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 12/49] perf: replace bitmap_weight with bitmap_empty where appropriate Message-ID: References: <20220210224933.379149-1-yury.norov@gmail.com> <20220210224933.379149-13-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 11, 2022 at 10:25:23AM +0000, Mark Rutland wrote: > Hi Yury, > > On Thu, Feb 10, 2022 at 02:48:56PM -0800, Yury Norov wrote: > > In some places, drivers/perf code calls bitmap_weight() to check if any > > bit of a given bitmap is set. It's better to use bitmap_empty() in that > > case because bitmap_empty() stops traversing the bitmap as soon as it > > finds first set bit, while bitmap_weight() counts all bits unconditionally. > > > > Signed-off-by: Yury Norov > > This looks like a nice semantic cleanup to me, so FWIW: Thanks :) > Acked-by: Mark Rutland > > How are you expecting to queue all of this? I expect maintainers of corresponding subsystems will pick most of the material. For the rest, I have my own bitmap branch. > Should Will and I pick this patch? Yes please. > Thanks, > Mark. > > > --- > > drivers/perf/arm-cci.c | 2 +- > > drivers/perf/arm_pmu.c | 4 ++-- > > drivers/perf/hisilicon/hisi_uncore_pmu.c | 2 +- > > drivers/perf/xgene_pmu.c | 2 +- > > 4 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c > > index 54aca3a62814..96e09fa40909 100644 > > --- a/drivers/perf/arm-cci.c > > +++ b/drivers/perf/arm-cci.c > > @@ -1096,7 +1096,7 @@ static void cci_pmu_enable(struct pmu *pmu) > > { > > struct cci_pmu *cci_pmu = to_cci_pmu(pmu); > > struct cci_pmu_hw_events *hw_events = &cci_pmu->hw_events; > > - int enabled = bitmap_weight(hw_events->used_mask, cci_pmu->num_cntrs); > > + bool enabled = !bitmap_empty(hw_events->used_mask, cci_pmu->num_cntrs); > > unsigned long flags; > > > > if (!enabled) > > diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c > > index 295cc7952d0e..a31b302b0ade 100644 > > --- a/drivers/perf/arm_pmu.c > > +++ b/drivers/perf/arm_pmu.c > > @@ -524,7 +524,7 @@ static void armpmu_enable(struct pmu *pmu) > > { > > struct arm_pmu *armpmu = to_arm_pmu(pmu); > > struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); > > - int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); > > + bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events); > > > > /* For task-bound events we may be called on other CPUs */ > > if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) > > @@ -785,7 +785,7 @@ static int cpu_pm_pmu_notify(struct notifier_block *b, unsigned long cmd, > > { > > struct arm_pmu *armpmu = container_of(b, struct arm_pmu, cpu_pm_nb); > > struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); > > - int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); > > + bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events); > > > > if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) > > return NOTIFY_DONE; > > diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c > > index a738aeab5c04..358e4e284a62 100644 > > --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c > > +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c > > @@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read); > > void hisi_uncore_pmu_enable(struct pmu *pmu) > > { > > struct hisi_pmu *hisi_pmu = to_hisi_pmu(pmu); > > - int enabled = bitmap_weight(hisi_pmu->pmu_events.used_mask, > > + bool enabled = !bitmap_empty(hisi_pmu->pmu_events.used_mask, > > hisi_pmu->num_counters); > > > > if (!enabled) > > diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c > > index 5283608dc055..0c32dffc7ede 100644 > > --- a/drivers/perf/xgene_pmu.c > > +++ b/drivers/perf/xgene_pmu.c > > @@ -867,7 +867,7 @@ static void xgene_perf_pmu_enable(struct pmu *pmu) > > { > > struct xgene_pmu_dev *pmu_dev = to_pmu_dev(pmu); > > struct xgene_pmu *xgene_pmu = pmu_dev->parent; > > - int enabled = bitmap_weight(pmu_dev->cntr_assign_mask, > > + bool enabled = !bitmap_empty(pmu_dev->cntr_assign_mask, > > pmu_dev->max_counters); > > > > if (!enabled) > > -- > > 2.32.0 > > 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 724F3C433EF for ; Fri, 11 Feb 2022 18:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PDCPi9EhQP8FB4OXfU8tR7A58q+MmT8b85WQ0Pdb594=; b=oZ+lPRazyLci4c DKIRvFpxcuAVuu7H9IHtQpGJ9FhSVwNYmC/Y7uoYJCBIaF5VLG3DVVlbTE7uMPXL3cvf4CZlYGopC EPyJnuwvMylxEjFB0u5UGCo+8z38WtlLGKHtTEZHoXgY/KNOOjfrSDm+8Cb4iYD1eGXD/9rxwbRVq lYnlmoULKITnKwlTjQt6Erymy2lYwKPXOb+1xz82ZnsWRNer+tjbrXqIYWeCBP3qK2cUwZeXuPAM1 VMsAwLHxOvBlioG97B/mMeh1uQUEPQA/6eF1LSXuSoKefn5yap5WoYIpI+qXC6H7+201mQvdMd8vN CXFoLDQHR14EIhNt9DYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIaFX-008Kbv-2i; Fri, 11 Feb 2022 18:02:27 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIaF7-008KPe-Tm for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 18:02:04 +0000 Received: by mail-io1-xd2d.google.com with SMTP id h7so12382262iof.3 for ; Fri, 11 Feb 2022 10:02:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WuU98BQWJ3JvxA0l3dqFEtp2hO3xbYQYBGFwDoum9mA=; b=IQQa84bdtaXRSdyR/rpKt0SgnPXBqmxmJhh+I01uwaxqxWu4ojcAKkL5xNw2hhBGl0 SqAcTIwGJOKoKuNltCzgv257aZj9Vr99QBpN7fDwSCfVrlHje/fQNIOKoT2Oaziq8EXi hkg4zp1Ee8VavOB4GljXvcV5lpnMc4zLiaQNUHF7HdGtilmw7DZd+3t0qKZgd5a2HdpH BakB8fh/e/dFXB9ddZuAAmTUp44pbvrS24H8kEGWZ/eS+JxRgohZIyxGzmv6OnwEinWq gyu2ZbJDXNO8o/ygp6HsRMRkWmTYq9HG8fLk2PoQbf5hE34N7V6vcspEXm8Qk3ExjvaJ +tiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WuU98BQWJ3JvxA0l3dqFEtp2hO3xbYQYBGFwDoum9mA=; b=dG3horCAmMgc4oC29oHsyTqMr3POzYFW2S8tzeQEwhjXWmQxtvL8ktyMulzPO9LyZl lWT8CofJslfpEijNO3BdDWa4TUmw8C0/1x9t5iCcMLtADvWNgE5CNKIuh/8WUSAcJhO/ oTV1booTbZ6joDmr7o6xRnMfkISBCXaSmCScpbSPOWQ07Q3kfiD5ro2CvWWUpVnurog8 LjnCUL4hCbQtZAEavWY2PuRg8b48MMfuWWAo26ChIlyEMnf8OIu3TFlwTZQ45NWOlVUj 3ejxpv9ZYMn/wB9wYjZ8jv7fZRxQ3Yp13sabT3FI+EY5rrKVImtQbScf0B/rfKVtPZru isDw== X-Gm-Message-State: AOAM533zFMsBF38uFlcqYOOSIZJodjPuLsH9sSov4qKkJHOVXWrT1tjF Ja8DIl/NRQDhcc/IdO58FhQ= X-Google-Smtp-Source: ABdhPJxJmxFpXOYmnUs8JwVDIPbLVn5DtmHoImtfp1nRCsmQ3PoW8zuCBCZu/2oyU1rR5Wa33NzJlQ== X-Received: by 2002:a6b:ef06:: with SMTP id k6mr1445483ioh.70.1644602520515; Fri, 11 Feb 2022 10:02:00 -0800 (PST) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id m1sm13808221ilu.87.2022.02.11.10.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 10:02:00 -0800 (PST) Date: Fri, 11 Feb 2022 09:59:49 -0800 From: Yury Norov To: Mark Rutland Cc: Will Deacon , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Greg Kroah-Hartman , Peter Zijlstra , David Laight , Joe Perches , Dennis Zhou , Emil Renner Berthing , Nicholas Piggin , Matti Vaittinen , Alexey Klimov , linux-kernel@vger.kernel.org, Shaokun Zhang , Qi Liu , Khuong Dinh , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 12/49] perf: replace bitmap_weight with bitmap_empty where appropriate Message-ID: References: <20220210224933.379149-1-yury.norov@gmail.com> <20220210224933.379149-13-yury.norov@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220211_100201_986508_F2E0CEED X-CRM114-Status: GOOD ( 26.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 11, 2022 at 10:25:23AM +0000, Mark Rutland wrote: > Hi Yury, > > On Thu, Feb 10, 2022 at 02:48:56PM -0800, Yury Norov wrote: > > In some places, drivers/perf code calls bitmap_weight() to check if any > > bit of a given bitmap is set. It's better to use bitmap_empty() in that > > case because bitmap_empty() stops traversing the bitmap as soon as it > > finds first set bit, while bitmap_weight() counts all bits unconditionally. > > > > Signed-off-by: Yury Norov > > This looks like a nice semantic cleanup to me, so FWIW: Thanks :) > Acked-by: Mark Rutland > > How are you expecting to queue all of this? I expect maintainers of corresponding subsystems will pick most of the material. For the rest, I have my own bitmap branch. > Should Will and I pick this patch? Yes please. > Thanks, > Mark. > > > --- > > drivers/perf/arm-cci.c | 2 +- > > drivers/perf/arm_pmu.c | 4 ++-- > > drivers/perf/hisilicon/hisi_uncore_pmu.c | 2 +- > > drivers/perf/xgene_pmu.c | 2 +- > > 4 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/perf/arm-cci.c b/drivers/perf/arm-cci.c > > index 54aca3a62814..96e09fa40909 100644 > > --- a/drivers/perf/arm-cci.c > > +++ b/drivers/perf/arm-cci.c > > @@ -1096,7 +1096,7 @@ static void cci_pmu_enable(struct pmu *pmu) > > { > > struct cci_pmu *cci_pmu = to_cci_pmu(pmu); > > struct cci_pmu_hw_events *hw_events = &cci_pmu->hw_events; > > - int enabled = bitmap_weight(hw_events->used_mask, cci_pmu->num_cntrs); > > + bool enabled = !bitmap_empty(hw_events->used_mask, cci_pmu->num_cntrs); > > unsigned long flags; > > > > if (!enabled) > > diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c > > index 295cc7952d0e..a31b302b0ade 100644 > > --- a/drivers/perf/arm_pmu.c > > +++ b/drivers/perf/arm_pmu.c > > @@ -524,7 +524,7 @@ static void armpmu_enable(struct pmu *pmu) > > { > > struct arm_pmu *armpmu = to_arm_pmu(pmu); > > struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); > > - int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); > > + bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events); > > > > /* For task-bound events we may be called on other CPUs */ > > if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) > > @@ -785,7 +785,7 @@ static int cpu_pm_pmu_notify(struct notifier_block *b, unsigned long cmd, > > { > > struct arm_pmu *armpmu = container_of(b, struct arm_pmu, cpu_pm_nb); > > struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); > > - int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); > > + bool enabled = !bitmap_empty(hw_events->used_mask, armpmu->num_events); > > > > if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) > > return NOTIFY_DONE; > > diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c > > index a738aeab5c04..358e4e284a62 100644 > > --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c > > +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c > > @@ -393,7 +393,7 @@ EXPORT_SYMBOL_GPL(hisi_uncore_pmu_read); > > void hisi_uncore_pmu_enable(struct pmu *pmu) > > { > > struct hisi_pmu *hisi_pmu = to_hisi_pmu(pmu); > > - int enabled = bitmap_weight(hisi_pmu->pmu_events.used_mask, > > + bool enabled = !bitmap_empty(hisi_pmu->pmu_events.used_mask, > > hisi_pmu->num_counters); > > > > if (!enabled) > > diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c > > index 5283608dc055..0c32dffc7ede 100644 > > --- a/drivers/perf/xgene_pmu.c > > +++ b/drivers/perf/xgene_pmu.c > > @@ -867,7 +867,7 @@ static void xgene_perf_pmu_enable(struct pmu *pmu) > > { > > struct xgene_pmu_dev *pmu_dev = to_pmu_dev(pmu); > > struct xgene_pmu *xgene_pmu = pmu_dev->parent; > > - int enabled = bitmap_weight(pmu_dev->cntr_assign_mask, > > + bool enabled = !bitmap_empty(pmu_dev->cntr_assign_mask, > > pmu_dev->max_counters); > > > > if (!enabled) > > -- > > 2.32.0 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel