From patchwork Sun Jan 23 18:39:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12721089 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 CBD7DC433EF for ; Sun, 23 Jan 2022 18:42:57 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YOlw6cdpvzhw8RBtVaBXM90Nvw5Umv0MzgCq438SBjc=; b=lFwhv/2dX7ILEP Cr6b3so5nXfshdMsELvllAYpG0f9Dc0X2+28KhIgCxLLyVd+r6XpVoZwT/7YSe/6HgpHhnG8Qn042 fZ6FF40t0RTKVPHpE/xMaMJfYON+H1hHUbuGnZbRN4TaykbBl0xkuM6BtZpJg8hP6JekZWYF3jdHA 6AanTM6IkPczRgcIm+1ba2yU6x3xm7eY8VJSuO/gRn4B9zays5scxx1U6GVqayNzZiPEgn5u79jQt bBbJVlXcg7w+RCJr/wy4Cu2+R7eHlrtL565OdagbZ3mRvSDpcaN0lz9imgBcOJaKgNvQPGW3s9nZn Z3A8fOtQ0d3FKZsTNi/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBho2-001ZgP-Th; Sun, 23 Jan 2022 18:41:39 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBhnz-001ZeH-N6 for linux-arm-kernel@lists.infradead.org; Sun, 23 Jan 2022 18:41:37 +0000 Received: by mail-pf1-x42c.google.com with SMTP id v74so10524003pfc.1 for ; Sun, 23 Jan 2022 10:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=T5W4tcAlu9II6TGKyllSre1cwbBZX0+vG2XX1glXT5Y=; b=VC3JAELl4Bcc9x72apcbabSCxL7VtVtW52zOXinf9qQcKr8OiQhjNNZMIrMJHzF88t PBbjx7GVOfENmdJpobQoYLoM0+q14MmtfuHhOG+fjHB0cOXMjZCKVaz6bk6JD+LNKC5B 5NUZ3S71+7ggjbktRx126GlRhxpUMjYhaZ2jbXFyzl5Lj7tIXclBHF9agDV7w5Qy9DhE XHds+SdkFGGW/BxKpgXgtqSdEdTmoAGhhKG9P7xJgfG1bWErw0ZgZPmTOwklfWyoaD2b xRSYuTXb3JFgXIhYF7+jekASh+2hU6RWDE3TB0a2Q1knyPegNCjOVKr8ZN8q72lZ8YSV A6cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T5W4tcAlu9II6TGKyllSre1cwbBZX0+vG2XX1glXT5Y=; b=lBziQvetFRLjMKoJSFZv/1Ea5CmP3qaTZRGb9Tq14q3xB7isSdYHLMngTIMbsXXRdq xacAmECI6LusSbk/MJfzEMoW/WafDIeShZc+THXetkSdtqV1MC8lThBeMBS8vPdIYf/t Eo19zFxAk+tYCmo2REJiuySpUQy17z3ISB1PEcpU7cC+OLyf8wuhcsRL6TfXHWKtDfhV IDYjLf85/mtXNUATQ2Wz1xzisMIkrUP9e8f0g3D3Gk9v+zomuEZEATHVHp1mOggvKPIT Sc3VxFe0d8x3zLSGRzGhM+NpPldDysbjUpcGswrBlcQMi7lps9UpZs/+SMsLDCwbkfWz 6INw== X-Gm-Message-State: AOAM532Imym4ueVmveFrytBjoLpCgnKDnHkk5nbPr0Ev/A3PmhaZZ6IH EqyPYLlGQVFM0klBa3KiVfU= X-Google-Smtp-Source: ABdhPJxNACDhw+pefiza8oco2JDFigwtzNjUitC28s8922ZKmIrgEEtXSDugjM9DU6Y1rqgheHdTqQ== X-Received: by 2002:a63:9347:: with SMTP id w7mr9366776pgm.84.1642963294566; Sun, 23 Jan 2022 10:41:34 -0800 (PST) Received: from localhost (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id k12sm14285241pfc.107.2022.01.23.10.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 10:41:34 -0800 (PST) From: Yury Norov To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Andrew Morton , =?utf-8?b?TWljaGHFgiBNaXJvc8WC?= =?utf-8?b?YXc=?= , 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, Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 34/54] perf: replace bitmap_weight with bitmap_weight_eq for ThunderX2 Date: Sun, 23 Jan 2022 10:39:05 -0800 Message-Id: <20220123183925.1052919-35-yury.norov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220123183925.1052919-1-yury.norov@gmail.com> References: <20220123183925.1052919-1-yury.norov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220123_104135_781380_CE5B9F8F X-CRM114-Status: GOOD ( 12.89 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org tx2_uncore_event_start() calls bitmap_weight() to compare the weight of bitmap with a given number. We can do it more efficiently with bitmap_weight_eq because conditional bitmap_weight may stop traversing the bitmap earlier, as soon as condition is met. Signed-off-by: Yury Norov --- drivers/perf/thunderx2_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/perf/thunderx2_pmu.c b/drivers/perf/thunderx2_pmu.c index 05378c0fd8f3..ebfa66b212c7 100644 --- a/drivers/perf/thunderx2_pmu.c +++ b/drivers/perf/thunderx2_pmu.c @@ -623,8 +623,8 @@ static void tx2_uncore_event_start(struct perf_event *event, int flags) return; /* Start timer for first event */ - if (bitmap_weight(tx2_pmu->active_counters, - tx2_pmu->max_counters) == 1) { + if (bitmap_weight_eq(tx2_pmu->active_counters, + tx2_pmu->max_counters, 1)) { hrtimer_start(&tx2_pmu->hrtimer, ns_to_ktime(tx2_pmu->hrtimer_interval), HRTIMER_MODE_REL_PINNED);